-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e19dab9
commit 4dcd888
Showing
14 changed files
with
744 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ python3 export_onnx.py --model_path your_minicpmv_path | |
此处介绍如何将onnx模型编译成bmodel。也可以省去编译模型这一步,直接下载编译好的模型: | ||
|
||
``` shell | ||
python3 -m dfss [email protected]:/ext_model_information/LLM/LLM-TPU/minicpmv26_bm1684x_int4.bmodel | ||
python3 -m dfss [email protected]:/ext_model_information/LLM/LLM-TPU/minicpmv26_bm1684x_int4_seq1024.bmodel | ||
``` | ||
|
||
#### 1. 下载docker,启动容器 | ||
|
@@ -61,12 +61,9 @@ source ./envsetup.sh #激活环境变量 | |
|
||
#### 3. 编译模型生成bmodel | ||
|
||
对ONNX模型进行编译,生成模型`minicpmv26_bm1684x_int4.bmodel` | ||
对ONNX模型进行编译,生成模型 | ||
|
||
``` shell | ||
cd compile | ||
./compile.sh | ||
``` | ||
具体请参考python_demo/README.md | ||
|
||
## 编译与运行程序 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,30 @@ | |
## Export onnx | ||
|
||
```shell | ||
pip install transformers_stream_generator einops tiktoken accelerate torch==2.0.1+cpu torchvision==0.15.2 transformers==4.40.0 | ||
pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu | ||
pip install transformers_stream_generator einops tiktoken accelerate transformers==4.40.0 | ||
cp files/MiniCPM-V-2_6/modeling_qwen2.py /usr/local/lib/python3.10/dist-packages/transformers/models/qwen2/ | ||
cp files/MiniCPM-V-2_6/resampler.py your_torch_model | ||
cp files/MiniCPM-V-2_6/modeling_navit_siglip.py your_torch_model | ||
``` | ||
your_torch_model是你模型的位置 | ||
```shell | ||
python3 export_onnx.py --model_path your_torch_model --seq_length 512 --device cpu | ||
python3 export_onnx.py --model_path your_torch_model --seq_length 1024 --device cpu --image_file ../python_demo/test0.jpg | ||
``` | ||
* image_file:image_file为真实图片的路径,导出模型时,输入size会固定为该图片的size。`image_file请输入你实际的图片` | ||
* 目前不支持多图,不支持图片size可变 | ||
|
||
## Compile bmodel | ||
使用io_alone | ||
``` | ||
./compile.sh --mode int4 --name minicpmv26 --seq_length 512 | ||
./compile.sh --mode int4 --name minicpmv26 --seq_length 1024 | ||
``` | ||
|
||
### 下载迁移好的模型 | ||
也可以直接下载编译好的模型,不用自己编译 | ||
```shell | ||
pip3 install dfss | ||
python3 -m dfss [email protected]:/ext_model_information/LLM/LLM-TPU/minicpm_int4_seq512_1dev.bmodel | ||
python3 -m dfss [email protected]:/ext_model_information/LLM/LLM-TPU/minicpmv26_bm1684x_int4_seq1024.bmodel | ||
``` | ||
|
||
### python demo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ pip3 install gradio==3.39.0 mdtex2html==1.2.0 dfss | |
|
||
如果不打算自己编译模型,可以直接用下载好的模型 | ||
``` | ||
python3 -m dfss [email protected]:/ext_model_information/LLM/LLM-TPU/minicpmv26_bm1684x_int4.bmodel | ||
python3 -m dfss [email protected]:/ext_model_information/LLM/LLM-TPU/minicpmv26_bm1684x_int4_seq1024.bmodel | ||
``` | ||
|
||
编译库文件 | ||
|
@@ -20,5 +20,5 @@ cd build && cmake .. && make && cp *cpython* .. && cd .. | |
|
||
# python demo | ||
``` | ||
python3 pipeline.py --model_path minicpmv26_bm1684x_int4.bmodel --tokenizer_path ../support/token_config/ --devid 0 | ||
``` | ||
python3 pipeline.py --model_path minicpmv26_bm1684x_int4_seq1024.bmodel --processor_path ../support/processor_config/ --devid 0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.