Janus/demo
che.ender ecc599e43e
Update README.md
add swift export
2025-02-26 14:50:48 +08:00
..
app_janusflow.py fix errors 2024-11-13 11:49:24 +08:00
app_januspro.py add Janus-Pro 2025-01-27 23:46:51 +08:00
app.py update demo 2024-10-20 22:41:16 +08:00
fastapi_app.py Create fastapi_app.py 2024-10-22 15:18:11 +08:00
fastapi_client.py Create fastapi_client.py 2024-10-22 15:19:17 +08:00
fastapi_swift.py Fine tune the Janus-Pro-7B model using ms swift, 2025-02-25 17:40:40 +08:00
Janus_colab_demo.ipynb update demo 2024-10-20 22:41:16 +08:00
README.md Update README.md 2025-02-26 14:50:48 +08:00

0 . Fine tuning restrictions

Fine tuning supports training for image understanding but not image generation

1. install ms-swift

use ms-swift Fine tune the Janus-Pro-7B model, First, install ms-swift

pip install git+https://github.com/modelscope/ms-swift.git cd ms-swift pip install -e .

2. Datasets

The dataset format is {"messages": [{"role": "user", "content": "Does the construction worker in this picture comply with the safety regulations for high-altitude operations"}, {"role": "assistant", "content": "In the high-altitude work area, people entering the construction site must wear safety helmets, and high-altitude workers should wear safety belts. The other end of the safety belt must be hung higher than the human body, which is called high hanging and low use. The high-altitude workers in the picture did not wear safety belts, which does not meet the safety standards for high-altitude operations."}], "images": ["root/train/train_images/wpd-36.jpg"]}

3. Fine tuning

lora Fine tuning swift sft --model_type deepseek_janus_pro --model --dataset --target_modules all-linear

full Fine tuning swift sft --model_type deepseek_janus_pro --model --dataset --train_type full

4. swift model export

Export can merge two previously dispersed models into one model system swift export --ckpt_dir

5. swift model Service

swift deploy --ckpt_dir

6. swift model Proxy Service

Create an empty uploads directory fastapi_swift.py

7. Client API fastapi_client. py

Submit questions and receive responses to the swift model Proxy Service using fastapi_client. py

Other1.

fastap_client.py parameters(seed、top_p、temperature ) are no longer useful, but in order to maintain interface reuse, they are retained

Other2.

If no export is performed, then: If the Swift model needs to change the directory, the configuration file needs to be changed Adapterconfig.json Modify 'base_madel_name_or_path' Args.json modifies 'model' Specify the Janus-Pro-7B directory for classical gravity