diff --git a/PyTorch/built-in/cv/semantic_segmentation/DeepLabv3+_ID1695_for_PyTorch/README.md b/PyTorch/built-in/cv/semantic_segmentation/DeepLabv3+_ID1695_for_PyTorch/README.md index 3b55edf27b4b539dc869a9da75b37185973348af..b4356fc95aeddaad8a2e437620d2d95048ccef63 100644 --- a/PyTorch/built-in/cv/semantic_segmentation/DeepLabv3+_ID1695_for_PyTorch/README.md +++ b/PyTorch/built-in/cv/semantic_segmentation/DeepLabv3+_ID1695_for_PyTorch/README.md @@ -1,42 +1,157 @@ -# Deeplabv3+ +# DeepLabv3+_ID1695 for PyTorch +- [概述](#概述) +- [准备训练环境](#准备训练环境) +- [开始训练](#开始训练) +- [训练结果展示](#训练结果展示) +- [版本说明](#版本说明) -Deeplabv3+ is an end-2-end semantic segmentation model. This implements training of deeplabv3+ on the PASCAL VOC2012 dataset, mainly modified from (https://github.com/jfzhang95/pytorch-deeplab-xception). +# 概述 +- DeepLabv3+是一种语义分割架构,它在[DeepLabv2](https://paperswithcode.com/method/deeplabv2)的基础上进行了一些修改。为了处理在多个尺度上分割对象的问题,设计了在级联或并行中采用多孔卷积的模块,通过采用多个多孔速率来捕获多尺度上下文。此外,来自 DeepLabv2 的 Atrous Spatial Pyramid Pooling模块增加了编码全局上下文的图像级特征,并进一步提高了性能。 -## Requirements + 本文在PASCAL VOC2012数据集上进行了deeplabv3+模型的训练。 + +- 参考实现: -- Install PyTorch ([pytorch.org](http://pytorch.org)) -- `pip install matplotlib pillow tensorboardX tqdm` -- modify env.sh to match your server setttings -- Model is trained and tested against PASCAL VOC2012 dataset, if you already have the dataset, change line 6 in ./mypath.py to point to '$VOCdevkit/VOC2012' - if you dont have the data installed on server, download and prepare like this(then change the path to ./data/VOC2012): -``` + ``` + url=https://github.com/jfzhang95/pytorch-deeplab-xception + commit_id=9135e104a7a51ea9effa9c6676a2fcffe6a6a2e6 + ``` + +- 适配昇腾 AI 处理器的实现: + + ``` + url=https://gitee.com/ascend/ModelZoo-PyTorch.git + code_path=PyTorch/built-in/cv/semantic_segmentation + ``` + +- 通过Git获取代码方法如下: + + ``` + git clone {url} # 克隆仓库的代码 + cd {code_path} # 切换到模型代码所在路径,若仓库下只有该模型,则无需切换 + ``` + +- 通过单击“立即下载”,下载源码包。 + +# 准备训练环境 + +## 准备环境 + +- 当前模型支持的固件与驱动、 CANN 以及 PyTorch 如下表所示。 + + **表 1** 版本配套表 + + | 配套 | 版本 | + |------------------------------------------------------------------------------| ------------------------------------------------------------ | + | 硬件 | [1.0.17](https://www.hiascend.com/hardware/firmware-drivers?tag=commercial) | + | NPU固件与驱动 | [6.0.rc1](https://www.hiascend.com/hardware/firmware-drivers?tag=commercial) | + | CANN | [6.0.RC1](https://www.hiascend.com/software/cann/commercial?version=6.0.RC1) | + | PyTorch | [1.8.1](https://gitee.com/ascend/pytorch/tree/master/) | + + +- 环境准备指导。 + + 请参考《[Pytorch框架训练环境准备](https://www.hiascend.com/document/detail/zh/ModelZoo/pytorchframework/ptes)》。 + +- 安装依赖。 + + ``` + pip3 install -r requirements.txt + ``` + +## 准备数据集 + +1. 获取数据集。 + + 用户需要使用PASCAL VOC2012数据集,可以在源码包根目录通过以下命令来下载: + + ``` mkdir data cd data wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar tar -xf VOCtrainval_11-May-2012.tar -``` -## Training -Note: pillow recommends installing a newer version. If the corresponding torchvision version cannot be installed directly, you can use the source code to install the corresponding version. The source code reference link: https://github.com/pytorch/vision. -Suggestion: the pillow is 9.1.0 and the torchvision is 0.6.0 when torch version is 1.5; torchvision version is 0.9.1 when torch version is 1.8; + ``` + + 修改mypath.py中第33行 `dataset_path=""`为PASCAL VOC2012数据集的路径,例如:`dataset_path="./data/VOC2012"` + + PASCAL VOC2012数据集目录结构参考如下所示: + + ``` + /data + └── VOC2012 + ├── Annotations + ├── ImageSets + │ └── Segmentation + ├── JPEGImages + ├── SegmentationObject + └── SegmentationClass + ``` + + > **说明:** + > 数据集路径以用户自行定义的路径为准 + +# 开始训练 + +## 训练模型 +1. 进入解压后的源码包根目录。 + + ``` + cd /${模型文件夹名称} + ``` + +2. 运行训练脚本。 + + 该模型支持单机单卡训练和单机8卡训练。 + - 单机单卡训练 + + 启动单卡训练。 + + ``` + bash ./test/train_performance_1p.sh --data_path=`data path` --epochs='train epochs' # 1p 性能训练 + + bash ./test/train_full_1p.sh --data_path=`data path` --epochs='train epochs' # 1p 精度训练 + + ``` + + - 单机8卡训练 + + 启动8卡训练。 + ``` + bash ./test/train_performance_8p.sh --data_path=`data path` --epochs='train epochs' # 8p 性能训练 + + bash ./test/train_full_8p.sh --data_path=`data path` --epochs='train epochs' # 8p 精度训练 + ``` + + + 模型训练脚本参数说明如下: + + ``` + --data_path //数据集路径 + --dataset //数据集名称,默认值pascal + --epochs //训练的epoch数量 + --precision_mode //混合精度level,可选值O1/O2/O3 + --num_classes //分类个数 + --resume //从checkpoint继续训练 + ``` + + + +# 训练结果展示 + +**表 2** 训练结果展示表 -To train a model, run "train_NPU_fp32.py" or "train_NPU_fp32_8p.py"with the desired model architecture and the other hyper-parameters. -For testing, use "train_NPU.py" or "train_NPU_8p.py" (have to modify env.sh). +| NAME | mIOU | FPS | Epochs | AMP_Type | +| ------ | ----- | :---- | ------ | -------: | +| 1p-NPU | 0.759 | 13.96 | 100 | fp32 | +| 8p-NPU | 0.751 | 65.86 | 100 | fp32 | -You can also directly use the scripts for training: -``` -bash ./test/train_performance_1p.sh --data_path=`data path` --epochs='train epochs' # 1-board training for performance -bash ./test/train_performance_8p.sh --data_path=`data path` --epochs='train epochs' # 8-board training for performance +# 版本说明 -bash ./test/train_full_1p.sh --data_path=`data path` --epochs='train epochs' # 1-board training for accuracy -bash ./test/train_full_8p.sh --data_path=`data path` --epochs='train epochs' # 8-board training for accuracy +## 变更 -``` +2023.01.12:readme整改。 -## Deeplabv3+ training result +## 已知问题 -| mIOU | FPS | Npu_nums | Epochs | AMP_Type | -| :------:| :------: | :------: | :------: | :------: | -| 0.759 | 13.96 | 1 | 100 | fp32 | -| 0.751 | 65.86 | 8 | 100 | fp32 | +无。