I use the tflite model to convert, bug got errors :
(vim3l) ➜ retinaface
NAME=retinaface
ACUITY_PATH=../bin/
convert_caffe=${ACUITY_PATH}convertcaffe
convert_tf=${ACUITY_PATH}convertensorflow
convert_tflite=${ACUITY_PATH}convertflite
convert_darknet=${ACUITY_PATH}convertdarknet
convert_onnx=${ACUITY_PATH}convertonnx
$convert_tflite \
--tflite-model /home/zqh/workspace/vim3l/aml_npu_sdk/acuity-toolkit/retinaface/retinaface.tflite \
--net-output ${NAME}.json \
--data-output ${NAME}.data
I Model: retinaface
I Version: 3
I Description: TOCO Converted.
I Subgraphs: 1
D Convert layer pad+conv_2d
D Convert layer depthwise_conv_2d
D Convert layer conv_2d
D Convert layer pad+depthwise_conv_2d
.
.
.
D Convert layer concatenation
D Convert layer concatenation
I Dump net to retinaface.json
2020-03-10 00:10:10.237926: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
D Process input_0 ...
D Acuity output shape(input): (1 640 640 3)
D Process model_1/conv1_pad_1 ...
D Acuity output shape(convolution): (1 319 319 8)
D Process model_1/conv1_relu_2 ...
D Acuity output shape(relun): (1 319 319 8)
D Process model_1/conv_dw_1_relu_3 ...
D Acuity output shape(convolution): (1 319 319 8)
D Process model_1/conv_dw_1_relu_4 ...
D Acuity output shape(relun): (1 319 319 8)
D Process model_1/conv_pw_1_relu_5 ...
D Acuity output shape(convolution): (1 319 319 16)
D Process model_1/conv_pw_1_relu_6 ...
D Acuity output shape(relun): (1 319 319 16)
D Process model_1/conv_pad_2_7 ...
D Acuity output shape(convolution): (1 159 159 16)
D Process model_1/conv_dw_2_relu_8 ...
D Acuity output shape(relun): (1 159 159 16)
D Process model_1/conv_pw_2_relu_9 ...
D Acuity output shape(convolution): (1 159 159 32)
D Process model_1/conv_pw_2_relu_10 ...
D Acuity output shape(relun): (1 159 159 32)
D Process model_1/conv_dw_3_relu_11 ...
D Acuity output shape(convolution): (1 159 159 32)
D Process model_1/conv_dw_3_relu_12 ...
D Acuity output shape(relun): (1 159 159 32)
D Process model_1/conv_pw_3_relu_13 ...
D Acuity output shape(convolution): (1 159 159 32)
D Process model_1/conv_pw_3_relu_14 ...
D Acuity output shape(relun): (1 159 159 32)
D Process model_1/conv_pad_4_15 ...
D Acuity output shape(convolution): (1 79 79 32)
D Process model_1/conv_dw_4_relu_16 ...
D Acuity output shape(relun): (1 79 79 32)
D Process model_1/conv_pw_4_relu_17 ...
D Acuity output shape(convolution): (1 79 79 64)
D Process model_1/conv_pw_4_relu_18 ...
D Acuity output shape(relun): (1 79 79 64)
D Process model_1/conv_dw_5_relu_19 ...
D Acuity output shape(convolution): (1 79 79 64)
D Process model_1/conv_dw_5_relu_20 ...
D Acuity output shape(relun): (1 79 79 64)
D Process model_1/conv_pw_5_relu_21 ...
D Acuity output shape(convolution): (1 79 79 64)
D Process model_1/conv_pw_5_relu_22 ...
D Acuity output shape(relun): (1 79 79 64)
D Process model_1/batch_normalization_23 ...
D Acuity output shape(convolution): (1 79 79 64)
D Process model_1/leaky_re_lu_24 ...
Traceback (most recent call last):
File "convertflite.py", line 63, in <module>
File "convertflite.py", line 41, in main
File "acuitylib/acuitynetbuilder.py", line 279, in build
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 305, in build_layer
File "acuitylib/acuitynetbuilder.py", line 305, in <genexpr>
AttributeError: 'NoneType' object has no attribute 'to_string'
[19456] Failed to execute script convertflite
I used tf2.0 training, there is no layer in the model that the model converter does not support. tflite model in here, Can check for me what’s wrong?
@jujuede When you use the conversion script , you tensorflow version must be tf1.10 . The conversion script can’t work in newer version . I use tf1.14 to train ,but I must use tf1.10 to convert . But I am not sure about TF2.0 model
I mean tflite should be all supported, not be unable to convert due to the lower version of tensorflow, and my model has no unsupported op. So I hope you can help me solve this problem
@jujuede the error log about AttributeError: 'NoneType' object has no attribute 'xxxxx' is the common version errors . Some functions in tf1.14 and tf2.0 are not available in tf1.10 . So if you use the models directly trained and frozen by others will contain some functional interfaces not included in tf1.10 . I have tried direct conversion and will report an error . Then I use tf1.10 again to export and freeze my model, which can be converted . This problem is also a very troublesome problem, which greatly affects the use . This means that some frozen models cannot be transformed which you can downloads in Internet . This tool is neither open source nor developed by us. We cannot change the current situation. We are already trying to find a way to feed back and solve this problem.
Does the model conversion tool not support tflite models?
I have generated my model from tf 1.10 to tflite, but the conversion still fails. At the same time, I used tf1.10 to generate tflite with the built-in mobilenetv1, and the conversion failed.
D Process global_average_pooling2d_109 ...
D Acuity output shape(pooling): (1 1 1 256)
D Process reshape_1_110 ...
D Acuity output shape(reshape): (1 1 1 256)
D Process conv_preds_111 ...
D Acuity output shape(convolution): (1 1 1 1000)
D Process variable_173 ...
D Acuity output shape(variable): (1)
D Process act_softmax_112 ...
Traceback (most recent call last):
File "convertflite.py", line 63, in <module>
File "convertflite.py", line 41, in main
File "acuitylib/acuitynetbuilder.py", line 279, in build
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 300, in build_layer
File "acuitylib/acuitynetbuilder.py", line 305, in build_layer
File "acuitylib/acuitynetbuilder.py", line 305, in <genexpr>
AttributeError: 'NoneType' object has no attribute 'to_string'
[4915] Failed to execute script convertflite
@jujuede I had test you model which you link to me . I get the same error . I am not sure what happen with it . Beacuse the convert tool not a open source tools . But I met this mistake once . Once I try to use TF tool that which build from tensorflow source code to test a inception model . It return this error . In the end, I found out that the reason for this mistake is my TF version is 1.10, not 1.14 . I forget to switch to 1.14 . I find the docs in the tf website that some functions can be work in 1.10. So I think this may have something to do with your transition from TF. Keras . Maybe you should use tflite directly to train one . There are many problems in the relationship transformation tool, and we are already giving feedback . Next, we will try to train some tflite, or transform some tflite for users to use . But this can’t be realized in the near future. Now we have a lot of stacked tasks to deal with. We can’t deal with this . Several users have fed back to me about tflite . It’s on the plan , just need times . I want to know what you use this model for,If you are not in a hurry, you can wait for further information.
@jujuede Maye you need to look the source code . Bucase this demo just to get one output data . If you need to get more . You need to modified the code .
Add this to you script 1_quantize_model.sh (you need to change parameter)
@jujuede Maybe you need to make sure your pictures in validation.txt is right? If you pictures are right , you need to check you parameter . Because the conversion tool is not open-source, it is difficult for me to debug. You can only try to modify the parameters .
Can you share “retinaface.quantize” , after running script 1_conversion?
What it says @concatenate_3/concat , @concatenate_4/concat,
@ concatenate_5/concat’ line?