diff --git a/TensorFlow/built-in/cv/image_classification/3D_ResNet_ID0486_for_TensorFlow/README.md b/TensorFlow/built-in/cv/image_classification/3D_ResNet_ID0486_for_TensorFlow/README.md index e3413e83d566741678f82799b40301fe5978690a..07a94124c7461394a9a804807a369fc1e7d9db1d 100644 --- a/TensorFlow/built-in/cv/image_classification/3D_ResNet_ID0486_for_TensorFlow/README.md +++ b/TensorFlow/built-in/cv/image_classification/3D_ResNet_ID0486_for_TensorFlow/README.md @@ -1,9 +1,9 @@ -- [基本信息](#基本信息.md) -- [概述](#概述.md) -- [训练环境准备](#训练环境准备.md) -- [快速上手](#快速上手.md) -- [迁移学习指导](#迁移学习指导.md) -- [高级参考](#高级参考.md) +- [基本信息](#基本信息.md) +- [概述](#概述.md) +- [训练环境准备](#训练环境准备.md) +- [快速上手](#快速上手.md) +- [迁移学习指导](#迁移学习指导.md) +- [高级参考](#高级参考.md)

基本信息

@@ -13,11 +13,11 @@ **版本(Version):1.1** -**修改时间(Modified) :2021.09.30** +**修改时间(Modified) :2022.04.02** **大小(Size)**_**:81.8K** -**框架(Framework):TensorFlow_1.15.0** +**框架(Framework):TensorFlow 1.15.0** **模型格式(Model Format):ckpt** @@ -30,23 +30,23 @@ **描述(Description):基于TensorFlow框架的3D_ResNet网络训练代码**

概述

-- 3D_ResNet是resnet网络的一种3D拓展,对图像分类的效果有一定提升。 - - 参考论文 +- 3D_ResNet是resnet网络的一种3D拓展,对图像分类的效果有一定提升。 - +- 参考论文: - - 参考实现 + [https://arxiv.org/pdf/1512.03385.pdf](https://arxiv.org/pdf/1512.03385.pdf) - https://github.com/JihongJu/keras-resnet3d +- 参考实现: - - 适配昇腾 AI 处理器的实现: + [https://github.com/JihongJu/keras-resnet3d](https://github.com/JihongJu/keras-resnet3d) - https://gitee.com/ascend/modelzoo/tree/master/built-in/TensorFlow/Official/cv/image_classification/3D_ResNet_ID0486_for_TensorFlow +- 适配昇腾 AI 处理器的实现: + + [https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_classification/3D_ResNet_ID0486_for_TensorFlow](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_classification/3D_ResNet_ID0486_for_TensorFlow) +- 通过Git获取对应commit\_id的代码方法如下: -- 通过Git获取对应commit\_id的代码方法如下: - ``` git clone {repository_url} # 克隆仓库的代码 cd {repository_name} # 切换到模型的代码仓目录 @@ -61,18 +61,12 @@ - 单卡batchsize:10 - 总Epoch数:20 -- 训练数据集预处理: - - 模型使用自制数据集 - -- 测试数据集预处理: - - 模型使用自制数据集 - - 训练超参(单卡): - Batch size: 10 - Train epoch: 20 -## 支持特性 +## 支持特性 | 特性列表 | 是否支持 | | ---------- | -------- | @@ -89,42 +83,29 @@ 相关代码示例。 ``` -custom_op.name = "NpuOptimizer" -custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") +config_proto = tf.ConfigProto(allow_soft_placement=True) + custom_op = config_proto.graph_options.rewrite_options.custom_optimizers.add() + custom_op.name = 'NpuOptimizer' + custom_op.parameter_map["use_off_line"].b = True + custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") + config_proto.graph_options.rewrite_options.remapping = RewriterConfig.OFF + session_config = npu_config_proto(config_proto=config_proto) ```

训练环境准备

-1. 硬件环境准备请参见各硬件产品文档"[驱动和固件安装升级指南]( https://support.huawei.com/enterprise/zh/category/ai-computing-platform-pid-1557196528909)"。需要在硬件设备上安装与CANN版本配套的固件与驱动。 -2. 宿主机上需要安装Docker并登录[Ascend Hub中心](https://ascendhub.huawei.com/#/detail?name=ascend-tensorflow-arm)获取镜像。 - - 当前模型支持的镜像列表如[表1](#zh-cn_topic_0000001074498056_table1519011227314)所示。 - - **表 1** 镜像列表 - - - - - - - - - - - - -

镜像名称

-

镜像版本

-

配套CANN版本

-
-

21.0.2

-

5.0.2

-
+- 硬件环境和运行环境准备请参见《[CANN软件安装指南](https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373?category=installation-update)》 +- 运行以下命令安装依赖。 +``` +pip3 install requirements.txt +``` +说明:依赖配置文件requirements.txt文件位于模型的根目录

快速上手

## 数据集准备 + 1. 模型训练使用自制数据集,数据集制作方法如下: ```python @@ -141,7 +122,7 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec 2. 生成数据集后,在训练脚本中指定数据集路径,即可正常使用。 ## 模型训练 -- 下载训练脚本。 +- 单击“立即下载”,并选择合适的下载方式下载源码包。 - 开始训练。 1. 启动训练之前,首先要配置程序运行相关环境变量。 @@ -156,58 +137,62 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec 2.1 设置单卡训练参数(脚本位于./3D_ResNet_ID0486_for_TensorFlow/test/train_full_1p.sh),示例如下。 - ``` - # 训练epoch - train_epochs=20 - # 训练batch_size - batch_size=10 - ``` - 2.2 单卡训练指令(脚本位于./3D_ResNet_ID0486_for_TensorFlow/test/train_full_1p.sh) - ``` - bash train_full_1p.sh - ``` + # 训练epoch + train_epochs=20 + # 训练batch_size + batch_size=10 + ``` + + + 2.2 单卡训练指令(脚本位于./3D_ResNet_ID0486_for_TensorFlow/test/train_full_1p.sh) + + ``` + 于终端中运行export ASCEND_DEVICE_ID=0 (0~7)以指定单卡训练时使用的卡 + bash train_full_1p.sh --data_path=xx + 数据集应有如下结构(数据切分可能不同),配置data_path时需指定为data这一层,例:--data_path=/home/data + ├─data + ├─X_train.npy + ├─labels.npy + ├─y_train.npy + ```

迁移学习指导

- 数据集准备。 1. 获取数据。 - 请参见“快速上手”中的数据集准备。 - - -- 模型训练。 - - 请参考“快速上手”章节。 + 请参见“快速上手”中的数据集准备 + +- 模型训练 + 请参考“快速上手”章节

高级参考

## 脚本和示例代码 - ├── LICENSE - ├── README.md - ├── modelzoo_level.txt - ├── requirements.txt + + ├── README.md //说明文档 + ├── requirements.txt //依赖 ├── test - │   ├── train_full_1p.sh // 执行训练脚本 - │   └── train_performance_1p.sh // 执行训练脚本 - └── train.py // 训练入口脚本 + | |—— train_full_1p.sh //单卡训练脚本 + | |—— train_performance_1p.sh //单卡训练脚本 + ├── train.py //训练入口脚本 ## 脚本参数 ``` ---X_train_file X_train_file ---labels_file labels_file ---y_train_file y_train_file ---train_epochs train_epochs ---batch_size batch_size +X_train_file X_train_file +labels_file labels_file +y_train_file y_train_file +batch_size 训练batch_size +learning_rate 初始学习率 +train_epochs 总训练epoch数 ``` ## 训练过程 -1. 通过“模型训练”中的训练指令启动单卡训练。 -2. 将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 -3. 模型存储路径为“curpath/output/$ASCEND_DEVICE_ID”,包括训练的log以及checkpoints文件。 -4. 以单卡训练为例,loss信息在文件curpath/output/{ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log中。 +通过“模型训练”中的训练指令启动单卡训练。 +将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 \ No newline at end of file diff --git a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/README.md b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/README.md index ab130be83da7e71c47f382a59f54ee4ad578be9f..02ed521d45b893cd9488c49722bec5e7affe9c9d 100644 --- a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/README.md +++ b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/README.md @@ -13,11 +13,11 @@ **版本(Version):1.1** -**修改时间(Modified) :2021.12.29** +**修改时间(Modified) :2022.04.02** -**大小(Size):68K** +**大小(Size)**_**:68K** -**框架(Framework):TensorFlow_1.15.0** +**框架(Framework):TensorFlow 1.15.0** **模型格式(Model Format):ckpt** @@ -30,23 +30,23 @@ **描述(Description):基于TensorFlow框架的Face-ResNet50网络训练代码**

概述

-- Face-ResNet50 是基于 ResNet50 为 backbone 实现的跨年龄人脸识别网络。 + +- Face-ResNet50 是基于 ResNet50 为 backbone 实现的跨年龄人脸识别网络。 - 参考论文: - https://link.springer.com/content/pdf/10.1007/978-3-319-10599-4_49.pdf + [https://link.springer.com/content/pdf/10.1007/978-3-319-10599-4_49.pdf](https://link.springer.com/content/pdf/10.1007/978-3-319-10599-4_49.pdf) - 参考实现: - https://github.com/KaihuaTang/ResNet50-Tensorflow-Face-Recognition + [https://github.com/KaihuaTang/ResNet50-Tensorflow-Face-Recognition](https://github.com/KaihuaTang/ResNet50-Tensorflow-Face-Recognition) - 适配昇腾 AI 处理器的实现: + + [https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow) - https://gitee.com/ascend/modelzoo/tree/master/built-in/TensorFlow/Research/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow - +- 通过Git获取对应commit\_id的代码方法如下: -- 通过Git获取对应commit_id的代码方法如下: - ``` git clone {repository_url} # 克隆仓库的代码 cd {repository_name} # 切换到模型的代码仓目录 @@ -61,13 +61,7 @@ - 初始学习率:1e-06 - 单卡batchsize:32 - Epoch:1 - -- 训练数据集预处理: - - 模型使用 Cross-Age Celebrity Dataset (CACD) 数据集,请用户自行下载 - -- 测试数据集预处理: - - 模型使用 Cross-Age Celebrity Dataset (CACD) 数据集,请用户自行下载 - + - 训练超参(单卡): - Batch size: 32 - Momentum: 0.9 @@ -75,7 +69,7 @@ - Train epoch: 1 -## 支持特性 +## 支持特性 | 特性列表 | 是否支持 | | ---------- | -------- | @@ -92,42 +86,29 @@ 相关代码示例。 ``` -custom_op.name = "NpuOptimizer" -custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") +config_proto = tf.ConfigProto(allow_soft_placement=True) + custom_op = config_proto.graph_options.rewrite_options.custom_optimizers.add() + custom_op.name = 'NpuOptimizer' + custom_op.parameter_map["use_off_line"].b = True + custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") + config_proto.graph_options.rewrite_options.remapping = RewriterConfig.OFF + session_config = npu_config_proto(config_proto=config_proto) ```

训练环境准备

-1. 硬件环境准备请参见各硬件产品文档"[驱动和固件安装升级指南]( https://support.huawei.com/enterprise/zh/category/ai-computing-platform-pid-1557196528909)"。需要在硬件设备上安装与CANN版本配套的固件与驱动。 -2. 宿主机上需要安装Docker并登录[Ascend Hub中心](https://ascendhub.huawei.com/#/detail?name=ascend-tensorflow-arm)获取镜像。 - - 当前模型支持的镜像列表如[表1](#zh-cn_topic_0000001074498056_table1519011227314)所示。 - - **表 1** 镜像列表 - - - - - - - - - - - - -

镜像名称

-

镜像版本

-

配套CANN版本

-
-

21.0.2

-

5.0.2

-
+- 硬件环境和运行环境准备请参见《[CANN软件安装指南](https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373?category=installation-update)》 +- 运行以下命令安装依赖。 +``` +pip3 install requirements.txt +``` +说明:依赖配置文件requirements.txt文件位于模型的根目录

快速上手

## 数据集准备 + 1. 模型训练使用 Cross-Age Celebrity Dataset (CACD) 数据集,数据集请用户自行获取。 2. 获取数据集后,放入模型目录下,在训练脚本中指定数据集路径,可正常使用。数据集文件结构示例如下: ``` @@ -142,8 +123,8 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec ``` ## 模型训练 -- 单击“立即下载”,并选择合适的下载方式下载源码包 -- 开始训练 +- 单击“立即下载”,并选择合适的下载方式下载源码包。 +- 开始训练。 1. 启动训练之前,首先要配置程序运行相关环境变量。 @@ -155,60 +136,66 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec 2. 单卡训练 2.1 设置单卡训练参数(脚本位于./Face-ResNet50_ID1372_for_TensorFlow/test/train_full_1p.sh),示例如下。 - -``` + + + ``` # 训练epoch train_epochs=1 # 训练batch_size batch_size=32 # 数据集文件 data_path=./ResNet50_dataset -``` - 2.2 单卡训练指令(脚本位于./Face-ResNet50_ID1372_for_TensorFlow/test/train_full_1p.sh),示例如下。 -``` - bash train_full_1p.sh --data_path=./ResNet50_dataset -``` + ``` + + + + 2.2 单卡训练指令(脚本位于./Face-ResNet50_ID1372_for_TensorFlow/test/train_full_1p.sh) + + ``` + 于终端中运行export ASCEND_DEVICE_ID=0 (0~7)以指定单卡训练时使用的卡 + bash train_full_1p.sh --data_path=xx + 数据集应有如下结构(数据切分可能不同),配置data_path时需指定为data这一层,例:--data_path=/home/ResNet50_dataset + ├── ResNet50_dataset + │   ├── label // label文件夹 + │   │   ├── label_1200.npy + │   │   ├── name_1200.npy + │   ├── train_data // train_data文件夹 + │   │   ├── 1200_data.npy + │   ├── CACD2000_Crop // CACD文件夹 + ```

迁移学习指导

- 数据集准备。 1. 获取数据。 - 请参见“快速上手”中的数据集准备。 - - -- 模型训练。 - - 请参考“快速上手”章节。 + 请参见“快速上手”中的数据集准备 + +- 模型训练 + 请参考“快速上手”章节

高级参考

## 脚本和示例代码 - . - ├── LICENSE - ├── README.md - ├── modelzoo_level.txt - ├── requirements.txt + ├── README.md //说明文档 + ├── requirements.txt //依赖 ├── test - │   ├── env.sh - │   ├── train_full_1p.sh // 执行训练脚本 - │   └── train_performance_1p.sh // 执行训练脚本 - └── TrainResNet.py // 训练入口脚本 + | |—— train_full_1p.sh //单卡训练脚本 + | |—— train_performance_1p.sh //单卡训练脚本 + ├── TrainResNet.py // 训练入口脚本 ## 脚本参数 ``` ---batch_size batch_size ---train_epochs train_epochs ---learning_rate learning_rate +batch_size 训练batch_size +learning_rate 初始学习率 +train_epochs 总训练epoch数 ``` ## 训练过程 -1. 通过“模型训练”中的训练指令启动单卡训练。 -2. 将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 -3. 模型存储路径为“curpath/output/$ASCEND_DEVICE_ID”,包括训练的log以及checkpoints文件。 -4. 以单卡训练为例,loss信息在文件curpath/output/{ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log中。 +通过“模型训练”中的训练指令启动单卡训练。 +将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 \ No newline at end of file diff --git a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/README.md b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/README.md index d8dc64a7d7fc7c7d1184e4412a743c62f5d795ad..2461a76dabc30f608b2edf2ea209cc30c711d29f 100644 --- a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/README.md +++ b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/README.md @@ -1,9 +1,9 @@ -- [基本信息](#基本信息.md) -- [概述](#概述.md) -- [训练环境准备](#训练环境准备.md) -- [快速上手](#快速上手.md) -- [迁移学习指导](#迁移学习指导.md) -- [高级参考](#高级参考.md) +- [基本信息](#基本信息.md) +- [概述](#概述.md) +- [训练环境准备](#训练环境准备.md) +- [快速上手](#快速上手.md) +- [迁移学习指导](#迁移学习指导.md) +- [高级参考](#高级参考.md)

基本信息

@@ -13,11 +13,11 @@ **版本(Version):1.1** -**修改时间(Modified) :2021.10.22** +**修改时间(Modified) :2022.04.02** **大小(Size)**_**:60K** -**框架(Framework):TensorFlow_1.15.0** +**框架(Framework):TensorFlow 1.15.0** **模型格式(Model Format):ckpt** @@ -30,23 +30,23 @@ **描述(Description):基于TensorFlow框架的2D_Unet网络训练代码**

概述

-- 2D_Unet网络是一个用于生物医学图像分割的卷积网络。 - - 参考论文 +- 2D_Unet网络是一个用于生物医学图像分割的卷积网络。 - 无 +- 参考论文: - - 参考实现 + [https://arxiv.org/abs/1505.04597](https://arxiv.org/abs/1505.04597) - https://github.com/zhixuhao/unet +- 参考实现: - - 适配昇腾 AI 处理器的实现: + [https://github.com/zhixuhao/unet](https://github.com/zhixuhao/unet) - https://gitee.com/ascend/modelzoo/tree/master/built-in/TensorFlow/Official/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow +- 适配昇腾 AI 处理器的实现: + + [https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow) +- 通过Git获取对应commit\_id的代码方法如下: -- 通过Git获取对应commit\_id的代码方法如下: - ``` git clone {repository_url} # 克隆仓库的代码 cd {repository_name} # 切换到模型的代码仓目录 @@ -61,13 +61,7 @@ - 优化器:Adam - 单卡batchsize:2 - 总Epoch数:300 - -- 训练数据集预处理: - - 模型使用 isbi challenge 数据集,请用户自行下载。数据预处理方式请关注 data.py。 - -- 测试数据集预处理: - - 模型使用 isbi challenge 数据集,请用户自行下载。数据预处理方式请关注 data.py。 - + - 训练超参(单卡): - Batch size: 2 - Momentum: 0.9 @@ -75,7 +69,7 @@ - Train epoch: 300 -## 支持特性 +## 支持特性 | 特性列表 | 是否支持 | | ---------- | -------- | @@ -92,48 +86,35 @@ 相关代码示例。 ``` -custom_op.name = "NpuOptimizer" -custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") +config_proto = tf.ConfigProto(allow_soft_placement=True) + custom_op = config_proto.graph_options.rewrite_options.custom_optimizers.add() + custom_op.name = 'NpuOptimizer' + custom_op.parameter_map["use_off_line"].b = True + custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") + config_proto.graph_options.rewrite_options.remapping = RewriterConfig.OFF + session_config = npu_config_proto(config_proto=config_proto) ```

训练环境准备

-1. 硬件环境准备请参见各硬件产品文档"[驱动和固件安装升级指南]( https://support.huawei.com/enterprise/zh/category/ai-computing-platform-pid-1557196528909)"。需要在硬件设备上安装与CANN版本配套的固件与驱动。 -2. 宿主机上需要安装Docker并登录[Ascend Hub中心](https://ascendhub.huawei.com/#/detail?name=ascend-tensorflow-arm)获取镜像。 - - 当前模型支持的镜像列表如[表1](#zh-cn_topic_0000001074498056_table1519011227314)所示。 - - **表 1** 镜像列表 - - - - - - - - - - - - -

镜像名称

-

镜像版本

-

配套CANN版本

-
-

21.0.2

-

5.0.2

-
+- 硬件环境和运行环境准备请参见《[CANN软件安装指南](https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373?category=installation-update)》 +- 运行以下命令安装依赖。 +``` +pip3 install requirements.txt +``` +说明:依赖配置文件requirements.txt文件位于模型的根目录

快速上手

## 数据集准备 + 1. 模型训练使用 isbi challenge 数据集,数据集请用户自行获取。 2. 数据预处理方式请关注 data.py。 3. 将预处理后的数据集放入模型目录下,在训练脚本中指定数据集路径,可正常使用。 ## 模型训练 -- 下载训练脚本。 +- 单击“立即下载”,并选择合适的下载方式下载源码包。 - 开始训练。 1. 启动训练之前,首先要配置程序运行相关环境变量。 @@ -148,59 +129,56 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec 2.1 设置单卡训练参数(脚本位于./2D_Unet_ID2337_for_TensorFlow/test/train_full_1p.sh),示例如下。 - ``` - # 训练epoch - train_epochs=300 - # 训练batch_size - batch_size=2 ``` + # 训练epoch + train_epochs=300 + # 训练batch_size + batch_size=2 + ``` + + 2.2 单卡训练指令(脚本位于./2D_Unet_ID2337_for_TensorFlow/test/train_full_1p.sh) - + + ``` + 于终端中运行export ASCEND_DEVICE_ID=0 (0~7)以指定单卡训练时使用的卡 + bash train_full_1p.sh --data_path=xx + 数据集应有如下结构(数据切分可能不同),配置data_path时需指定为data这一层,例:--data_path=/home/2D_Unet_dataset + ├─2D_Unet_dataset + ├─data + ├─membrane ``` - bash train_full_1p.sh - ```

迁移学习指导

- 数据集准备。 1. 获取数据。 - 请参见“快速上手”中的数据集准备。 - - -- 模型训练。 - - 请参考“快速上手”章节。 + 请参见“快速上手”中的数据集准备 + +- 模型训练 + 请参考“快速上手”章节

高级参考

## 脚本和示例代码 - . - ├── LICENSE - ├── README.md - ├── modelzoo_level.txt - ├── requirements.txt + ├── README.md //说明文档 + ├── requirements.txt //依赖 ├── test - │   ├── env.sh - │   ├── train_full_1p.sh // 执行训练脚本 - │   └── train_performance_1p.sh // 执行训练脚本 - └── main.py // 训练入口脚本 - + | |—— train_full_1p.sh //单卡训练脚本 + | |—— train_performance_1p.sh //单卡训练脚本 + ├── main.py //训练入口文件 ## 脚本参数 ``` - ---batch_size batch_size ---train_epochs train_epochs ---learning_rate learning_rate +batch_size 训练batch_size +learning_rate 初始学习率 +train_epochs 总训练epoch数 ``` ## 训练过程 -1. 通过“模型训练”中的训练指令启动单卡训练。 -2. 将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 -3. 模型存储路径为“curpath/output/$ASCEND_DEVICE_ID”,包括训练的log以及checkpoints文件。 -4. 以单卡训练为例,loss信息在文件curpath/output/{ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log中。 +通过“模型训练”中的训练指令启动单卡训练。 +将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 \ No newline at end of file diff --git a/TensorFlow/built-in/cv/image_segmentation/ShapeNet_ID1138_for_TensorFlow/README.md b/TensorFlow/built-in/cv/image_segmentation/ShapeNet_ID1138_for_TensorFlow/README.md index be6d23abb191e3898fa2d9b414aa8a1d40fc8045..7567620258938ab69c75c843523d1275f43c0e09 100644 --- a/TensorFlow/built-in/cv/image_segmentation/ShapeNet_ID1138_for_TensorFlow/README.md +++ b/TensorFlow/built-in/cv/image_segmentation/ShapeNet_ID1138_for_TensorFlow/README.md @@ -13,11 +13,11 @@ **版本(Version):1.1** -**修改时间(Modified) :2021.12.29** +**修改时间(Modified) :2022.04.02** -**大小(Size):132K** +**大小(Size)**_**:132K** -**框架(Framework):TensorFlow_1.15.0** +**框架(Framework):TensorFlow 1.15.0** **模型格式(Model Format):ckpt** @@ -30,23 +30,23 @@ **描述(Description):基于TensorFlow框架的ShapeNet网络训练代码**

概述

-- 与通过定制的卷积算子捕获3D点云中的局部模式的文献相反,本文研究了如何有效地将此类点云投影到2D图像空间中的问题,从而使传统2D卷积神经网络(CNN) )(例如U-Net)可用于细分。为此,我们受到图绘制的激励,并将其重新构造为整数编程问题,以了解每个单个点云的拓扑保留图到网格映射。为了在实践中加快计算速度,我们进一步提出了一种新颖的分层近似算法。 + +- 与通过定制的卷积算子捕获3D点云中的局部模式的文献相反,本文研究了如何有效地将此类点云投影到2D图像空间中的问题,从而使传统2D卷积神经网络(CNN) )(例如U-Net)可用于细分。为此,我们受到图绘制的激励,并将其重新构造为整数编程问题,以了解每个单个点云的拓扑保留图到网格映射。为了在实践中加快计算速度,我们进一步提出了一种新颖的分层近似算法。 - 参考论文: - https://arxiv.org/abs/2003.05593v2 + [https://arxiv.org/abs/2003.05593v2](https://arxiv.org/abs/2003.05593v2) - 参考实现: - https://github.com/Zhang-VISLab/Learning-to-Segment-3D-Point-Clouds-in-2D-Image-Space + [https://github.com/Zhang-VISLab/Learning-to-Segment-3D-Point-Clouds-in-2D-Image-Space](https://github.com/Zhang-VISLab/Learning-to-Segment-3D-Point-Clouds-in-2D-Image-Space) - 适配昇腾 AI 处理器的实现: + + [https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_segmentation/ShapeNet_ID1138_for_TensorFlow](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/image_segmentation/ShapeNet_ID1138_for_TensorFlow) - https://gitee.com/ascend/modelzoo/tree/master/built-in/TensorFlow/Official/cv/image_segmentation/ShapeNet_ID1138_for_TensorFlow - +- 通过Git获取对应commit\_id的代码方法如下: -- 通过Git获取对应commit_id的代码方法如下: - ``` git clone {repository_url} # 克隆仓库的代码 cd {repository_name} # 切换到模型的代码仓目录 @@ -62,13 +62,7 @@ - 单卡batchsize:4 - Epoch:1 - Steps:15000 - -- 训练数据集预处理: - - 模型使用 shapenet_part_seg_hdf5_data 数据集,请用户自行下载,具体获取方法参见 ./ShapeNet_ID1138_for_TensorFlow/S0_download_data.sh 。 - -- 测试数据集预处理: - - 模型使用 shapenet_part_seg_hdf5_data 数据集,请用户自行下载,具体获取方法参见 ./ShapeNet_ID1138_for_TensorFlow/S0_download_data.sh 。 - + - 训练超参(单卡): - Batch size: 4 - Learning rate: 1e-4 @@ -76,7 +70,7 @@ - Train steps:15000 -## 支持特性 +## 支持特性 | 特性列表 | 是否支持 | | ---------- | -------- | @@ -93,43 +87,30 @@ 相关代码示例。 ``` -custom_op.name = "NpuOptimizer" -custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") +config_proto = tf.ConfigProto(allow_soft_placement=True) + custom_op = config_proto.graph_options.rewrite_options.custom_optimizers.add() + custom_op.name = 'NpuOptimizer' + custom_op.parameter_map["use_off_line"].b = True + custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") + config_proto.graph_options.rewrite_options.remapping = RewriterConfig.OFF + session_config = npu_config_proto(config_proto=config_proto) ```

训练环境准备

-1. 硬件环境准备请参见各硬件产品文档"[驱动和固件安装升级指南]( https://support.huawei.com/enterprise/zh/category/ai-computing-platform-pid-1557196528909)"。需要在硬件设备上安装与CANN版本配套的固件与驱动。 -2. 宿主机上需要安装Docker并登录[Ascend Hub中心](https://ascendhub.huawei.com/#/detail?name=ascend-tensorflow-arm)获取镜像。 - - 当前模型支持的镜像列表如[表1](#zh-cn_topic_0000001074498056_table1519011227314)所示。 - - **表 1** 镜像列表 - - - - - - - - - - - - -

镜像名称

-

镜像版本

-

配套CANN版本

-
-

21.0.2

-

5.0.2

-
+- 硬件环境和运行环境准备请参见《[CANN软件安装指南](https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373?category=installation-update)》 +- 运行以下命令安装依赖。 +``` +pip3 install requirements.txt +``` +说明:依赖配置文件requirements.txt文件位于模型的根目录

快速上手

## 数据集准备 -1. 模型使用 shapenet_part_seg_hdf5_data 数据集,请用户自行下载,具体获取方法参见 ./ShapeNet_ID1138_for_TensorFlow/S0_download_data.sh 。 + +1. 模型使用 shapenet_part_seg_hdf5_data 数据集,请用户自行下载,具体获取方法参见 ./ShapeNet_ID1138_for_TensorFlow/S0_download_data.sh。 2. 获取数据集后,进行数据预处理,并将预处理后的数据放入模型目录下,在训练脚本中指定数据集路径,可正常使用。数据预处理和最终数据集文件结构示例如下: ``` # 数据预处理,详见: @@ -144,8 +125,8 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec ``` ## 模型训练 -- 单击“立即下载”,并选择合适的下载方式下载源码包 -- 开始训练 +- 单击“立即下载”,并选择合适的下载方式下载源码包。 +- 开始训练。 1. 启动训练之前,首先要配置程序运行相关环境变量。 @@ -157,8 +138,9 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec 2. 单卡训练 2.1 设置单卡训练参数(脚本位于./ShapeNet_ID1138_for_TensorFlow/test/train_full_1p.sh),示例如下。 - -``` + + + ``` # 训练epoch train_epochs=1 # 训练batch_size @@ -167,53 +149,54 @@ custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_prec train_steps=15000 # 数据集文件 data_path=./ShapeNet_dataset -``` - 2.2 单卡训练指令(脚本位于./ShapeNet_ID1138_for_TensorFlow/test/train_full_1p.sh),示例如下。 -``` - bash train_full_1p.sh --data_path=./ShapeNet_dataset -``` + ``` + + + + 2.2 单卡训练指令(脚本位于./ShapeNet_ID1138_for_TensorFlow/test/train_full_1p.sh) + + ``` + 于终端中运行export ASCEND_DEVICE_ID=0 (0~7)以指定单卡训练时使用的卡 + bash train_full_1p.sh --data_path=xx + 数据集应有如下结构(数据切分可能不同),配置data_path时需指定为data这一层,例:--data_path=/home/ShapeNet_dataset + ├── ShapeNet_dataset + │   ├── ShapeNet_prepro.hdf5 + │   ├── ShapeNet_training.hdf5 + ```

迁移学习指导

- 数据集准备。 1. 获取数据。 - 请参见“快速上手”中的数据集准备。 - - -- 模型训练。 - - 请参考“快速上手”章节。 + 请参见“快速上手”中的数据集准备 + +- 模型训练 + 请参考“快速上手”章节

高级参考

## 脚本和示例代码 - . - ├── LICENSE - ├── README.md - ├── modelzoo_level.txt - ├── requirements.txt + ├── README.md //说明文档 + ├── requirements.txt //依赖 ├── test - │   ├── env.sh - │   ├── train_full_1p.sh // 执行训练脚本 - │   └── train_performance_1p.sh // 执行训练脚本 - └── S2_network_training.py // 训练入口脚本 + | |—— train_full_1p.sh //单卡训练脚本 + | |—— train_performance_1p.sh //单卡训练脚本 + ├── S2_network_training.py // 训练入口脚本 ## 脚本参数 ``` ---batch_size batch_size ---train_epochs train_epochs ---train_steps train_steps ---learning_rate learning_rate +batch_size 训练batch_size +learning_rate 初始学习率 +train_epochs 总训练epoch数 +train_steps 总训练steps数 ``` ## 训练过程 -1. 通过“模型训练”中的训练指令启动单卡训练。 -2. 将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 -3. 模型存储路径为“curpath/output/$ASCEND_DEVICE_ID”,包括训练的log以及checkpoints文件。 -4. 以单卡训练为例,loss信息在文件curpath/output/{ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log中。 +通过“模型训练”中的训练指令启动单卡训练。 +将训练脚本(train_full_1p.sh)中的data_path设置为训练数据集的路径。具体的流程参见“模型训练”的示例。 \ No newline at end of file