Hi,
I used following two different cfg with same weights for yolov3, first one is producing wrong results and the second one is correctly executed. The detail is given below, can you please help me out!
- CASE. A
cfg: darknet/yolov3.cfg at master · pjreddie/darknet · GitHub
weights: https://pjreddie.com/media/files/yolov3.weights
- CASE. B
cfg: models-zoo/yolov3.cfg at master · yan-wyb/models-zoo · GitHub
weights: https://pjreddie.com/media/files/yolov3.weights
Differnce between two cfg files:
diff ~/sajjad/darknet/cfg/yolov3.cfg ~/sajjad/models-zoo/darknet/yolov3/yolov3/yolov3.cfg
3,4c3,4
< # batch=1
< # subdivisions=1
---
> batch=1
> subdivisions=1
6,9c6,9
< batch=64
< subdivisions=16
< width=608
< height=608
---
> # batch=64
> # subdivisions=16
> width=416
> height=416
- For CASE A. SDK CONVERSION SCRIPTS ARE:
0_import_model_608A.sh
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
pegasus=${ACUITY_PATH}pegasus
if [ ! -e "$pegasus" ]; then
pegasus=${ACUITY_PATH}pegasus.py
fi
$pegasus import darknet\
--model /home/sajjad/sajjad/darknet/cfg/yolov3.cfg \
--weights /home/sajjad/sajjad/darknet/yolov3.weights \
--output-model ${NAME}.json \
--output-data ${NAME}.data \
#generate inpumeta --source-file dataset.txt
$pegasus generate inputmeta \
--model ${NAME}.json \
--input-meta-output ${NAME}_inputmeta.yml \
--channel-mean-value "0 0 0 0.003906" \
--source-file data/validation_tf_608.txt
1_quantize_model_608_tiny.sh
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
pegasus=${ACUITY_PATH}pegasus
if [ ! -e "$pegasus" ]; then
pegasus=${ACUITY_PATH}pegasus.py
fi
$pegasus quantize \
--quantizer dynamic_fixed_point \
--qtype int8 \
--rebuild \
--with-input-meta ${NAME}_inputmeta.yml \
--model ${NAME}.json \
--model-data ${NAME}.data
2_export_case_code_608_tiny.sh
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
pegasus=$ACUITY_PATH/pegasus
if [ ! -e "$pegasus" ]; then
pegasus=$ACUITY_PATH/pegasus.py
fi
$pegasus export ovxlib\
--model ${NAME}.json \
--model-data ${NAME}.data \
--model-quantize ${NAME}.quantize \
--with-input-meta ${NAME}_inputmeta.yml \
--dtype quantized \
--optimize VIPNANOQI_PID0X88 \
--viv-sdk ${ACUITY_PATH}vcmdtools \
--pack-nbg-unify
rm -rf ${NAME}_nbg_unify
mv ../*_nbg_unify ${NAME}_nbg_unify
cd ${NAME}_nbg_unify
mv network_binary.nb ${NAME}_88.nb
cd ..
#save normal case demo export.data
mkdir -p ${NAME}_normal_case_demo
mv *.h *.c .project .cproject *.vcxproj BUILD *.linux *.export.data ${NAME}_normal_case_demo
# delete normal_case demo source
#rm *.h *.c .project .cproject *.vcxproj BUILD *.linux *.export.data
#rm *.data *.quantize *.json *_inputmeta.yml
rm *.data *.json *_inputmeta.yml
validation_tf_608.txt
demo$ cat data/validation_tf_608.txt
./1080p-608x608.jpg
- For CASE B. SDK CONVERSION SCRIPTS ARE:
Only difference is in the first script actually.
0_import_model_416A.sh
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
pegasus=${ACUITY_PATH}pegasus
if [ ! -e "$pegasus" ]; then
pegasus=${ACUITY_PATH}pegasus.py
fi
$pegasus import darknet\
--model /home/sajjad/sajjad/models-zoo/darknet/yolov3/yolov3/yolov3.cfg \
--weights /home/sajjad/sajjad/darknet/yolov3.weights \
--output-model ${NAME}.json \
--output-data ${NAME}.data \
#generate inpumeta --source-file dataset.txt
$pegasus generate inputmeta \
--model ${NAME}.json \
--input-meta-output ${NAME}_inputmeta.yml \
--channel-mean-value "0 0 0 0.003906" \
--source-file data/validation_tf_416.txt
1_quantize_model_416.sh
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
pegasus=${ACUITY_PATH}pegasus
if [ ! -e "$pegasus" ]; then
pegasus=${ACUITY_PATH}pegasus.py
fi
$pegasus quantize \
--quantizer dynamic_fixed_point \
--qtype int8 \
--rebuild \
--with-input-meta ${NAME}_inputmeta.yml \
--model ${NAME}.json \
--model-data ${NAME}.data
2_export_case_code_416.sh
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
pegasus=$ACUITY_PATH/pegasus
if [ ! -e "$pegasus" ]; then
pegasus=$ACUITY_PATH/pegasus.py
fi
$pegasus export ovxlib\
--model ${NAME}.json \
--model-data ${NAME}.data \
--model-quantize ${NAME}.quantize \
--with-input-meta ${NAME}_inputmeta.yml \
--dtype quantized \
--optimize VIPNANOQI_PID0X88 \
--viv-sdk ${ACUITY_PATH}vcmdtools \
--pack-nbg-unify
rm -rf ${NAME}_nbg_unify
mv ../*_nbg_unify ${NAME}_nbg_unify
cd ${NAME}_nbg_unify
mv network_binary.nb ${NAME}_88.nb
cd ..
#save normal case demo export.data
mkdir -p ${NAME}_normal_case_demo
mv *.h *.c .project .cproject *.vcxproj BUILD *.linux *.export.data ${NAME}_normal_case_demo
# delete normal_case demo source
#rm *.h *.c .project .cproject *.vcxproj BUILD *.linux *.export.data
#rm *.data *.quantize *.json *_inputmeta.yml
rm *.data *.json *_inputmeta.yml
validation_tf_416.txt
demo$ cat data/validation_tf_416.txt
./1080p-416x416.jpg
Test using detect_demo_picture/detect_demo_x11 -m 2
I am following the instructions from convert and call your own model through NPU | Khadas Documentation to detect objects using yolov3 based on the converted models.
- CASE. A: gives wrong results, I don’t know why?
- CASE. B: gives correct results:
Can you please elaborate what is the difference here for darknet/yolov3.cfg at master · pjreddie/darknet · GitHub, what should be the correct parameters in the conversion scripts to perform conversion based on this configuration file.
NOTE: When i modified darknet/yolov3.cfg at master · pjreddie/darknet · GitHub to the following (changed width=416, height=416), it still works for me correctly.
[net]
# Testing
# batch=1
# subdivisions=1
# Training
batch=64
subdivisions=16
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
I am really curious and confused what is the problem in these two configurations files while the three conversion scripts are similar.
@Frank @numbqq
Please guide, thanks for you time!
Regards,
Sajjad