README.md 24.7 KB
Newer Older
G
Guanghua Yu 已提交
1
简体中文 | [English](README_en.md)
G
Guanghua Yu 已提交
2

G
Guanghua Yu 已提交
3
# PP-PicoDet
G
Guanghua Yu 已提交
4

G
Guanghua Yu 已提交
5
![](../../docs/images/picedet_demo.jpeg)
G
Guanghua Yu 已提交
6

G
Guanghua Yu 已提交
7
## 最新动态
G
Guanghua Yu 已提交
8

G
Guanghua Yu 已提交
9 10
- 发布PicoDet-NPU模型,支持模型全量化部署。**(2022.08.10)**

G
Guanghua Yu 已提交
11
- 发布全新系列PP-PicoDet模型:**(2022.03.20)**
G
Guanghua Yu 已提交
12 13 14
  - (1)引入TAL及ETA Head,优化PAN等结构,精度提升2个点以上;
  - (2)优化CPU端预测速度,同时训练速度提升一倍;
  - (3)导出模型将后处理包含在网络中,预测直接输出box结果,无需二次开发,迁移成本更低,端到端预测速度提升10%-20%。
G
Guanghua Yu 已提交
15

G
Guanghua Yu 已提交
16
## 历史版本模型
G
Guanghua Yu 已提交
17

G
Guanghua Yu 已提交
18
- 详情请参考:[PicoDet 2021.10版本](./legacy_model/)
G
Guanghua Yu 已提交
19

G
Guanghua Yu 已提交
20
## 简介
G
Guanghua Yu 已提交
21

