Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
BLIP-3_pytorch
Commits
088890af
Commit
088890af
authored
Sep 23, 2025
by
yangzhong
Browse files
update README.md
parent
1b9205c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
32 deletions
+30
-32
README.md
README.md
+30
-32
No files found.
README.md
View file @
088890af
...
@@ -15,11 +15,11 @@ BLIP-3,也叫xGen-MM,是一个用于开发Large的框架多模态模型(lm
...
@@ -15,11 +15,11 @@ BLIP-3,也叫xGen-MM,是一个用于开发Large的框架多模态模型(lm
### Docker(方法一)
### Docker(方法一)
```
```
# 在光源可拉取docker镜像
:
# 在光源可拉取docker镜像
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04.1-py3.10
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04.1-py3.10
# 创建并启动容器
:
# 创建并启动容器
docker run -it --network=host -v /opt/hyhal/:/opt/hyhal/:ro --shm-size=80G --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged=true --device=/dev/kfd --device=/dev/dri/ --ipc=host --group-add video --privileged --name <your_proiect_name> <image_id> bash
docker run -it --network=host -v /opt/hyhal/:/opt/hyhal/:ro --shm-size=80G --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged=true --device=/dev/kfd --device=/dev/dri/ --ipc=host --group-add video --privileged --name <your_proiect_name> <image_id> bash
# 安装依赖包
:
# 安装依赖包
python setup.py install
python setup.py install
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
```
```
...
@@ -29,7 +29,7 @@ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
...
@@ -29,7 +29,7 @@ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
```
```
docker build --no-cache -t blip3_pytorch:latest .
docker build --no-cache -t blip3_pytorch:latest .
docker run -it --network=host --name=blip3_pytorch --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal/:/opt/hyhal/:ro -v /usr/local/hyhal:/usr/local/hyhal:ro blip3_pytorch:latest bash
docker run -it --network=host --name=blip3_pytorch --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal/:/opt/hyhal/:ro -v /usr/local/hyhal:/usr/local/hyhal:ro blip3_pytorch:latest bash
安装依赖
:
安装依赖
python setup.py install
python setup.py install
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
```
```
...
@@ -37,7 +37,7 @@ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
...
@@ -37,7 +37,7 @@ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
### Anaconda(方法三)
### Anaconda(方法三)
```
```
1.创建conda虚拟环境
:
1.创建conda虚拟环境
conda create -n blip3_pytorch python=3.10
conda create -n blip3_pytorch python=3.10
2.关于本项目DCU显卡所需的工具包、深度学习库等均可从光合开发者社区下载安装:https://developer.hpccube.com/tool/
2.关于本项目DCU显卡所需的工具包、深度学习库等均可从光合开发者社区下载安装:https://developer.hpccube.com/tool/
DTK驱动:dtk25.04.1
DTK驱动:dtk25.04.1
...
@@ -55,19 +55,7 @@ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
...
@@ -55,19 +55,7 @@ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
# 训练
# 训练
## 数据集
## 数据集
模型支持llava格式的json数据集文件,json文件结构如下。参考数据集
[
llava_pretrain
](
http://113.200.138.88:18080/aimodels/llava_pretrain
)
。您可以放置多个不同的数据集。
模型支持llava格式的json数据集文件,json文件结构如下
接着您需要配置
[
`data/example_data_config.yaml`
](
./data_configs/example_data_config.yaml
)
文件,包括所有json文件路径和图片数量。如果您的json文件内是数据的相对路径,则还需要配置路径映射文件
[
`data/data_paths.py`
](
./data/data_paths.py
)
。
```
yaml文件:
data_path: {
'/path/to/llava_pretrain.json': 558128
'/path/to/som_qa_coco20k.json': 20160,
'/path/to/som_listing_coco10k.json': 10000,
}
```
```
```
json文件:
json文件:
...
@@ -88,31 +76,42 @@ json文件:
...
@@ -88,31 +76,42 @@ json文件:
]
]
}
}
```
```
LLaVA-Pretrain数据集目录结构如下:
接着您需要配置
[
`data/example_data_config.yaml`
](
./data_configs/example_data_config.yaml
)
文件,包括所有json文件路径和图片数量,yaml文件中可以放置多个不同的数据集。如果您的json文件内是数据的相对路径,则还需要配置路径映射文件
[
`data/data_paths.py`
](
./data/data_paths.py
)
。
```
yaml文件:
data_path: {
'/path/to/blip_laion_cc_sbu_558k.json': 558128
'/path/to/som_qa_coco20k.json': 20160,
'/path/to/som_listing_coco10k.json': 10000,
}
```
本项目训练使用的是SoM-LLaVA数据集,目录结构如下,下载可以通过Hugging Face
[
下载链接
](
https://api-inference.hf-mirror.com/datasets/zzxslp/SoM-LLaVA/tree/main
)
,也可以通过本项目提供的脚本down_dataset_hf.py进行下载。
```
```
/path/to/LLaVA-Pretrain/
/path/to/SoM-LLaVA/
├── blip_laion_cc_sbu_558k.json
├── som_listing_coco10k.json
├── 00000
├── som_llava_mix695k.json
│ ├── 000000010.jpg
├── som_qa_coco20k.json
│ ├── 000000012.jpg
├── som_train2017
│ ├── 000000000001.jpg
│ ├── 000000000009.jpg
│ └── ...
│ └── ...
├── 00001
├── 00002
└── ...
```
```
## 微调
## 微调
#### 预训练权重
#### 预训练权重
可从scnet快速
[
下载链接
](
http://113.200.138.88:18080/aimodels/xgen-mm-phi3-mini-base-r-v1.5
)
获取预训练模型
`xgen-mm-phi3-mini-base-r-v1.5`
运行如下脚本生成pytorch原生格式pt文件,Salesforce/xgen-mm-phi3-mini-base-r-v1.5、microsoft/Phi-3-mini-4k-instruct、google/siglip-so400m-patch14-384会自动从Hugging Face下载,脚本中已添加Hugging Face国内镜像
并运行如下脚本生成pytorch原生格式pt文件:
```
```
# 修改dest_fn参数为保存路径和pt文件名
,以及修改model_name_or_path为预训练模型权重路径
# 修改dest_fn参数为保存路径和pt文件名
python convert_hf_model.py
python convert_hf_model.py
```
```
#### 单机多卡
#### 单机多卡
```
```
bash scripts/
finetune
.sh
bash scripts/
example_finetune_xgenmmv1-phi3_mini_4k_instruct
.sh
```
```
训练脚本参数说明如下
训练脚本参数说明如下
*
`exp_name`
: 训练日志文件名
*
`exp_name`
: 训练日志文件名
...
@@ -149,4 +148,3 @@ AIGC,设计
...
@@ -149,4 +148,3 @@ AIGC,设计
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment