I have a yolov8s model for object detection (2 classes). I converted yolov8s.onnx to yolov8s.dlc by this command:
python $SNPE_ROOT/bin/x86_64-linux-clang/snpe-onnx-to-dlc \
--input_network yolov8s.onnx \
--input_type images image \
--input_layout images NCHW \
--input_dim images "1, 3, 640, 640" \
--input_dtype images float32 \
--input_encoding images bgr \
--out_node output0 \
--output_path yolov8s.dlc
After that, I continue to quantized yolov8s.dlc to yolov8s_quantize.dlc:
source $SNPE_ROOT/bin/x86_64-linux-clang/snpe-dlc-quantize \
--input_dlc yolov8s.dlc \
--input_list raw_list.txt \
--output_dlc yolov8s_quantized.dlc
My raw images format is NCHW, float32, normalize by divided by 255.
I use one of raw images to reference:
$SNPE_ROOT/bin/aarch64-ubuntu-gcc9.4/snpe-net-run \
--input_list input.txt \
--container yolov8s_quantized.dlc \
--output_dir output \
--use_dsp
I got the output is a raw file. Thus, how I can draw bbox from this raw file to sample image.
I try to find scale and offset of current quantized model by using snpe-dlc-info -i yolov8_quantized.dlc
. I got this:
-------------------------------------------------------------------------------------------------------------------------------------------
| Input Name | Dimensions | Type | Encoding Info
|
-------------------------------------------------------------------------------------------------------------------------------------------
| images | 1,640,640,3 | uFxp_8 | bitwidth 8, min 0.000000000000, max 1.000000000000, scale 0.003921568859, offset 0.000000000000 |
-------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------
| Output Name | Dimensions | Type | Encoding Info
|
-------------------------------------------------------------------------------------------------------------------------------------------------
| output0 | 1,6,8400 | uFxp_8 | bitwidth 8, min -43.135402679443, max 690.166442871094, scale 2.875693559647, offset -15.000000000000 |
-------------------------------------------------------------------------------------------------------------------------------------------------
Then I use this formula dequant_output = quant_output * SCALE - OFFSET
with SCALE = 2.875693559647
, OFFSET = -15
to get the value to draw bbox on image. But it have high confidences score. I couldn't draw exactly bbox for objects.
I have a yolov8s model for object detection (2 classes). I converted yolov8s.onnx to yolov8s.dlc by this command:
python $SNPE_ROOT/bin/x86_64-linux-clang/snpe-onnx-to-dlc \
--input_network yolov8s.onnx \
--input_type images image \
--input_layout images NCHW \
--input_dim images "1, 3, 640, 640" \
--input_dtype images float32 \
--input_encoding images bgr \
--out_node output0 \
--output_path yolov8s.dlc
After that, I continue to quantized yolov8s.dlc to yolov8s_quantize.dlc:
source $SNPE_ROOT/bin/x86_64-linux-clang/snpe-dlc-quantize \
--input_dlc yolov8s.dlc \
--input_list raw_list.txt \
--output_dlc yolov8s_quantized.dlc
My raw images format is NCHW, float32, normalize by divided by 255.
I use one of raw images to reference:
$SNPE_ROOT/bin/aarch64-ubuntu-gcc9.4/snpe-net-run \
--input_list input.txt \
--container yolov8s_quantized.dlc \
--output_dir output \
--use_dsp
I got the output is a raw file. Thus, how I can draw bbox from this raw file to sample image.
I try to find scale and offset of current quantized model by using snpe-dlc-info -i yolov8_quantized.dlc
. I got this:
-------------------------------------------------------------------------------------------------------------------------------------------
| Input Name | Dimensions | Type | Encoding Info
|
-------------------------------------------------------------------------------------------------------------------------------------------
| images | 1,640,640,3 | uFxp_8 | bitwidth 8, min 0.000000000000, max 1.000000000000, scale 0.003921568859, offset 0.000000000000 |
-------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------
| Output Name | Dimensions | Type | Encoding Info
|
-------------------------------------------------------------------------------------------------------------------------------------------------
| output0 | 1,6,8400 | uFxp_8 | bitwidth 8, min -43.135402679443, max 690.166442871094, scale 2.875693559647, offset -15.000000000000 |
-------------------------------------------------------------------------------------------------------------------------------------------------
Then I use this formula dequant_output = quant_output * SCALE - OFFSET
with SCALE = 2.875693559647
, OFFSET = -15
to get the value to draw bbox on image. But it have high confidences score. I couldn't draw exactly bbox for objects.
1 Answer
Reset to default 0The output from snpe-net-run is already de-quantized to float32. This is the equivalent raw buffer from the ONNX equivalent which can be taken for post-processing to extract the bounding boxes.
You may further refer to the following resource to understand the inference flow with Yolov8 using SNPE,
https://github/quic/qidk/blob/master/Model-Enablement/Model-Accuracy-Mixed-Precision/Accuracy_Analyzer_YoloV8.ipynb