README.md 8.2 KB
Newer Older
G
Guanghua Yu 已提交
1 2
# PicoDet

G
Guanghua Yu 已提交
3
![](../../docs/images/picedet_demo.jpeg)
G
Guanghua Yu 已提交
4 5
## Introduction

G
Guanghua Yu 已提交
6
We developed a series of lightweight models, which named `PicoDet`. Because of its excellent performance, it is very suitable for deployment on mobile or CPU.
G
Guanghua Yu 已提交
7

G
Guanghua Yu 已提交
8
- 🌟 Higher mAP: the **first** object detectors that surpass mAP(0.5:0.95) **30+** within 1M parameters when the input size is 416.
G
Guanghua Yu 已提交
9
- 🚀 Faster latency: 129FPS on mobile ARM CPU.
10 11 12
- 😊 Deploy friendly: support PaddleLite/MNN/NCNN/OpenVINO and provide C++/Python/Android implementation.
- 😍 Advanced algorithm: use the most advanced algorithms and innovate, such as ESNet, CSP-PAN, SimOTA with VFL, etc.

G
Guanghua Yu 已提交
13 14 15 16
### Comming soon
- [ ] More series of model, such as smaller or larger model.
- [ ] Pretrained models for more scenarios.
- [ ] More features in need.
G
Guanghua Yu 已提交
17 18

## Requirements
19
- PaddlePaddle >= 2.1.2
G
Guanghua Yu 已提交
20 21
- PaddleSlim >= 2.1.1

G
Guanghua Yu 已提交
22
## Benchmark
G
Guanghua Yu 已提交
23

