Skip to content

Commit 673d0d4

Browse files
add int8 mobilenet & faster_rcnn (#504)
* add mobilenet & faster_rcnn Signed-off-by: mengniwa <[email protected]> * fix readme Signed-off-by: mengniwa <[email protected]> * update model link Signed-off-by: mengniwa <[email protected]> Co-authored-by: Chun-Wei Chen <[email protected]>
1 parent 03458a1 commit 673d0d4

File tree

10 files changed

+94
-2
lines changed

10 files changed

+94
-2
lines changed

vision/classification/mobilenet/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ The below model is using multiplier value as 1.0.
1616
|Model |Download |Download (with sample test data)| ONNX version |Opset version|Top-1 accuracy (%)|Top-5 accuracy (%)|
1717
|-------------|:--------------|:--------------|:--------------|:--------------|:--------------|:--------------|
1818
|MobileNet v2-1.0| [13.6 MB](model/mobilenetv2-7.onnx) | [14.1 MB](model/mobilenetv2-7.tar.gz) | 1.2.1 | 7| 70.94 | 89.99 |
19+
|MobileNet v2-1.0-fp32| [13.3 MB](model/mobilenetv2-12.onnx) | [12.9 MB](model/mobilenetv2-12.tar.gz) | 1.9.0 | 12| 69.48 | 89.26 |
20+
|MobileNet v2-1.0-int8| [3.5 MB](model/mobilenetv2-12-int8.onnx) | [3.7 MB](model/mobilenetv2-12-int8.tar.gz) | 1.9.0 | 12| 68.30 | 88.44 |
21+
> Compared with the fp32 MobileNet v2-1.0, int8 MobileNet v2-1.0's Top-1 accuracy decline ratio is 1.70%, Top-5 accuracy decline ratio is 0.92% and performance improvement is 1.05x.
22+
>
23+
> Note the performance depends on the test hardware.
24+
>
25+
> Performance data here is collected with Intel® Xeon® Platinum 8280 Processor, 1s 4c per instance, CentOS Linux 8.3, data batch size is 1.
1926
2027
## Inference
2128
We used MXNet as framework with gluon APIs to perform inference. View the notebook [imagenet_inference](../imagenet_inference.ipynb) to understand how to use above models for doing inference. Make sure to specify the appropriate model name in the notebook.
@@ -48,15 +55,40 @@ We used MXNet as framework with gluon APIs to perform training. View the [traini
4855
## Validation
4956
We used MXNet as framework with gluon APIs to perform validation. Use the notebook [imagenet_validation](../imagenet_validation.ipynb) to verify the accuracy of the model on the validation set. Make sure to specify the appropriate model name in the notebook.
5057

58+
## Quantization
59+
MobileNet v2-1.0-int8 is obtained by quantizing MobileNet v2-1.0-fp32 model. We use [Intel® Neural Compressor](https://github.com/intel/neural-compressor) with onnxruntime backend to perform quantization. View the [instructions](https://github.com/intel/neural-compressor/blob/master/examples/onnxrt/image_recognition/onnx_model_zoo/mobilenet/quantization/ptq/README.md) to understand how to use Intel® Neural Compressor for quantization.
60+
61+
### Environment
62+
onnx: 1.9.0
63+
onnxruntime: 1.8.0
64+
65+
### Prepare model
66+
```shell
67+
wget https://github.com/onnx/models/blob/main/vision/classification/mobilenet/model/mobilenetv2-12.onnx
68+
```
69+
70+
### Model quantize
71+
Make sure to specify the appropriate dataset path in the configuration file.
72+
```bash
73+
bash run_tuning.sh --input_model=path/to/model \ # model path as *.onnx
74+
--config=mobilenetv2.yaml \
75+
--output_model=path/to/save
76+
```
5177

5278
## References
5379
* **MobileNet-v2** Model from the paper [MobileNetV2: Inverted Residuals and Linear Bottlenecks](https://arxiv.org/abs/1801.04381)
5480

5581
* [MXNet](http://mxnet.incubator.apache.org), [Gluon model zoo](https://mxnet.incubator.apache.org/api/python/gluon/model_zoo.html), [GluonCV](https://gluon-cv.mxnet.io)
5682

83+
* [Intel® Neural Compressor](https://github.com/intel/neural-compressor)
84+
5785
## Contributors
5886
* [ankkhedia](https://github.com/ankkhedia) (Amazon AI)
5987
* [abhinavs95](https://github.com/abhinavs95) (Amazon AI)
88+
* [mengniwang95](https://github.com/mengniwang95) (Intel)
89+
* [airMeng](https://github.com/airMeng) (Intel)
90+
* [ftian1](https://github.com/ftian1) (Intel)
91+
* [hshen14](https://github.com/hshen14) (Intel)
6092

6193
## License
6294
Apache 2.0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:cc028fe6cae7bc11a4ff53cfc9b79c920e8be65ce33a904ec3e2a8f66d77f95f
3+
size 3655033
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:f00ea406993d4b2a404a4c5f4258e862f68aedfbcc324510267e556612501211
3+
size 3910933
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:c0c3f76d93fa3fd6580652a45618618a220fced18babf65774ed169de0432ad5
3+
size 13964571
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5f83b422708a708b592a5fd56d84710038511789df3ae510b84123930c37762d
3+
size 13498787

vision/object_detection_segmentation/faster-rcnn/README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ This model is a real-time neural network for object detection that detects 80 di
1010
|Model |Download | Download (with sample test data)|ONNX version|Opset version|Accuracy |
1111
|-------------|:--------------|:--------------|:--------------|:--------------|:--------------|
1212
|Faster R-CNN R-50-FPN |[167.3 MB](model/FasterRCNN-10.onnx) |[158.0 MB](model/FasterRCNN-10.tar.gz) |1.5 |10 |mAP of 0.35 |
13-
13+
|Faster R-CNN R-50-FPN-fp32 |[168.5 MB](model/FasterRCNN-12.onnx) |[156.2 MB](model/FasterRCNN-12.tar.gz) |1.9 |12 |mAP of 0.3437 |
14+
|Faster R-CNN R-50-FPN-int8 |[42.6 MB](model/FasterRCNN-12-int8.onnx) |[36.2 MB](model/FasterRCNN-12-int8.tar.gz) |1.9 |12 |mAP of 0.3399 |
15+
> Compared with the fp32 FasterRCNN-12, int8 FasterRCNN-12's mAP decline ratio is 1.11% and performance improvement is 1.43x.
16+
>
17+
> Note the performance depends on the test hardware.
18+
>
19+
> Performance data here is collected with Intel® Xeon® Platinum 8280 Processor, 1s 4c per instance, CentOS Linux 8.3, data batch size is 1.
1420
1521

1622
<hr>
@@ -112,14 +118,44 @@ Metric is COCO box mAP (averaged over IoU of 0.5:0.95), computed over 2017 COCO
112118
mAP of 0.353
113119
<hr>
114120

121+
## Quantization
122+
Faster R-CNN R-50-FPN-fp32 is obtained by quantizing Faster R-CNN R-50-FPN-fp32 model. We use [Intel® Neural Compressor](https://github.com/intel/neural-compressor) with onnxruntime backend to perform quantization. View the [instructions](https://github.com/intel/neural-compressor/blob/master/examples/onnxrt/object_detection/onnx_model_zoo/faster_rcnn/quantization/ptq/README.md) to understand how to use Intel® Neural Compressor for quantization.
123+
124+
### Environment
125+
onnx: 1.9.0
126+
onnxruntime: 1.8.0
127+
128+
### Prepare model
129+
```shell
130+
wget https://github.com/onnx/models/blob/main/vision/object_detection_segmentation/faster-rcnn/model/FasterRCNN-12.onnx
131+
```
132+
133+
### Model quantize
134+
```bash
135+
bash run_tuning.sh --input_model=path/to/model \ # model path as *.onnx
136+
--config=faster_rcnn.yaml \
137+
--data_path=path/to/COCO2017 \
138+
--output_model=path/to/save
139+
```
140+
<hr>
141+
115142
## Publication/Attribution
116143
Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. Conference on Neural Information Processing Systems (NIPS), 2015.
117144

118145
Massa, Francisco and Girshick, Ross. maskrcnn-benchmark: Fast, modular reference implementation of Instance Segmentation and Object Detection algorithms in PyTorch. [facebookresearch/maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark).
119146
<hr>
120147

121148
## References
122-
This model is converted from [facebookresearch/maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark) with modifications in [repository](https://github.com/BowenBao/maskrcnn-benchmark/tree/onnx_stage).
149+
* This model is converted from [facebookresearch/maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark) with modifications in [repository](https://github.com/BowenBao/maskrcnn-benchmark/tree/onnx_stage).
150+
151+
* [Intel® Neural Compressor](https://github.com/intel/neural-compressor)
152+
<hr>
153+
154+
## Contributors
155+
* [mengniwang95](https://github.com/mengniwang95) (Intel)
156+
* [airMeng](https://github.com/airMeng) (Intel)
157+
* [ftian1](https://github.com/ftian1) (Intel)
158+
* [hshen14](https://github.com/hshen14) (Intel)
123159
<hr>
124160

125161
## License
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:c6bb169f20bd4bf1c08212f2c8b2693a22a6343454f8115fd8c0fadd2a49922a
3+
size 44626453
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:599fcd738eb08d8d5daee9edb332f785c59f9a3c704292ba420a41c1b43404e2
3+
size 37955516
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:789104f5a47f008450a37e02da8a8d3642766ed10d91238312b1532fe72789a6
3+
size 176713194
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:67208685047b27a201c1b50a3a7a0ea25161e9988bc4211adb74c85637c33860
3+
size 163814449

0 commit comments

Comments
 (0)