Yolov3 single channel model quantize error

when i try to convert a yolov3 single channel model, some errors occur. When i run bash 1_quantize_model.sh,
File “tensorflow_core/python/framework/op_def_library.py”, line 793, in _apply_op_helper
File “tensorflow_core/python/util/deprecation.py”, line 507, in new_func
File “tensorflow_core/python/framework/ops.py”, line 3360, in create_op
File “tensorflow_core/python/framework/ops.py”, line 3429, in _create_op_internal
File “tensorflow_core/python/framework/ops.py”, line 1773, in init
File “tensorflow_core/python/framework/ops.py”, line 1613, in _create_c_op
ValueError: Depth of input (1) is not a multiple of input depth of filter (32) for ‘convolution_0_2/Conv2D’ (op: ‘Conv2D’) with input shapes: [1,418,418,1], [3,3,32,32].
[7819] Failed to execute script tensorzonex

1_quantize_model.sh is as below:



#dynamic_fixed_point-i8 asymmetric_affine-u8
–action quantization
–dtype float32
–source text
–source-file ./data/validation_tf.txt
–channel-mean-value ‘0 0 0 256’
–model-input ${NAME}.json
–model-data ${NAME}.data
–model-quantize ${NAME}.quantize
–quantized-dtype dynamic_fixed_point-i8

so i want to know how to convert a single channel yolov3 model to nb format?

@objectness Please follow this file Model_Transcoding and Running User Guide_V0.7.pdf in docs

Thanks for your quick response.My data is normalized to the range [0, 1], so i set the –channel-mean-value paras to ‘0 0 0 256’.Any other suggestions :pray:

@objectness Maybe you can try this 0 0 0 1 ? I am not sure . You can try and faceback there

@Frank Same error as before :confused:

@objectness ValueError ,this is not caused by the channel value. This is caused by unsupported network layers or neural nodes.

@Frank My yolov3 network model is almost same as original repo, i just change channels=1 in .cfg file when training.

@objectness If you just change channels=1 , how you data normalized to the range [0,1] ?

@Frank I am a little bit confused of what you said, in my opinion if i set –channel-mean-value to ‘0 0 0 256’ the pre-process will normalize image data to the range [0,1].

@objectness You say Thanks for your quick response.My data is normalized to the range [0, 1], so i set the –channel-mean-value paras to ‘0 0 0 256’.Any other suggestions . I understand that it has been normalized before the conversion…

This parameter configuration should be correct.

Can you try to convert the official weights file? It will help you to confirm whether there is a problem with your conversion environment

@Frank I have already tried both official weights and my own weights, while channels=3 converting process is fine, nbg_unify_yolov3 file is generated, but when i use a single channel, i met some errors.

@objectness Had you modified this file and remake ?


@Frank No, i just use original code, just edit some paras in .cfg file.

@objectness If you want to train single channel . You need to edit the source code and remakeit .just edit configiure file is not enough

@Frank I have successful trained a single channel model on FLIR dataset, which can work fine on original repo. I have also converted the model to caffe framework, .pb file also could work fine.

@objectness I had trained single channel. And I have modified the source code .
In functionload_data_detection

d.X.cols = h*w*3; --> d.X.cols = h*w;

Maybe you don’t need to do this . But I think it’s not correct here, it’s wrong when loading the image data

@Frank Maybe i should not use AlexeyAB’s version, in his repo d.X.cols = hwc. But it’s weird because 3 channels model can work fine while single channel model cannot.

@objectness I suggest you use the official version

@Frank I will try the official version, if i have any progress i will feedback here, anyway thanks for your help :smiley:

@objectness OK, If you have any question, you can faceback there