---
title: RetinaNet_contrib-PyTorch-模型库-ModelZoo-Atlas Community
description: 生态贡献模型
keywords: RetinaNet,PyTorch,模型库,ModelZoo,Atlas,Community,准备训练环境,准备环境
url: https://www.hiascend.com/software/modelzoo/models/detail/37d3666e19374e6bb7845d05708a8daa?index_id=37d3666e19374e6bb7845d05708a8daa
section: (其他)
---

# RetinaNet_contrib-PyTorch-模型库-ModelZoo-Atlas Community

URL: https://www.hiascend.com/software/modelzoo/models/detail/37d3666e19374e6bb7845d05708a8daa?index_id=37d3666e19374e6bb7845d05708a8daa
描述: 生态贡献模型
关键词: RetinaNet,PyTorch,模型库,ModelZoo,Atlas,Community,准备训练环境,准备环境

ModelZoo主页

主页 [了解详情](https://www.hiascend.com/software/modelzoo)大模型 [了解详情](https://www.hiascend.com/software/modelzoo/big-models)模型库 [了解详情](https://www.hiascend.com/software/modelzoo/models)工具库 [了解详情](https://www.hiascend.com/software/modelzoo/tools)权重库 [了解详情](https://www.hiascend.com/software/modelzoo/datasets)ModelShow [了解详情](https://www.hiascend.com/software/modelzoo/modelshow)DeepSeek专区HOT [了解详情](https://www.hiascend.com/developer/deepseek)文档中心论坛交流

主页 [了解详情](https://www.hiascend.com/software/modelzoo)大模型 [了解详情](https://www.hiascend.com/software/modelzoo/big-models)模型库 [了解详情](https://www.hiascend.com/software/modelzoo/models)工具库 [了解详情](https://www.hiascend.com/software/modelzoo/tools)权重库 [了解详情](https://www.hiascend.com/software/modelzoo/datasets)ModelShow [了解详情](https://www.hiascend.com/software/modelzoo/modelshow)DeepSeek专区HOT [了解详情](https://www.hiascend.com/developer/deepseek)文档中心论坛交流

模型库 [了解详情](https://www.hiascend.com/software/modelzoo/models)

RetinaNet_contrib-PyTorch

## RetinaNet_contrib-PyTorch

视觉检测与跟踪PyTorch训练115次浏览2023/08/14更新

No rating yet

Rate This Document

查看模型源码

RetinaNet_contrib-PyTorch

查看模型源码

...

# 准备训练环境

## 准备环境

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

表 1版本支持表

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

请参考《Pytorch框架训练环境准备 [了解详情](https://www.hiascend.com/document/detail/zh/ModelZoo/pytorchframework/ptes)》。
- 安装依赖。

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

```
pip install -r 1.5_requirements.txt  # PyTorch1.5版本

pip install -r 1.8_requirements.txt  # PyTorch1.8版本
```

说明：只需执行一条对应的PyTorch版本依赖安装命令。
- 安装 detectron2 框架。

```
pip3.7 install -e .
pip3.7 install fvcore --upgrade
```

## 准备数据集

1. 获取数据集。

请用户自行准备coco数据集，并将数据集解压后放置在服务器的任意目录下。

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

```
|-coco
|-- annotations
|   |-- captions_train2017.json
|   |-- captions_val2017.json
|   |-- instances_train2017.json
|   |-- instances_val2017.json
|   |-- person_keypoints_train2017.json
|   |-- person_keypoints_val2017.json
|-- train2017
|-- val2017
|-- test2017
|   |-- 000000000001.jpg
|   |-- 000000000016.jpg
```

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

### 获取预训练模型

请用户自行下载预训练模型R-50.pkl，上传到服务器任意路径下，并修改源码包根目录下''configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml''文件的WEIGHTS参数，指定预训练模型文件的绝对路径，示例如下：

```
WEIGHTS: "/root/txyWorkSpace/Faster_Mask_RCNN_for_PyTorch/R-50.pkl"
```

# 开始训练

## 训练模型

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

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

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

- 单机单卡训练

启动单卡训练。

```
bash ./test/train_full_1p.sh --data_path=/data/xxx/  # 单卡精度

bash ./test/train_performance_1p.sh --data_path=/data/xxx/  # 单卡性能
```
- 单机8卡训练

启动8卡训练。

```
bash ./test/train_full_8p.sh --data_path=/data/xxx/  # 8卡精度

bash ./test/train_performance_8p.sh --data_path=/data/xxx/  # 8卡性能
```
- 单机8卡评测

启动8卡评测。

```
bash ./test/train_eval_8p.sh --data_path=/data/xxx/
```

--data_path参数填写数据集路径，需写到数据集的一级目录。

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

```
公共参数：
--config-file                       //模型配置文件
--device_id 0,1,2,3,4,5,6,7         //指定训练用卡
--num-gpus                          //指定训练卡数
--batch-size                        //训练过程批量大小
AMP 1                               //是否开启混合精度训练，1代表开启，0代表SOLVER.BASE_LR                      //基础学习率
SOLVER.MAX_ITER                     //最高迭代次数
```

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

# 训练结果展示

表 2训练结果展示表

| NAME | Acc@1 | FPS | Max_iter | AMP_Type | Torch_Version |
| --- | --- | --- | --- | --- | ---|
| 1p-NPU | - | 9.644 | 1000 | O1 | 1.8 |
| 8p-NPU | 37.8 | 66.273 | 90000 | O1 | 1.8 |

# 版本说明

## 变更

2023.03.02：更新readme，重新发布。

2021.07.14：首次发布。

## FAQ

无。

# 公网地址说明

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

| 版本 | 更新时间 | 精度 | 处理器 | CANN版本 | 操作 |
| --- | --- | --- | --- | --- | ---|

暂无数据

使用模型资源和服务前，请您仔细阅读并理解透彻《昇腾深度学习模型许可协议 3.0》 [了解详情](https://www.hiascend.com/legal/modelzoo_models_license)
