根据 https://docs.khadas.com/vim3/HowToTransformYolo.html 中的步骤,使用 yolov3.cfg和yolov3.weights,但最终的结果输出却大于0,请问问题应该出在哪?如何排查问题?
@ThinkBird 请问你在转换之前验证了吗,看起来这种情况是训练数据有问题
模型和权重文件没有问题,使用命令./darknet detect cfg/yolov3.cfg weights/yolov3.weights data/dog.jpg
输出如下:
另外,修改过量化所用的文件名和文件内容:
1_quantize_model_yolov3.sh
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
tensorzone=${ACUITY_PATH}tensorzonex
#asymmetric_quantized-u8 dynamic_fixed_point-8 dynamic_fixed_point-16
$tensorzone \
--action quantization \
--source text \
--source-file ./data/validation_yolov3.txt \
--channel-mean-value '0 0 0 256' \
--model-input ${NAME}.json \
--model-data ${NAME}.data \
--quantized-dtype dynamic_fixed_point-8 \
--quantized-rebuild
##$tensorzone \
## --action inference \
## --source text \
## --source-file ./data/validation_yolov3.txt \
## --channel-mean-value '0 0 0 256' \
## --model-input ${NAME}.json \
## --model-data ${NAME}.data \
## --dtype quantized
validation_yolov3.txt(实际内容有200行)
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000002.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000003.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000007.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000009.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000016.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000021.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000026.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000027.jpg
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000032.jpg
@ThinkBird 将验证图片改成一张试试,这个地方是有bug的
请问验证图片文件的格式是怎样的?仅仅是图片路径吗?
我看demo里的validation_tf.txt
内容是
./dog_299.jpg, 208
但 Model-convert-0.4-Wesion_zh.pdf 文件中并未提及。
@ThinkBird 只要包括图片路径就可以,这里只是做验证,使用一张就好,多张图片会有bug,最后显示的结果是不正确的
验证图片换成一张,仍旧有问题。
yolov3和yolov3tiny也都试过了,还是问题依旧。
用命令行也是不行,问题依旧,命令行如下,请帮忙看是否是命令行有问题:
../bin/convertdarknet --net-input yolov3-tiny.cfg --weight-input yolov3-tiny.weights --data-output yolov3-tiny.data --net-output yolov3-tiny.json
../bin/tensorzonex --action quantization \
--quantized-dtype dynamic_fixed_point-8 \
--channel-mean-value '0 0 0 256' \
--source text --source-file dataset1.txt \
--model-input yolov3-tiny.json --model-data yolov3-tiny.data \
--quantized-rebuild
../bin/ovxgenerator --model-input yolov3-tiny.json \
--model-quantize yolov3-tiny.quantize \
--data-input yolov3-tiny.data \
--channel-mean-value '0 0 0 256' \
--reorder-channel '2 1 0' \
--export-dtype quantized \
--optimize VIPNANOQI_PID0X88 \
--viv-sdk ../bin/vcmdtools \
--pack-nbg-unify
验证文件如下:
dataset1.txt
/home/yan/project/darknet/VOCdevkit/VOC2012/JPEGImages/2008_000002.jpg
另外,有没有可能是解析(process.c)过程出的问题?
I trained yolov3 for logo recognization and I have same issue.
Seems like it is not a multiple --source-file problem. I used only one jpg file.
Of course I’ve tested my trained weight file at PC and it works graceful.
@khs971 Did you check you parameter in the conversion script is true ? There are many parameters to set when using scripts.
error occured script below.
0_import_model.sh
$convert_darknet
–net-input /home/khs971/npu/logo-train-416/yolov3-voc.cfg
–weight-input /home/khs971/npu/logo-train-416/backup/yolov3-voc_10000.weights
–net-output ${NAME}.json
–data-output ${NAME}.data
1_quantize_model.sh
$tensorzone
–action quantization
–source text
–source-file ./data/validation_tf.txt
–channel-mean-value ‘0 0 0 256’
–model-input ${NAME}.json
–model-data ${NAME}.data
–quantized-dtype dynamic_fixed_point-8
–quantized-rebuild
$tensorzone
–action inference
–source text
–source-file ./data/validation_tf.txt
–channel-mean-value ‘0 0 0 256’
–model-input ${NAME}.json
–model-data ${NAME}.data
–dtype quantized
2_export_case_code.sh
$export_ovxlib
–model-input ${NAME}.json
–data-input ${NAME}.data
–reorder-channel ‘2 1 0’
–channel-mean-value ‘0 0 0 256’
–export-dtype quantized
–model-quantize ${NAME}.quantize
–optimize VIPNANOQI_PID0X88
–viv-sdk …/bin/vcmdtools
–pack-nbg-unify
and I tried script which Model_Transform_and_Process_Guide-Wesion_EN.pdf document explained, but result is same.
@khs971 There seems to be nothing wrong with the parameters . Can you show me the log info about you transfrom .
my trans log here:
@khs971 I see in the log file, where are the five zeros about the highest probability . In combination with your log and the conversion parameters you provide, I don’t think there is any problem with your conversion process. Did you test your Darknet model on your PC before you converted again ?
@ThinkBird 你使用yolov3的模型也会么,不使用tiny版本的话,你训练使用的哪个权重文件
@khs971 when you run 1_quantize_model.sh . It will show a result in the end of log. Such as
I Build model complete.
I Generated network graph with 1 outputs.
I @attach_output_1/out0_0:out0: (3,)
I Start tensor porvider ...
I Clean.
D Saving attach_conv2d_1_input_out0_1_out0_1_30_30_3.tensor
D Saving attach_output_1_out0_0_out0_3.tensor
I 1: 1.0
I 0: 2.006780491108507e-18
I 2: 1.6472656956609696e-19
I ----------------Warning(0)----------------
It can help you to check you that your conversion was right or no before this step
yolov3和yolov3-tiny情况一样,权重文件是官网下载的,没有做任何修改。(用训练过的权重文件,也是这个问题)
@ThinkBird 脚本1_quantize_model.sh
里面也有一个验证,请问你在第二部验证时,结果是什么
$tensorzone \
--action inference \
--source text \
--source-file ./data/validation_edu.txt \
--channel-mean-value '0 0 0 256' \
--model-input ${NAME}.json \
--model-data ${NAME}.data \
--dtype quantized
That is yolov3 convert log? when i convert yolov3, i have 1 input and 3 output tensor at log.
I Build yolov3-voc complete.
I Generated network graph with 3 outputs.
I @output_199:out0: (1, 19, 19, 111)
I @output_225:out0: (1, 38, 38, 111)
I @output_251:out0: (1, 76, 76, 111)
I Start tensor porvider …
I Clean.
D Saving input_0_out0_1_3_608_608.tensor
D Saving output_199_out0_1_111_19_19.tensor
D Saving output_225_out0_1_111_38_38.tensor
D Saving output_251_out0_1_111_76_76.tensor
I ----------------Warning(0)----------------
我使用的脚本内容略有不同,
文件 1_quantize_model_yolov3.sh 内容如下:
#!/bin/bash
NAME=yolov3
ACUITY_PATH=../bin/
tensorzone=${ACUITY_PATH}tensorzonex
#asymmetric_quantized-u8 dynamic_fixed_point-8 dynamic_fixed_point-16
$tensorzone \
--action quantization \
--source text \
--source-file ./data/validation_yolov3.txt \
--channel-mean-value '0 0 0 256' \
--model-input ${NAME}.json \
--model-data ${NAME}.data \
--quantized-dtype asymmetric_quantized-u8 \
--quantized-rebuild
其输出内容如下:
xin@DESKTOP-GV1O2QJ:conversion_scripts$ ./1_quantize_model_yolov3.sh
I Namespace(action='quantization', batch_size=100, caffe_mean_file=None, capture_format='nchw', capture_quantized=False, channel_mean_value='0 0 0 256', config=None, data_output=None, debug=False, device=None, dtype='float32', epochs=1, epochs_per_decay=100, force_gray=False, fpfs_delta0=1, fpfs_epochs=0, fpfs_reduce_target=0, input_fitting='scale', input_normalization=None, lr=0.1, mean_file=None, model_data='yolov3.data', model_data_format='zone', model_input='yolov3.json', model_quantize=None, optimizer='momentum', output_dir=None, output_num=5, pb_name=None, prune_epochs=10, prune_loss=1, quantized_algorithm='normal', quantized_divergence_nbins=1024, quantized_dtype='asymmetric_quantized-u8', quantized_hybrid=False, quantized_moving_alpha=0.0, quantized_rebuild=True, quantized_rebuild_all=False, random_brightness=None, random_contrast=None, random_crop=False, random_flip=False, random_mirror=False, reorder_channel=None, restart=False, samples=-1, source='text', source_file='./data/validation_yolov3.txt', task='classification', validation_output='validation.csv', without_update_masked_grad=False)2020-03-04 15:54:22.717727: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
I Load net in yolov3.json
D Load layer input_0 ...
D Load layer convolution_1 ...
D Load layer leakyrelu_3 ...
D Load layer convolution_4 ...
D Load layer leakyrelu_6 ...
D Load layer convolution_7 ...
D Load layer leakyrelu_9 ...
D Load layer convolution_10 ...
D Load layer leakyrelu_12 ...
D Load layer add_13 ...
(此处省去一部分)
D Load layer leakyrelu_246 ...
D Load layer convolution_247 ...
D Load layer leakyrelu_249 ...
D Load layer convolution_250 ...
D Load layer output_251 ...
I Load yolov3.json complete.
I Load data in yolov3.data
I Fitting image with scale.
I Channel mean value [0.0, 0.0, 0.0, 256.0]
I Quantization start...
I Init validate tensor provider.
I Enqueue samples 8
I Init provider with 8 samples.
D set up a quantize net
D Process input_0 ...
D Acuity output shape(input): (8 608 608 3)
D Real output shape: (8, 608, 608, 3)
D Process convolution_1 ...
D Acuity output shape(convolution): (8 608 608 32)
D Real output shape: (8, 608, 608, 32)
D Process leakyrelu_3 ...
D Acuity output shape(leakyrelu): (8 608 608 32)
D Real output shape: (8, 608, 608, 32)
D Process convolution_4 ...
D Acuity output shape(convolution): (8 304 304 64)
D Real output shape: (8, 304, 304, 64)
(此处省去一部分)
D Process convolution_250 ...
D Acuity output shape(convolution): (8 76 76 255)
D Real output shape: (8, 76, 76, 255)
D Process output_251 ...
D Acuity output shape(output): (8 76 76 255)
D Real output shape: (8, 76, 76, 255)
I Build yolov3 complete.
I Generated network graph with 3 outputs.
I @output_199:out0: (8, 19, 19, 255)
I @output_225:out0: (8, 38, 38, 255)
I @output_251:out0: (8, 76, 76, 255)
D Init coefficients ...
I Start tensor porvider ...
I Runing 1 epochs, algorithm: normal
I iterations: 0
2020-03-04 15:55:58.225621: W tensorflow/core/framework/allocator.cc:108] Allocation of 378535936 exceeds 10% of system memory.
2020-03-04 15:55:59.468026: W tensorflow/core/framework/allocator.cc:108] Allocation of 378535936 exceeds 10% of system memory.
2020-03-04 15:56:00.311111: W tensorflow/core/framework/allocator.cc:108] Allocation of 381030400 exceeds 10% of system memory.
D Quantize tensor @input_0:out0.
D Quantize tensor @convolution_1:out0.
D Quantize tensor @leakyrelu_3:out0.
D Quantize tensor @convolution_4:out0.
D Quantize tensor @leakyrelu_6:out0.
D Quantize tensor @convolution_7:out0.
D Quantize tensor @leakyrelu_9:out0.
D Quantize tensor @convolution_10:out0.
D Quantize tensor @leakyrelu_12:out0.
D Quantize tensor @add_13:out0.
D Quantize tensor @convolution_14:out0.
D Quantize tensor @leakyrelu_16:out0.
D Quantize tensor @convolution_17:out0.
D Quantize tensor @leakyrelu_19:out0.
D Quantize tensor @convolution_20:out0.
D Quantize tensor @leakyrelu_22:out0.
D Quantize tensor @add_23:out0.
D Quantize tensor @convolution_24:out0.
D Quantize tensor @leakyrelu_26:out0.
D Quantize tensor @convolution_27:out0.
D Quantize tensor @leakyrelu_29:out0.
D Quantize tensor @add_30:out0.
D Quantize tensor @convolution_31:out0.
D Quantize tensor @leakyrelu_33:out0.
D Quantize tensor @convolution_34:out0.
D Quantize tensor @leakyrelu_36:out0.
D Quantize tensor @convolution_37:out0.
D Quantize tensor @leakyrelu_39:out0.
(此处省去一部分)
D Quantize tensor @convolution_244:out0.
D Quantize tensor @leakyrelu_246:out0.
D Quantize tensor @convolution_247:out0.
D Quantize tensor @leakyrelu_249:out0.
D Quantize tensor @convolution_250:out0.
D Quantize tensor @convolution_1:weight.
D Quantize tensor @convolution_4:weight.
D Quantize tensor @convolution_7:weight.
D Quantize tensor @convolution_10:weight.
D Quantize tensor @convolution_14:weight.
D Quantize tensor @convolution_17:weight.
D Quantize tensor @convolution_20:weight.
(此处省去一部分)
D Quantize tensor @convolution_235:weight.
D Quantize tensor @convolution_238:weight.
D Quantize tensor @convolution_241:weight.
D Quantize tensor @convolution_244:weight.
D Quantize tensor @convolution_247:weight.
D Quantize tensor @convolution_250:weight.
D Quantize tensor @convolution_1:bias.
D Quantize tensor @convolution_4:bias.
D Quantize tensor @convolution_7:bias.
D Quantize tensor @convolution_10:bias.
D Quantize tensor @convolution_14:bias.
D Quantize tensor @convolution_17:bias.
D Quantize tensor @convolution_20:bias.
D Quantize tensor @convolution_24:bias.
D Quantize tensor @convolution_27:bias.
(此处省去一部分)
D Quantize tensor @convolution_241:bias.
D Quantize tensor @convolution_244:bias.
D Quantize tensor @convolution_247:bias.
D Quantize tensor @convolution_250:bias.
I Clean.
D Optimizing network with qnt_single_transmit_quantize, align_quantize, broadcast_quantize, qnt_adjust_coef
D Align @upsampling_204:out0 scale to [0.12511505]
D Align @add_148:out0 scale to [0.12511505]
D Align @concat_205:out0 scale to [0.12511505]
D Align @concat_231:out0 scale to [0.1118538]
D Align @upsampling_230:out0 scale to [0.1118538]
D Align @add_89:out0 scale to [0.1118538]
D Quantize tensor(@output_199:out0) with tensor(@convolution_198:out0)
D Quantize tensor(@output_225:out0) with tensor(@convolution_224:out0)
D Quantize tensor(@output_251:out0) with tensor(@convolution_250:out0)
I Dump net quantize tensor table to yolov3.quantize
I Quantization complete.
I Save net to yolov3.data
I Clean.
I ----------------Warning(0)----------------
使用你给出的脚本:
$tensorzone \
--action inference \
--source text \
--source-file ./data/validation_edu.txt \
--channel-mean-value '0 0 0 256' \
--model-input ${NAME}.json \
--model-data ${NAME}.data \
--dtype quantized
其输出内如如下:
(以上部分省去)
D New variable weight of convolution_247 ...
D New variable bias of convolution_247 ...
D Real output shape: (8, 76, 76, 256)
D Process leakyrelu_249 ...
D Acuity output shape(leakyrelu): (8 76 76 256)
D Real output shape: (8, 76, 76, 256)
D Process convolution_250 ...
D Acuity output shape(convolution): (8 76 76 255)
D New variable weight of convolution_250 ...
D New variable bias of convolution_250 ...
D Real output shape: (8, 76, 76, 255)
D Process output_251 ...
D Acuity output shape(output): (8 76 76 255)
D Real output shape: (8, 76, 76, 255)
I Build yolov3 complete.
I Generated network graph with 3 outputs.
I @output_199:out0: (8, 19, 19, 255)
I @output_225:out0: (8, 38, 38, 255)
I @output_251:out0: (8, 76, 76, 255)
I Start tensor porvider ...
2020-03-04 16:25:53.081495: W tensorflow/core/framework/allocator.cc:108] Allocation of 378535936 exceeds 10% of system memory.
2020-03-04 16:25:54.192078: W tensorflow/core/framework/allocator.cc:108] Allocation of 378535936 exceeds 10% of system memory.
2020-03-04 16:25:54.717038: W tensorflow/core/framework/allocator.cc:108] Allocation of 381030400 exceeds 10% of system memory.
I Clean.
D Saving input_0_out0_8_3_608_608.tensor
D Saving output_199_out0_8_255_19_19.tensor
D Saving output_225_out0_8_255_38_38.tensor
D Saving output_251_out0_8_255_76_76.tensor
I ----------------Warning(0)----------------