文件最后提交记录最后更新时间
!4699 [PyTorch][dev][perf]增加DeepLabV3优化代码 * 【PyTorch】【dev】【DeepLabV3】DeepLabV3性能优化 2 年前
!5952 [fix][PyTorch]Adapt to Python 3.8 Merge pull request !5952 from LRJ/master 2 年前
!4784 [PyTorch][dev][perf]取消torch.histc自动在cpu上计算 * 【PyTorch】【dev】【DeepLabV3】DeepLabV3 取消histc patch 2 年前
!4662 [PyTorch][dev][perf]增加DeepLabV3适配代码 * 【PyTorch】【dev】【DeepLabV3】DeepLabV3适配代码上传 3 年前
文档整改,gitee->gitcode Co-authored-by: Lighters_c<zyh13227@163.com> # message auto-generated for no-merge-commit merge: !7469 merge ffffix into master 文档整改,gitee->gitcode Created-by: addsubmuldiv Commit-by: Lighters_c 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!74695 个月前
README.md

DeepLabV3 for PyTorch

概述

DeepLabv3是在DeepLabv1、DeepLabv2的基础上发展而来,DeepLab系列主要围绕空洞卷积、全连接条件随机场(Fully-connected Conditional Random Field (CRF))以及ASPP展开讨论。DeepLabv3重新考虑了空洞卷积的使用,增加了多尺度分割物体的模块,同时改进了ASPP模块。

  • 参考实现:

    url=https://github.com/open-mmlab/mmsegmentation.git
    commit_id=e64548fda0221ad708f5da29dc907e51a644c345
    
  • 适配昇腾 AI 处理器的实现:

    url=https://gitcode.com/ascend/ModelZoo-PyTorch.git
    code_path=PyTorch/dev/perf/DeepLabV3_for_PyTorch
    

准备训练环境

准备环境

  • 当前模型支持的 PyTorch 版本和已知三方库依赖如下表所示。

    表 1 版本支持表

    Torch_Version 三方库依赖版本
    PyTorch 1.5 torchvision==0.2.2.post3
    PyTorch 1.8 torchvision==0.9.1
  • 环境准备指导。

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

  • 安装依赖。

    1、使用 NPU 设备源码编译安装 mmcv-full。

    • 创建MMCV目录,拉取MMCV 源码
    git clone https://github.com/open-mmlab/mmcv.git
    
    • 编译
    MMCV_WITH_OPS=1 MAX_JOBS=8 FORCE_NPU=1 python3 setup.py build_ext
    
    • 安装
    MMCV_WITH_OPS=1 FORCE_NPU=1 python3 setup.py develop
    

    2、安装 MMEngine。

    pip3 install mmengine==0.7.3
    

    3、安装 MMSegmentation

    下载MMSegmentation源码包:

    git clone -b main https://github.com/open-mmlab/mmsegmentation.git
    

    进入MMSegmentation目录,执行以下语句:

    git checkout e64548fda0221ad708f5da29dc907e51a644c345
    pip3 install -e .
    

准备数据集

  1. 获取数据集。

    请用户自行获取原始数据集cityscapes,并在DeepLabV3_for_PyTorch目录新建data文件夹,将下载好的数据集上传至该目录DeepLabV3_for_PyTorch/data

    数据集目录结构参考如下所示。

    $ DeepLabV3_for_PyTorch
        ├── data
        │   └── cityscapes
        │       ├── leftImg8bit
        │       │   ├── train
        │       │   ├── val
        │       │   └── test
        │       └── gtFine
        │           ├── train
        │           ├── val
        │           └── test
        └── ... 
    

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

开始训练

训练模型

  1. 进入DeepLabV3_for_PyTorch目录。

    cd ./DeepLabV3_for_PyTorch
    
  2. 运行训练脚本。

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

    • 单机单卡训练

      启动单卡训练。

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

      启动8卡训练。

      bash ./test/train_full_8p.sh               # 8卡精度
      
      bash ./test/train_performance_8p.sh        # 8卡性能
      

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

    公共参数:
    --use_npu_fused_sgd                         // 是否使用NpuFusedSGD, 默认值false
    

    训练完成后,权重文件保存在当前路径下,并输出模型训练精度和性能信息。

训练结果展示

表 2 训练结果展示表

NAME mIoU FPS iters AMP_Type Torch_Version
1p-竞品A - 13.6 40000 O2 1.8
8p-竞品A 78.09 78.2 40000 O2 1.8
8p-竞品A 77.47 62.4 40000 O0 1.8
1p-NPU - 11.6 40000 O2 1.8
8p-NPU 78.56 86.6 40000 O2 1.8

版本说明

变更

2023.05.15: 更新训练结果。 2023.05.05: 首次发布。

FAQ

无。