文件最后提交记录最后更新时间
!5870 [built-in][PyTorch][GLIP for PyTorch] open dropout and revise numpy version Merge pull request !5870 from 孙依然/master 2 年前
add 2 年前
!7219 [bugfix][PyTorch] 修复文档中的拼写错误 Merge pull request !7219 from 郑特驹/master 1 年前
add 2 年前
!6551 【BUG FIX】【GLIP_FOR_PYTORCH】GLIP: add viturl memory in default configration of PyTorch Merge pull request !6551 from 胡牛/master 1 年前
!5870 [built-in][PyTorch][GLIP for PyTorch] open dropout and revise numpy version Merge pull request !5870 from 孙依然/master 2 年前
add 2 年前
add 2 年前
add 2 年前
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 个月前
!7219 [bugfix][PyTorch] 修复文档中的拼写错误 Merge pull request !7219 from 郑特驹/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 个月前
!5870 [built-in][PyTorch][GLIP for PyTorch] open dropout and revise numpy version Merge pull request !5870 from 孙依然/master 2 年前
add 2 年前
README.md

GLIP for PyTorch

概述

简述

GLIP是一种用于视觉定位的语言-图像预训练模型,可以学习对象级、语言感知和语义丰富的视觉表示。GLIP统一了预训练的对象检测和短语定位。统一框架带来了两个优点,1)允许GLIP从检测和定位数据中学习,以提高这两项任务的精度并得到一个优秀的定位模型,2)GLIP可以通过自训练的范式利用大量的图文对生成定位框,得到语义丰富的特征。实验证明,GLIP具有强大的零样本、少样本迁移能力。

  • 参考实现:

      url=https://github.com/microsoft/GLIP/
      commit_id=a5f302bfd4c5c67010e29f779e3b0bde94e89985
    
  • 适配昇腾 AI 处理器的实现:

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

准备训练环境

该模型为随版本演进模型(随版本演进模型范围可在此处查看),您可以根据下面提供的安装指导选择匹配的CANN等软件下载使用。

准备环境

  • 推荐参考配套资源文档使用最新的配套版本。

    表 1 版本配套表

    软件 版本 安装指南
    Driver AscendHDK 24.1.RC3 驱动固件安装指南
    Firmware AscendHDK 24.1.RC3
    CANN CANN 8.0.RC3 CANN 软件安装指南
    PyTorch 2.1.0 Ascend Extension for PyTorch 配置与安装
    torch_npu release v6.0.rc3
  • 环境准备指导。

    请参考《Pytorch框架训练环境准备》。

  • 安装依赖。

    在模型源码包根目录下执行命令,安装模型对应PyTorch版本需要的依赖。

    pip install -r requirements.txt
    python setup.py build develop
    
  • 注意 mmcv-full 需要拉取1.x分支的最新代码源码编译,不要使用pip安装方式。(如果环境中有mmcv,请先卸载再编译安装)

    git clone -b 1.x https://github.com/open-mmlab/mmcv.git
    cd mmcv
    MMCV_WITH_OPS=1 MAX_JOBS=8 FORCE_NPU=1 python setup.py build_ext
    pip install -r requirements/runtime.txt
    MMCV_WITH_OPS=1 FORCE_NPU=1 python setup.py develop
    
  • 如果环境中自动安装了torch和torchvision,请先卸载再安装正确依赖版本

准备训练数据集

使用coco2017数据集。 准备好数据集后放到 /${模型文件夹名称} 目录下,并重命名为coco

├── coco
      ├── annotations               
      	├── instances_train2017.json
      	├── instances_val2017.json ...
      ├── train2017
      	├── 000000******.jpg ...
      ├── val2017
      	├── 000000******.jpg ...

说明: 该数据集的训练过程脚本只作为一种参考示例。

准备预训练模型

  • 下载预训练模型glip_tiny_model_o365_goldg_cc_sbu.pth,路径为/${模型文件夹名称}/pretrain/glip_tiny_model_o365_goldg_cc_sbu.pth。
  • 下载预训练语言模型文件夹bert-base-uncased,路径为/${模型文件夹名称}/bert-base-uncased。

开始训练

训练模型

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

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

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

    • 单机单卡训练

      启动单卡训练:

      bash test/train_full_1p.sh         #单卡训练
      
      bash test/train_performance_1p.sh  #单卡性能测试
      
    • 单机8卡训练

      启动8卡训练:

      bash test/train_full_8p.sh          #多卡训练
      
      bash test/train_performance_8p.sh   #多卡性能测试
      

    --batch_size //训练批次大小

    --load_from //加载的预训练参数路径

    --fp32 //开启fp32模式

    --fp16 //开启fp16模式

    模型训练脚本参数说明如下。

       --config-file                  //配置文件
       --override_output_dir          //结果保存路径
       --early_stop_iteration         //早停训练迭代数
       MODEL.WEIGHT                   //预训练权重路径
       MODEL.LANGUAGE_BACKBONE.TOKENIZER_PATH   //分词模型路径
       MODEL.LANGUAGE_BACKBONE.MODEL_PATH       //预训练bert权重路径
       SOLVER.IMS_PER_BATCH           //训练批次大小
       SOLVER.USE_AMP                 //使能混精训练
       SOLVER.MAX_EPOCH               //训练epoch数
    

    训练完成后,权重文件保存在/${模型文件夹名称}/test/output路径下,并输出模型训练精度和性能信息。

训练结果展示

表 2 训练结果展示表

NAME mAP FPS USE AMP Iterations Batch Size Torch_Version
8p-NPU 54.5 6.941 False 35000 8 1.11
8p-竞品A 54.5 8.023 False 35000 8 1.9
8p-NPU 54.7 6.737 True 35000 8 1.11
8p-竞品A 54.4 7.371 True 35000 8 1.9

版本说明

变更

2023.09.08:首次发布。

FAQ

无。

公网地址说明

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