---
title: BLIP2-Chinese
canonical_url: "https://www.modelscope.cn/models/xiajinpeng123/BLIP2-Chinese"
md_url: "https://www.modelscope.cn/models/xiajinpeng123/BLIP2-Chinese.md"
repository: xiajinpeng123/BLIP2-Chinese
chinese_name: "中文BLIP2"
last_updated: 2023-08-22
license: "Apache License 2.0"
pipeline_tag: image-text-retrieval
tasks:
  - image-text-retrieval
library_name:
  - pytorch
frameworks:
  - Pytorch
downloads: 19821
stars: 42
---

# BLIP2-Chinese

> BLIP2-Chinese - xiajinpeng123 在 ModelScope 开源的模型。首个开源的中文BLIP2模型。我们遵循BLIP2的实验设置，采用itc、itm、lm损失，基于2亿中文图文对训练5个epoch，得到第一个中文版本的blip2模型。

xiajinpeng123/BLIP2-Chinese 是 ModelScope 魔搭社区上的image-text-retrieval模型，采用 Apache License 2.0 许可。

- **Repository**: xiajinpeng123/BLIP2-Chinese
- **License**: Apache License 2.0
- **Tasks**: image-text-retrieval
- **Downloads**: 19821
- **Stars**: 42
- **Last updated**: 2023-08-22

Source: https://www.modelscope.cn/models/xiajinpeng123/BLIP2-Chinese

---

# BLIP2-Qformer


## 简介 Brief Introduction

首个开源的中文BLIP2模型。我们遵循BLIP2的实验设置，采用itc、itm、lm损失，基于2亿中文图文对训练5个epoch，得到第一个中文版本的blip2模型。

The first open source Chinese BLIP2. We follow the experimental setup of BLIP2, we adopted itc, itm and lm losses, trained 5 epochs based on 200 million Chinese image pairs, and obtained the first Chinese version of BLIP2. 


### 下游效果 Performance


**Zero-Shot image-to-text-retrieval**

|  model   |  COCO-CN | Flickr30k-CN| 
|  ----  | ----  | ---- | 
| cn_clip  | 60.4 | 80.2| 
| cn_blip2(ours)  | 70.3 | 85.7| 

**Zero-Shot text-to-image-retrieval**

|  model   | COCO-CN | Flickr30k-CN | 
|  ----  | ----  | ---- | 
| cn_clip  | 64.0 | 68.0| 
| cn_blip2(ours)  | 71.4 | 70.46| 

## 使用 Usage

```bash
from modelscope.hub.snapshot_download import snapshot_download
model_path = snapshot_download('xiajinpeng123/BLIP2-Chinese',revision='v1.0.0')
import os
os.chdir(model_path)
import sys
sys.path.insert(0, model_path)
import ms_wrapper
from modelscope.pipelines import pipeline
img = [f"{model_path}/test1.jpg",f"{model_path}/test3.jpg"]
txt=["两台汽车","白色标记","两辆汽车停在公路上","两只小鸟在树上"]
input_dict=dict()
input_dict['img']=img
input_dict['text']=txt
weight_path = f"{model_path}/checkpoint_04.pth"

inference = pipeline('image-text-retrieval', model='xiajinpeng123/BLIP2-Chinese',model_revision='v1.0.0', weight_path=weight_path,device="cuda") # GPU环境可以设置为True
output = inference(input_dict)

print(output)
```

```bash
 git clone https://www.modelscope.cn/xiajinpeng123/BLIP2-Chinese.git
```

## 使用方式及场景
### 使用方式：

- 对输入的图像、文本数据进行特征提取
### 使用场景:

- 通用的图文跨模态检索任务
- 通用图文特征提取器

## 模型局限性以及可能的偏差
- 训练数据集自身有局限，有可能产生一些偏差，请用户自行评测后决定如何使用。

#### 如果喜欢，敬请下载收藏！
