Quark ONNX Quantization Example#

This folder contains an example of Auto search for quantizing a yolov3 model based on the ONNX quantizer of Quark. The example has the following parts:

Pip requirements#

Install the necessary python packages:

python -m pip install -r ./requirements.txt

Prepare model#

Download the yolov3 model from huggingface url:

https://huggingface.co/amd/yolov3/tree/main

Prepare data#

COCO 2017, commonly known as ‘COCO’. This dataset include five thousand validation pictures with labels.

In this example, we use the built-in evaluator, so we do not use the COCO2017 directly. Instead, at first you need to prepare the calibration dataset with coco 2017 preprocess and save in .npy format.

The storage format of the val_data of the COCO2017 dataset organized as follows:

-  val_data
      -  sample_1.npy
      -  sample_2.npy
      -  …

we use this dataset as evaluation dataset and calibration dataset at the same time.

Evaluation#

Test the accuracy of the float model on ImageNet val dataset:

python ../utils/onnx_validate.py val_data --model-name resnet152 --batch-size 1 --onnx-input models/resnet152.onnx

Test the accuracy of the quantized model without CLE on ImageNet val dataset:

License#

Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved. SPDX-License-Identifier: MIT