G
Guanghua Yu 已提交
24
| Model                  | Input size | mAP<sup>val<br>0.5:0.95 | mAP<sup>val<br>0.5 | Params<br><sup>(M) | FLOPS<br><sup>(G)  | Latency<br><sup>(ms) |                           download                          | config |
G
Guanghua Yu 已提交
25
| :------------------------ | :-------:  | :------: | :---: | :---: | :---: | :------------:  | :-------------------------------------------------: | :-----: |
G
Guanghua Yu 已提交
26 27 28 29 30 31 32
| PicoDet-S    | 320*320    |   27.1     | 41.4 | 0.99 | 0.73 | 7.78 | [model](https://paddledet.bj.bcebos.com/models/picodet_s_320_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_s_320_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_s_320_coco.yml) |
| PicoDet-S    | 416*416    |   30.6     | 45.5 | 0.99 | 1.24 | 11.84 | [model](https://paddledet.bj.bcebos.com/models/picodet_s_416_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_s_416_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_s_416_coco.yml) |
| PicoDet-M    | 320*320   |  30.9     | 45.7 |  2.15 | 1.48 | 10.56 | [model](https://paddledet.bj.bcebos.com/models/picodet_m_320_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_m_320_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_m_320_coco.yml) |
| PicoDet-M    | 416*416    |   34.3     | 49.8 |  2.15 | 2.50 | 15.87 | [model](https://paddledet.bj.bcebos.com/models/picodet_m_416_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_m_416_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_m_416_coco.yml) |
| PicoDet-L    | 320*320   |  32.6     | 47.9 |  3.24 | 2.18 | 12.82 | [model](https://paddledet.bj.bcebos.com/models/picodet_l_320_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_l_320_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_l_320_coco.yml) |
| PicoDet-L    | 416*416   |  35.9    |   51.7  |  3.24 | 3.69 | 19.42 | [model](https://paddledet.bj.bcebos.com/models/picodet_l_416_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_l_416_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_l_416_coco.yml) |
| PicoDet-L    | 640*640   |  40.3    |  57.1   |  3.24 | 8.74 | 41.52 | [model](https://paddledet.bj.bcebos.com/models/picodet_l_640_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_l_640_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/picodet_l_640_coco.yml) |
G
Guanghua Yu 已提交
33 34


G
Guanghua Yu 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47
<details>
<summary>Table Notes (click to expand)</summary>

- PicoDet inference speed is tested on SD 888(1*X1+3*A78+4*A55) with 4 threads by arm8 and with FP16.
- PicoDet is trained on COCO train2017 dataset and evaluated on COCO val2017.
- PicoDet used 4 or 8 GPUs for training and all checkpoints are trained to 300 epochs with default settings and hyperparameters.

</details>

## More config

| Model                  | Input size | mAP<sup>val<br>0.5:0.95 | mAP<sup>val<br>0.5 | Params<br><sup>(M) | FLOPS<br><sup>(G)  | Latency<br><sup>(ms) |                           download                          | config |
| :------------------------ | :-------:  | :------: | :---: | :---: | :---: | :------------:  | :-------------------------------------------------: | :-----: |
G
Guanghua Yu 已提交
48 49 50
| PicoDet-Shufflenetv2 1x    | 416*416    |   30.0     | 44.6 | 1.17 | 1.53 | 14.76 | [model](https://paddledet.bj.bcebos.com/models/picodet_shufflenetv2_1x_416_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_shufflenetv2_1x_416_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/more_config/picodet_shufflenetv2_1x_416_coco.yml) |
| PicoDet-MobileNetv3-large 1x    | 416*416    |   35.6    | 52.0 | 3.55 | 2.80 | 18.87 | [model](https://paddledet.bj.bcebos.com/models/picodet_mobilenetv3_large_1x_416_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_mobilenetv3_large_1x_416_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/more_config/picodet_mobilenetv3_large_1x_416_coco.yml) |
| PicoDet-LCNet 1.5x    | 416*416    |   36.3    | 52.2 | 3.10 | 3.85 | 19.75 | [model](https://paddledet.bj.bcebos.com/models/picodet_lcnet_1_5x_416_coco.pdparams) &#124; [log](https://paddledet.bj.bcebos.com/logs/train_picodet_lcnet_1_5x_416_coco.log) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/picodet/more_config/picodet_lcnet_1_5x_416_coco.yml) |
G
Guanghua Yu 已提交
51 52 53 54 55 56

## Deployment

### Export and Convert model

<details>
G
Guanghua Yu 已提交
57
<summary>1. Export model (click to expand)</summary>
G
Guanghua Yu 已提交
58 59 60 61 62 63 64 65 66 67

```shell
cd PaddleDetection
python tools/export_model.py -c configs/picodet/picodet_s_320_coco.yml \
              -o weights=https://paddledet.bj.bcebos.com/models/picodet_s_320_coco.pdparams --output_dir=inference_model
```

</details>

<details>
G
Guanghua Yu 已提交
68
<summary>2. Convert to PaddleLite (click to expand)</summary>
G
Guanghua Yu 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

- Install Paddlelite>=2.10.rc:

```shell
pip install paddlelite
```

- Convert model:

```shell
# FP32
paddle_lite_opt --model_dir=inference_model/picodet_s_320_coco --valid_targets=arm --optimize_out=picodet_s_320_coco_fp32
# FP16
paddle_lite_opt --model_dir=inference_model/picodet_s_320_coco --valid_targets=arm --optimize_out=picodet_s_320_coco_fp16 --enable_fp16=true
```

</details>

<details>
G
Guanghua Yu 已提交
88
<summary>3. Convert to ONNX (click to expand)</summary>
G
Guanghua Yu 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123

- Install [Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX) >= 0.7 and ONNX > 1.10.1, for details, please refer to [Tutorials of Export ONNX Model](../../deploy/EXPORT_ONNX_MODEL.md)

```shell
pip install onnx
pip install paddle2onnx
```

- Convert model:

```shell
paddle2onnx --model_dir output_inference/picodet_s_320_coco/ \
            --model_filename model.pdmodel  \
            --params_filename model.pdiparams \
            --opset_version 11 \
            --save_file picodet_s_320_coco.onnx
```

- Simplify ONNX model: use onnx-simplifier to simplify onnx model.

  - Install onnx-simplifier >= 0.3.6:
  ```shell
  pip install onnx-simplifier
  ```
  - simplify onnx model:
  ```shell
  python -m onnxsim picodet_s_320_coco.onnx picodet_s_processed.onnx
  ```

</details>

### Deploy

- PaddleInference demo [Python](../../deploy/python) & [C++](../../deploy/cpp)
- [PaddleLite C++ demo](../../deploy/lite)
G
Guanghua Yu 已提交
124 125 126
- [NCNN C++/Python demo](../../deploy/third_engine/demo_ncnn)
- [MNN C++/Python demo](../../deploy/third_engine/demo_mnn)
- [OpenVINO C++/Python demo](../../deploy/third_engine/demo_openvino)
G
Guanghua Yu 已提交
127 128 129 130 131 132 133
- [Android demo]()

## Slim

### quantization

<details>
G
Guanghua Yu 已提交
134
<summary>Quant aware (click to expand)</summary>
G
Guanghua Yu 已提交
135 136 137 138 139 140 141 142 143 144 145

Configure the quant config and start training:

```shell
python tools/train.py -c configs/picodet/picodet_s_320_coco.yml \
          --slim_config configs/slim/quant/picodet_s_quant.yml --eval
```

</details>

<details>
G
Guanghua Yu 已提交
146
<summary>Post quant (click to expand)</summary>
G
Guanghua Yu 已提交
147 148 149 150

Configure the post quant config and start calibrate model:

```shell
G
Guanghua Yu 已提交
151 152
python tools/post_quant.py -c configs/picodet/picodet_s_320_coco.yml \
          --slim_config configs/slim/post_quant/picodet_s_ptq.yml
G
Guanghua Yu 已提交
153 154 155
```

</details>
G
Guanghua Yu 已提交
156

G
Guanghua Yu 已提交
157 158
## Cite PiocDet
If you use PiocDet in your research, please cite our work by using the following BibTeX entry:
G
Guanghua Yu 已提交
159
```
G
Guanghua Yu 已提交
160
comming soon
G
Guanghua Yu 已提交
161 162

```