文件最后提交记录最后更新时间
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!7007 [bugfix] fixed training error based pytorch2.5 Merge pull request !7007 from bigdog1206/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!7082 [性能] clip性能优化 Merge pull request !7082 from bigdog1206/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!7376 optimize public_address_statement.md Merge pull request !7376 from 王凯宇/master 8 个月前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
!6719 [built-in][Pytorch] 调整多模态模型存放目录 Merge pull request !6719 from zhangjunyi08/master 1 年前
README.md

ChineseCLIP for PyTorch

概述

简述

本项目为CLIP模型的中文版本,使用大规模中文数据进行训练(~2亿图文对),旨在帮助用户快速实现中文领域的图文特征&相似度计算、跨模态检索、零样本图片分类等任务。

  • 参考实现:

    url=https://github.com/OFA-Sys/Chinese-CLIP
    commit_id=2c38d03557e50eadc72972b272cebf840dbc34ea
    
  • 适配昇腾 AI 处理器的实现:

    url=https://gitcode.com/ascend/ModelZoo-PyTorch.git
    code_path=PyTorch/built-in/others
    

准备训练环境

准备环境

准备预训练模型与词表

准备数据集

开始训练

训练模型

  1. 进入解压后的源码包根目录。

    cd /${模型文件夹名称}
    
  2. 运行训练脚本。

    该模型支持单机单卡训练和单机8卡训练。

    • 单机单卡训练

      启动单卡训练。

      bash test/flickr30k_finetune_vit-b-16_rbt-base_full_1p.sh .        # 单卡训练 vit-b
      bash test/flickr30k_finetune_vit-h-14_rbt-large_full_1p.sh .       # 单卡训练 vit-h
      
      bash test/flickr30k_finetune_vit-b-16_rbt-base_performance_1p.sh .        # 单卡性能 vit-b
      bash test/flickr30k_finetune_vit-h-14_rbt-large_performance_1p.sh .       # 单卡性能 vit-h
      
    • 单机8卡训练

      启动8卡训练。

      bash test/flickr30k_finetune_vit-b-16_rbt-base_full_8p.sh .        # 8卡训练 vit-b
      bash test/flickr30k_finetune_vit-h-14_rbt-large_full_8p.sh .       # 8卡训练 vit-h
      
      bash test/flickr30k_finetune_vit-b-16_rbt-base_performance_8p.sh .        # 8卡性能 vit-b
      bash test/flickr30k_finetune_vit-h-14_rbt-large_performance_8p.sh .       # 8卡性能 vit-h
      

    训练完成后,权重文件保存在./experiments下,并输出模型训练精度和性能信息。

模型推理

  1. 支持speed_benchmark

    • 进行speed_benchmark测试
      bash test/speed_benchmark_eval.sh .        # speed_benchmark测试
      
  2. 支持zeroshot

    • 进行zeroshot测试
      bash test/zeroshot_eval.sh .        # zeroshot测试
      

训练结果展示

表 2 训练结果展示表

pretrain_model 芯片 卡数 text_to_image_R@5 image_to_text_R@5 FPS Epochs batch_size
vit-b Atlas 800T A2 8p 94.76 98.7 2280.00 3 128
vit-b 竞品A 8p 94.63 98.97 2512.40 3 128
vit-h Atlas 800T A2 8p 95.18 98.7 316.07 3 32
vit-h 竞品A 8p 95.34 99.4 348.13 3 32

表 3 zeroshot结果展示表

NAME zeroshot-top1
Atlas 800T A2 64.44
竞品A 64.32

版本说明

变更

2023.08.29:首次提交。

2023.09.04:适配NPU,新增训练和性能脚本。

2023.09.05:新增推理测试脚本。

FAQ

无。

公网地址说明

代码涉及公网地址参考 public_address_statement.md