Open tingggggg opened 3 years ago
@tingggggg, could you provide more info, like how big is your calibration dataset, which model are you using?
@yufenglee , thank u for your help. I use 100 images to calibrate. Is there a standard that requires several pictures to be enough? I use small yolov3 for 5 class and only 2 output (32x32, 16x16)
Can I do calibration with coco dataset if model trained with image of actual application scenarios? (same category)
@tingggggg,
@yufenglee , thank u for your help. I use 100 images to calibrate. Is there a standard that requires several pictures to be enough? I use small yolov3 for 5 class and only 2 output (32x32, 16x16)
Can I do calibration with coco dataset if model trained with image of actual application scenarios? (same category)
@tingggggg, no, you need to use the dataset with same characteristic as training dataset to calibrate. And if you don't run with TensorRT ep, you don't need to call get_calibration_table(model_path, augmented_model_path, calibration_dataset)
.
100 images is a little bit small. In general, we use 500 and more to do calibrate.
Other option you can try is to try the Entropy calibration method: https://github.com/microsoft/onnxruntime/blob/c6ef6b5bc8eeb49a6b8f6fadfd212c9e07ddde31/onnxruntime/python/tools/quantization/quantize.py#L149
@yufenglee, after done some test. I find out that i need to add param nodes_to_exclude
for function quantize_static
and quantize only for Conv node to avoid bad accuracy.
I also find out size of yolov3 model that doing this quantize operation be reduce, but inference time slow down. Do I quantizing wrong?
e.g.
op_types_to_quantize = ["Conv"]
nodes_to_exclude = ['conv0', 'conv1', 'conv2', 'conv3', 'conv4'] # exclude some node from head
quantize_static(..., op_types_to_quantize, nodes_to_exclude=nodes_to_exclude, )
@tingggggg, partial quantization introduces interleaving Dequantize and Quantize and makes latency bad. I would recommend to retrain the model with Quantized Aware Training tech to get the accuracy back. Could you share me your model with conv quantized only?
This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.
I refer example (https://github.com/microsoft/onnxruntime-inference-examples/tree/main/quantization/object_detection/trt/yolov3) to do quantization on own yolo model. But I got the bad result on quantized model.
I test to change both QuantFormat and QuantType but still got the bad result. Model can not detect anything after quantized.
Can someone give me some tricks or tips to convert the yolo model?