This document describes the step-by-step to reproduce Yolo-v3 tuning result with Neural Compressor.
Recommend python 3.6 or higher version.
# Install Intel® Neural Compressor
pip install neural-compressor
Check your python version and pip install 1.15.0 up3 from links as below:
pip install https://storage.googleapis.com/intel-optimized-tensorflow/intel_tensorflow-1.15.0up3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
pip install https://storage.googleapis.com/intel-optimized-tensorflow/intel_tensorflow-1.15.0up3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Note: Supported Tensorflow versions please refer to Neural Compressor readme file.
cd examples/tensorflow/object_detection/yolo_v3/quantization/ptq
pip install -r requirements.txt
git clone https://github.com/mystic123/tensorflow-yolo-v3.git
cd tensorflow-yolo-v3
wget https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names
wget https://pjreddie.com/media/files/yolov3.weights
python convert_weights_pb.py --class_names coco.names --weights_file yolov3.weights --data_format NHWC --size 416 --output_graph yolov3.pb
Note:
prepare_dataset.sh
script works with TF version 1.x.
Run the prepare_dataset.sh
script located in examples/tensorflow/object_detection/yolo_v3/quantization/ptq
.
Usage:
cd examples/tensorflow/object_detection/yolo_v3/quantization/ptq
. prepare_dataset.sh
This script will download the train, validation and test COCO datasets. Furthermore it will convert them to
tensorflow records using the https://github.com/tensorflow/models.git
dedicated script.
Download CoCo Dataset from Official Website.
Usage
cd examples/tensorflow/object_detection/yolo_v3/quantization/ptq
python infer_detections.py --input_graph /path/to/yolov3_fp32.pb --config ./yolo_v3.yaml --output_graph /path/to/save/yolov3_tuned3.pb
Finally, the program will generate the quantized Yolo-v3 model with relative 1% loss.