G
Guanghua Yu 已提交
22
PaddleDetection中提出了全新的轻量级系列模型`PP-PicoDet`,在移动端具有卓越的性能,成为全新SOTA轻量级模型。详细的技术细节可以参考我们的[arXiv技术报告](https://arxiv.org/abs/2111.00902)
G
Guanghua Yu 已提交
23

G
Guanghua Yu 已提交
24 25 26 27 28 29
PP-PicoDet模型有如下特点:

- 🌟 更高的mAP: 第一个在1M参数量之内`mAP(0.5:0.95)`超越**30+**(输入416像素时)。
- 🚀 更快的预测速度: 网络预测在ARM CPU下可达150FPS。
- 😊 部署友好: 支持PaddleLite/MNN/NCNN/OpenVINO等预测库,支持转出ONNX,提供了C++/Python/Android的demo。
- 😍 先进的算法: 我们在现有SOTA算法中进行了创新, 包括:ESNet, CSP-PAN, SimOTA等等。
30

G
Guanghua Yu 已提交
31 32 33 34 35

<div align="center">
  <img src="../../docs/images/picodet_map.png" width='600'/>
</div>

G
Guanghua Yu 已提交
36
## 基线
G
Guanghua Yu 已提交
37

G
Guanghua Yu 已提交
38
| 模型     | 输入尺寸 | mAP<sup>val<br>0.5:0.95 | mAP<sup>val<br>0.5 | 参数量<br><sup>(M) | FLOPS<br><sup>(G) | 预测时延<sup><small>[CPU](#latency)</small><sup><br><sup>(ms) | 预测时延<sup><small>[Lite](#latency)</small><sup><br><sup>(ms) |  权重下载  | 配置文件 | 导出模型  |
39 40 41 42 43 44 45 46 47 48
| :-------- | :--------: | :---------------------: | :----------------: | :----------------: | :---------------: | :-----------------------------: | :-----------------------------: | :----------------------------------------: | :--------------------------------------- | :--------------------------------------- |
| PicoDet-XS |  320*320   |          23.5           |        36.1       |        0.70        |       0.67        |              3.9ms              |            7.81ms             | [model](https://paddledet.bj.bcebos.com/models/picodet_xs_320_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_xs_320_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_xs_320_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_xs_320_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_xs_320_coco_lcnet_non_postprocess.tar) |
| PicoDet-XS |  416*416   |          26.2           |        39.3        |        0.70        |       1.13        |              6.1ms             |            12.38ms             | [model](https://paddledet.bj.bcebos.com/models/picodet_xs_416_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_xs_416_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_xs_416_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_xs_416_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_xs_416_coco_lcnet_non_postprocess.tar) |
| PicoDet-S |  320*320   |          29.1           |        43.4        |        1.18       |       0.97       |             4.8ms              |            9.56ms             | [model](https://paddledet.bj.bcebos.com/models/picodet_s_320_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_s_320_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_s_320_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_320_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_320_coco_lcnet_non_postprocess.tar) |
| PicoDet-S |  416*416   |          32.5           |        47.6        |        1.18        |       1.65       |              6.6ms              |            15.20ms             | [model](https://paddledet.bj.bcebos.com/models/picodet_s_416_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_s_416_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_s_416_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet_non_postprocess.tar) |
| PicoDet-M |  320*320   |          34.4           |        50.0        |        3.46        |       2.57       |             8.2ms              |            17.68ms             | [model](https://paddledet.bj.bcebos.com/models/picodet_m_320_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_m_320_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_m_320_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_m_320_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_m_320_coco_lcnet_non_postprocess.tar) |
| PicoDet-M |  416*416   |          37.5           |        53.4       |        3.46        |       4.34        |              12.7ms              |            28.39ms            | [model](https://paddledet.bj.bcebos.com/models/picodet_m_416_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_m_416_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_m_416_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_m_416_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_m_416_coco_lcnet_non_postprocess.tar) |
| PicoDet-L |  320*320   |          36.1           |        52.0        |        5.80       |       4.20        |              11.5ms             |            25.21ms           | [model](https://paddledet.bj.bcebos.com/models/picodet_l_320_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_l_320_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_l_320_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_l_320_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_l_320_coco_lcnet_non_postprocess.tar) |
| PicoDet-L |  416*416   |          39.4           |        55.7        |        5.80        |       7.10       |              20.7ms              |            42.23ms            | [model](https://paddledet.bj.bcebos.com/models/picodet_l_416_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_l_416_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_l_416_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_l_416_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_l_416_coco_lcnet_non_postprocess.tar) |
| PicoDet-L |  640*640   |          42.6           |        59.2        |        5.80        |       16.81        |              62.5ms              |            108.1ms          | [model](https://paddledet.bj.bcebos.com/models/picodet_l_640_coco_lcnet.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_l_640_coco_lcnet.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_l_640_coco_lcnet.yml) | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_l_640_coco_lcnet.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_l_640_coco_lcnet_non_postprocess.tar) |
G
Guanghua Yu 已提交
49

G
Guanghua Yu 已提交
50 51 52 53 54 55
- 特色模型

| 模型     | 输入尺寸 | mAP<sup>val<br>0.5:0.95 | mAP<sup>val<br>0.5 | 参数量<br><sup>(M) | FLOPS<br><sup>(G) | 预测时延<sup><small>[CPU](#latency)</small><sup><br><sup>(ms) | 预测时延<sup><small>[Lite](#latency)</small><sup><br><sup>(ms) |  权重下载  | 配置文件 |
| :-------- | :--------: | :---------------------: | :----------------: | :----------------: | :---------------: | :-----------------------------: | :-----------------------------: | :----------------------------------------: | :--------------------------------------- |
| PicoDet-S-NPU |  416*416   |          30.1           |        44.2       |        -        |       -        |              -             |            -             | [model](https://paddledet.bj.bcebos.com/models/picodet_s_416_coco_npu.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_s_416_coco_npu.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_s_416_coco_npu.yml) |

56

G
Guanghua Yu 已提交
57
<details open>
G
Guanghua Yu 已提交
58
<summary><b>注意事项:</b></summary>
G
Guanghua Yu 已提交
59

G
Guanghua Yu 已提交
60
- <a name="latency">时延测试:</a> 我们所有的模型都在`英特尔酷睿i7 10750H`的CPU 和`骁龙865(4xA77+4xA55)`的ARM CPU上测试(4线程,FP16预测)。上面表格中标有`CPU`的是使用OpenVINO测试,标有`Lite`的是使用[Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite)进行测试。
G
Guanghua Yu 已提交
61 62
- PicoDet在COCO train2017上训练,并且在COCO val2017上进行验证。使用4卡GPU训练,并且上表所有的预训练模型都是通过发布的默认配置训练得到。
- Benchmark测试:测试速度benchmark性能时,导出模型后处理不包含在网络中,需要设置`-o export.benchmark=True` 或手动修改[runtime.yml](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/configs/runtime.yml#L12)
G
Guanghua Yu 已提交
63 64

</details>
65

G
Guanghua Yu 已提交
66
#### 其他模型的基线
G
Guanghua Yu 已提交
67

G
Guanghua Yu 已提交
68
| 模型     | 输入尺寸 | mAP<sup>val<br>0.5:0.95 | mAP<sup>val<br>0.5 | 参数量<br><sup>(M) | FLOPS<br><sup>(G) | 预测时延<sup><small>[NCNN](#latency)</small><sup><br><sup>(ms) |
G
Guanghua Yu 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81
| :-------- | :--------: | :---------------------: | :----------------: | :----------------: | :---------------: | :-----------------------------: |
| YOLOv3-Tiny |  416*416   |          16.6           |        33.1      |        8.86        |       5.62        |             25.42               |
| YOLOv4-Tiny |  416*416   |          21.7           |        40.2        |        6.06           |       6.96           |             23.69               |
| PP-YOLO-Tiny |  320*320       |          20.6         |        -              |   1.08             |    0.58             |    6.75                           |  
| PP-YOLO-Tiny |  416*416   |          22.7          |    -               |    1.08               |    1.02             |    10.48                          |  
| Nanodet-M |  320*320      |          20.6            |    -               |    0.95               |    0.72             |    8.71                           |  
| Nanodet-M |  416*416   |          23.5             |    -               |    0.95               |    1.2              |  13.35                          |
| Nanodet-M 1.5x |  416*416   |          26.8        |    -                  | 2.08               |    2.42             |    15.83                          |
| YOLOX-Nano     |  416*416   |          25.8          |    -               |    0.91               |    1.08             |    19.23                          |
| YOLOX-Tiny     |  416*416   |          32.8          |    -               |    5.06               |    6.45             |    32.77                          |
| YOLOv5n |  640*640       |          28.4             |    46.0            |    1.9                |    4.5              |    40.35                          |
| YOLOv5s |  640*640       |          37.2             |    56.0            |    7.2                |    16.5             |    78.05                          |

G
Guanghua Yu 已提交
82
- ARM测试的benchmark脚本来自: [MobileDetBenchmark](https://github.com/JiweiMaster/MobileDetBenchmark)
G
Guanghua Yu 已提交
83

G
Guanghua Yu 已提交
84
## 快速开始
G
Guanghua Yu 已提交
85 86

<details open>
G
Guanghua Yu 已提交
87
<summary>依赖包:</summary>
G
Guanghua Yu 已提交
88

G
Guanghua Yu 已提交
89
- PaddlePaddle == 2.2.2
G
Guanghua Yu 已提交
90 91 92 93

</details>

<details>
G
Guanghua Yu 已提交
94
<summary>安装</summary>
G
Guanghua Yu 已提交
95

G
Guanghua Yu 已提交
96 97
- [安装指导文档](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/INSTALL.md)
- [准备数据文档](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/PrepareDataSet_en.md)
G
Guanghua Yu 已提交
98 99 100 101

</details>

<details>
G
Guanghua Yu 已提交
102
<summary>训练&评估</summary>
G
Guanghua Yu 已提交
103

G
Guanghua Yu 已提交
104
- 单卡GPU上训练:
G
Guanghua Yu 已提交
105 106 107 108

```shell
# training on single-GPU
export CUDA_VISIBLE_DEVICES=0
G
Guanghua Yu 已提交
109
python tools/train.py -c configs/picodet/picodet_s_320_coco_lcnet.yml --eval
G
Guanghua Yu 已提交
110 111
```

G
Guanghua Yu 已提交
112 113 114
**注意:**如果训练时显存out memory,将TrainReader中batch_size调小,同时LearningRate中base_lr等比例减小。同时我们发布的config均由4卡训练得到,如果改变GPU卡数为1,那么base_lr需要减小4倍。

- 多卡GPU上训练:
G
Guanghua Yu 已提交
115 116 117


```shell
G
Guanghua Yu 已提交
118
# training on multi-GPU
G
Guanghua Yu 已提交
119 120
export CUDA_VISIBLE_DEVICES=0,1,2,3
python -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py -c configs/picodet/picodet_s_320_coco_lcnet.yml --eval
G
Guanghua Yu 已提交
121 122
```

G
Guanghua Yu 已提交
123 124
**注意:**PicoDet所有模型均由4卡GPU训练得到,如果改变训练GPU卡数,需要按线性比例缩放学习率base_lr。

G
Guanghua Yu 已提交
125
- 评估:
G
Guanghua Yu 已提交
126 127

```shell
G
Guanghua Yu 已提交
128 129
python tools/eval.py -c configs/picodet/picodet_s_320_coco_lcnet.yml \
              -o weights=https://paddledet.bj.bcebos.com/models/picodet_s_320_coco_lcnet.pdparams
G
Guanghua Yu 已提交
130 131
```

G
Guanghua Yu 已提交
132
- 测试:
G
Guanghua Yu 已提交
133 134

```shell
G
Guanghua Yu 已提交
135 136
python tools/infer.py -c configs/picodet/picodet_s_320_coco_lcnet.yml \
              -o weights=https://paddledet.bj.bcebos.com/models/picodet_s_320_coco_lcnet.pdparams
G
Guanghua Yu 已提交
137 138
```

G
Guanghua Yu 已提交
139
详情请参考[快速开始文档](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED.md).
G
Guanghua Yu 已提交
140 141 142 143

</details>


G
Guanghua Yu 已提交
144
## 部署
G
Guanghua Yu 已提交
145

G
Guanghua Yu 已提交
146
### 导出及转换模型
G
Guanghua Yu 已提交
147

G
Guanghua Yu 已提交
148 149
<details open>
<summary>1. 导出模型</summary>
G
Guanghua Yu 已提交
150 151 152

```shell
cd PaddleDetection
G
Guanghua Yu 已提交
153 154
python tools/export_model.py -c configs/picodet/picodet_s_320_coco_lcnet.yml \
              -o weights=https://paddledet.bj.bcebos.com/models/picodet_s_320_coco_lcnet.pdparams \
P
pk_hk 已提交
155
              --output_dir=output_inference
G
Guanghua Yu 已提交
156 157
```

G
Guanghua Yu 已提交
158
- 如无需导出后处理,请指定:`-o export.benchmark=True`(如果-o已出现过,此处删掉-o)或者手动修改[runtime.yml](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/configs/runtime.yml) 中相应字段。
G
Guanghua Yu 已提交
159
- 如无需导出NMS,请指定:`-o export.nms=False`或者手动修改[runtime.yml](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/configs/runtime.yml) 中相应字段。 许多导出至ONNX场景只支持单输入及固定shape输出,所以如果导出至ONNX,推荐不导出NMS。
G
Guanghua Yu 已提交
160

G
Guanghua Yu 已提交
161 162 163
</details>

<details>
G
Guanghua Yu 已提交
164
<summary>2. 转换模型至Paddle Lite (点击展开)</summary>
G
Guanghua Yu 已提交
165

G
Guanghua Yu 已提交
166
- 安装Paddlelite>=2.10:
G
Guanghua Yu 已提交
167 168 169 170 171

```shell
pip install paddlelite
```

G
Guanghua Yu 已提交
172
- 转换模型至Paddle Lite格式:
G
Guanghua Yu 已提交
173 174 175

```shell
# FP32
P
pk_hk 已提交
176
paddle_lite_opt --model_dir=output_inference/picodet_s_320_coco_lcnet --valid_targets=arm --optimize_out=picodet_s_320_coco_fp32
G
Guanghua Yu 已提交
177
# FP16
P
pk_hk 已提交
178
paddle_lite_opt --model_dir=output_inference/picodet_s_320_coco_lcnet --valid_targets=arm --optimize_out=picodet_s_320_coco_fp16 --enable_fp16=true
G
Guanghua Yu 已提交
179 180 181 182 183
```

</details>

<details>
G
Guanghua Yu 已提交
184
<summary>3. 转换模型至ONNX (点击展开)</summary>
G
Guanghua Yu 已提交
185

G
Guanghua Yu 已提交
186
- 安装[Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX) >= 0.7 并且 ONNX > 1.10.1, 细节请参考[导出ONNX模型教程](../../deploy/EXPORT_ONNX_MODEL.md)
G
Guanghua Yu 已提交
187 188 189

```shell
pip install onnx
G
Guanghua Yu 已提交
190
pip install paddle2onnx==0.9.2
G
Guanghua Yu 已提交
191 192
```

G
Guanghua Yu 已提交
193
- 转换模型:
G
Guanghua Yu 已提交
194 195

```shell
G
Guanghua Yu 已提交
196
paddle2onnx --model_dir output_inference/picodet_s_320_coco_lcnet/ \
G
Guanghua Yu 已提交
197 198 199 200 201 202
            --model_filename model.pdmodel  \
            --params_filename model.pdiparams \
            --opset_version 11 \
            --save_file picodet_s_320_coco.onnx
```

G
Guanghua Yu 已提交
203
- 简化ONNX模型: 使用`onnx-simplifier`库来简化ONNX模型。
G
Guanghua Yu 已提交
204

D
daquexian 已提交
205
  - 安装 onnxsim >= 0.4.1:
G
Guanghua Yu 已提交
206
  ```shell
D
daquexian 已提交
207
  pip install onnxsim
G
Guanghua Yu 已提交
208
  ```
G
Guanghua Yu 已提交
209
  - 简化ONNX模型:
G
Guanghua Yu 已提交
210
  ```shell
D
daquexian 已提交
211
  onnxsim picodet_s_320_coco.onnx picodet_s_processed.onnx
G
Guanghua Yu 已提交
212 213
  ```

G
Guanghua Yu 已提交
214 215
</details>

G
Guanghua Yu 已提交
216
- 部署用的模型
G
Guanghua Yu 已提交
217

P
pk_hk 已提交
218
| 模型     | 输入尺寸 | ONNX  | Paddle Lite(fp32) | Paddle Lite(fp16) |
G
Guanghua Yu 已提交
219
| :-------- | :--------: | :---------------------: | :----------------: | :----------------: |
G
Guanghua Yu 已提交
220 221 222 223 224 225 226 227 228
| PicoDet-XS |  320*320   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_xs_320_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_xs_320_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_xs_320_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_xs_320_coco_lcnet_fp16.tar) |
| PicoDet-XS |  416*416   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_xs_416_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_xs_416_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_xs_416_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_xs_416_coco_lcnet_fp16.tar) |
| PicoDet-S |  320*320   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_s_320_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_s_320_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_320_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_320_coco_lcnet_fp16.tar) |
| PicoDet-S |  416*416   |  [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_s_416_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_s_416_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet_fp16.tar) |
| PicoDet-M |  320*320   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_m_320_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_m_320_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_m_320_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_m_320_coco_lcnet_fp16.tar) |
| PicoDet-M |  416*416   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_m_416_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_m_416_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_m_416_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_m_416_coco_lcnet_fp16.tar) |
| PicoDet-L |  320*320   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_l_320_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_l_320_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_l_320_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_l_320_coco_lcnet_fp16.tar) |
| PicoDet-L |  416*416   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_l_416_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_l_416_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_l_416_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_l_416_coco_lcnet_fp16.tar) |
| PicoDet-L |  640*640   | [( w/ 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_l_640_lcnet_postprocessed.onnx) &#124; [( w/o 后处理)](https://paddledet.bj.bcebos.com/deploy/third_engine/picodet_l_640_coco_lcnet.onnx) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_l_640_coco_lcnet.tar) | [model](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_l_640_coco_lcnet_fp16.tar) |
G
Guanghua Yu 已提交
229

G
Guanghua Yu 已提交
230
### 部署
G
Guanghua Yu 已提交
231

232 233 234 235 236 237
| 预测库     | Python | C++  | 带后处理预测 |
| :-------- | :--------: | :---------------------: | :----------------: |
| OpenVINO | [Python](../../deploy/third_engine/demo_openvino/python) | [C++](../../deploy/third_engine/demo_openvino)(带后处理开发中) |  ✔︎ |
| Paddle Lite |  -    |  [C++](../../deploy/lite) | ✔︎ |
| Android Demo |  -  |  [Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite-Demo/tree/develop/object_detection/android/app/cxx/picodet_detection_demo) | ✔︎ |
| PaddleInference | [Python](../../deploy/python) |  [C++](../../deploy/cpp) | ✔︎ |
238 239 240
| ONNXRuntime  | [Python](../../deploy/third_engine/demo_onnxruntime) | Coming soon | ✔︎ |
| NCNN |  Coming soon  | [C++](../../deploy/third_engine/demo_ncnn) | ✘ |
| MNN  | Coming soon | [C++](../../deploy/third_engine/demo_mnn) |  ✘ |
241

G
Guanghua Yu 已提交
242 243


G
Guanghua Yu 已提交
244
Android demo可视化:
G
Guanghua Yu 已提交
245 246 247 248
<div align="center">
  <img src="../../docs/images/picodet_android_demo1.jpg" height="500px" ><img src="../../docs/images/picodet_android_demo2.jpg" height="500px" ><img src="../../docs/images/picodet_android_demo3.jpg" height="500px" ><img src="../../docs/images/picodet_android_demo4.jpg" height="500px" >
</div>

G
Guanghua Yu 已提交
249

G
Guanghua Yu 已提交
250
## 量化
G
Guanghua Yu 已提交
251

G
Guanghua Yu 已提交
252
<details open>
G
Guanghua Yu 已提交
253
<summary>依赖包:</summary>
G
Guanghua Yu 已提交
254

G
Guanghua Yu 已提交
255
- PaddlePaddle >= 2.2.2
G
Guanghua Yu 已提交
256
- PaddleSlim >= 2.2.2
G
Guanghua Yu 已提交
257

G
Guanghua Yu 已提交
258
**安装:**
G
Guanghua Yu 已提交
259 260

```shell
G
Guanghua Yu 已提交
261
pip install paddleslim==2.2.2
G
Guanghua Yu 已提交
262 263 264 265
```

</details>

G
Guanghua Yu 已提交
266 267
<details open>
<summary>量化训练</summary>
G
Guanghua Yu 已提交
268

G
Guanghua Yu 已提交
269
开始量化训练:
G
Guanghua Yu 已提交
270 271

```shell
G
Guanghua Yu 已提交
272 273
python tools/train.py -c configs/picodet/picodet_s_416_coco_lcnet.yml \
          --slim_config configs/slim/quant/picodet_s_416_lcnet_quant.yml --eval
G
Guanghua Yu 已提交
274 275
```

G
Guanghua Yu 已提交
276
- 更多细节请参考[slim文档](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/slim)
G
Guanghua Yu 已提交
277

G
Guanghua Yu 已提交
278 279
</details>

G
Guanghua Yu 已提交
280
- 量化训练Model ZOO:
G
Guanghua Yu 已提交
281

G
Guanghua Yu 已提交
282 283 284
| 量化模型     | 输入尺寸 | mAP<sup>val<br>0.5:0.95  | Configs | Weight | Inference Model | Paddle Lite(INT8) |
| :-------- | :--------: | :--------------------: | :-------: | :----------------: | :----------------: | :----------------: |
| PicoDet-S |  416*416   |  31.5  | [config](./picodet_s_416_coco_lcnet.yml) &#124; [slim config](../slim/quant/picodet_s_416_lcnet_quant.yml) | [model](https://paddledet.bj.bcebos.com/models/picodet_s_416_coco_lcnet_quant.pdparams)  | [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet_quant.tar) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet_quant_non_postprocess.tar) |  [w/ 后处理](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet_quant.nb) &#124; [w/o 后处理](https://paddledet.bj.bcebos.com/deploy/paddlelite/picodet_s_416_coco_lcnet_quant_non_postprocess.nb) |
G
Guanghua Yu 已提交
285

G
Guanghua Yu 已提交
286
## 非结构化剪枝
M
minghaoBD 已提交
287 288

<details open>
G
Guanghua Yu 已提交
289
<summary>教程:</summary>
M
minghaoBD 已提交
290

G
Guanghua Yu 已提交
291
训练及部署细节请参考[非结构化剪枝文档](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/legacy_model/pruner/README.md)
M
minghaoBD 已提交
292 293 294

</details>

G
Guanghua Yu 已提交
295
## 应用
G
Guanghua Yu 已提交
296

G
Guanghua Yu 已提交
297
- **行人检测:** `PicoDet-S-Pedestrian`行人检测模型请参考[PP-TinyPose](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/keypoint/tiny_pose#%E8%A1%8C%E4%BA%BA%E6%A3%80%E6%B5%8B%E6%A8%A1%E5%9E%8B)
G
Guanghua Yu 已提交
298

299
- **主体检测:** `PicoDet-L-Mainbody`主体检测模型请参考[主体检测文档](./legacy_model/application/mainbody_detection/README.md)
littletomatodonkey's avatar
littletomatodonkey 已提交
300

G
Guanghua Yu 已提交
301 302 303
## FAQ

<details>
G
Guanghua Yu 已提交
304
<summary>显存爆炸(Out of memory error)</summary>
G
Guanghua Yu 已提交
305

G
Guanghua Yu 已提交
306
请减小配置文件中`TrainReader``batch_size`
G
Guanghua Yu 已提交
307 308 309

</details>

G
Guanghua Yu 已提交
310
<details>
G
Guanghua Yu 已提交
311
<summary>如何迁移学习</summary>
G
Guanghua Yu 已提交
312

G
Guanghua Yu 已提交
313
请重新设置配置文件中的`pretrain_weights`字段,比如利用COCO上训好的模型在自己的数据上继续训练:
G
Guanghua Yu 已提交
314
```yaml
G
Guanghua Yu 已提交
315
pretrain_weights: https://paddledet.bj.bcebos.com/models/picodet_l_640_coco_lcnet.pdparams
G
Guanghua Yu 已提交
316 317 318 319 320
```

</details>

<details>
G
Guanghua Yu 已提交
321
<summary>`transpose`算子在某些硬件上耗时验证</summary>
G
Guanghua Yu 已提交
322

G
Guanghua Yu 已提交
323
请使用`PicoDet-LCNet`模型,`transpose`较少。
G
Guanghua Yu 已提交
324 325 326 327

</details>


W
Wenyu 已提交
328
<details>
G
Guanghua Yu 已提交
329
<summary>如何计算模型参数量。</summary>
W
Wenyu 已提交
330

G
Guanghua Yu 已提交
331
可以将以下代码插入:[trainer.py](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/ppdet/engine/trainer.py#L141) 来计算参数量。
W
Wenyu 已提交
332 333 334 335 336 337 338 339 340 341 342

```python
params = sum([
    p.numel() for n, p in self.model. named_parameters()
    if all([x not in n for x in ['_mean', '_variance']])
]) # exclude BatchNorm running status
print('params: ', params)
```

</details>

G
Guanghua Yu 已提交
343 344
## 引用PP-PicoDet
如果需要在你的研究中使用PP-PicoDet,请通过一下方式引用我们的技术报告:
G
Guanghua Yu 已提交
345
```
G
Guanghua Yu 已提交
346 347 348 349 350 351 352 353
@misc{yu2021pppicodet,
      title={PP-PicoDet: A Better Real-Time Object Detector on Mobile Devices},
      author={Guanghua Yu and Qinyao Chang and Wenyu Lv and Chang Xu and Cheng Cui and Wei Ji and Qingqing Dang and Kaipeng Deng and Guanzhong Wang and Yuning Du and Baohua Lai and Qiwen Liu and Xiaoguang Hu and Dianhai Yu and Yanjun Ma},
      year={2021},
      eprint={2111.00902},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}
G
Guanghua Yu 已提交
354 355

```