forked from onnx/neural-compressor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mengni Wang <[email protected]>
- Loading branch information
1 parent
0f8c3a6
commit a4410a2
Showing
75 changed files
with
11,978 additions
and
1,336 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
examples/image_recognition/resnet50/quantization/ptq_static/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Step-by-Step | ||
|
||
This example load an image classification model from [ONNX Model Zoo](https://github.com/onnx/models) and confirm its accuracy and speed based on [ILSVR2012 validation Imagenet dataset](http://www.image-net.org/challenges/LSVRC/2012/downloads). You need to download this dataset yourself. | ||
|
||
# Prerequisite | ||
|
||
## 1. Environment | ||
|
||
```shell | ||
pip install onnx-neural-compressor | ||
pip install -r requirements.txt | ||
``` | ||
|
||
> Note: Validated ONNX Runtime [Version](/docs/source/installation_guide.md#validated-software-environment). | ||
## 2. Prepare Model | ||
|
||
```shell | ||
python prepare_model.py --output_model='resnet50-v1-12.onnx' | ||
``` | ||
|
||
## 3. Prepare Dataset | ||
|
||
Download dataset [ILSVR2012 validation Imagenet dataset](http://www.image-net.org/challenges/LSVRC/2012/downloads). | ||
|
||
Download label: | ||
|
||
```shell | ||
wget http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz | ||
tar -xvzf caffe_ilsvrc12.tar.gz val.txt | ||
``` | ||
|
||
# Run | ||
|
||
|
||
## 1. Quantization | ||
|
||
Quantize model with QLinearOps: | ||
|
||
```bash | ||
bash run_quant.sh --input_model=path/to/model \ # model path as *.onnx | ||
--dataset_location=/path/to/imagenet \ | ||
--label_path=/path/to/val.txt \ | ||
--output_model=path/to/save | ||
``` | ||
|
||
Quantize model with QDQ mode: | ||
|
||
```bash | ||
bash run_quant.sh --input_model=path/to/model \ # model path as *.onnx | ||
--dataset_location=/path/to/imagenet \ | ||
--label_path=/path/to/val.txt \ | ||
--output_model=path/to/save \ | ||
--quant_format=QDQ | ||
``` | ||
|
||
## 2. Benchmark | ||
|
||
```bash | ||
bash run_benchmark.sh --input_model=path/to/model \ # model path as *.onnx | ||
--dataset_location=/path/to/imagenet \ | ||
--label_path=/path/to/val.txt \ | ||
--mode=performance # or accuracy | ||
``` |
Oops, something went wrong.