Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

The models converted from Tensorflow can not do the correct prediction.

fan__wang
Beginner
396 Views
Hi 
I used the model optimizer to convert the tensorflow models , but I can not get the correct prediction. 
I converted the frozen models such as mobilenet_v1, mobilenet_v2, resnet50, but the prediction is totally wrong.
Can you explain the is there something wrong? 
 
I used the command lines such as follows:
 
convert_tool=/opt/intel/computer_vision_sdk_2018.2.319/deployment_tools/model_optimizer/mo_tf.py
tf_model_dir=/home/xxx/ml_work/dnn-models/tensorflow
python $convert_tool --input_model mobilenet_v1_1.0_224_frozen.pb --input_shape [1,224,224,3] --model_name mobilenet_v1 --output_dir mobilenet_v2
I use classification_sample.py , 
 
classification=/opt/intel/computer_vision_sdk_2018.2.319/inference_engine/samples/python_samples/classification_sample.py
python3 $classification -m ./mobilenet_v1.xml -d GPU -i cat.png. 
Compared with the output results of tensotflow results, the output tensor is different. 
the result is something like follows, but the exapact result is #283, a tiger cat. not 928 
 
928 1.0000000 label #928
336 0.0000000 label #336
168 0.0000000 label #168
99 0.0000000 label #99
44 0.0000000 label #44
378 0.0000000 label #378
153 0.0000000 label #153
 
Thanks.
0 Kudos
1 Solution
Monique_J_Intel
Employee
396 Views

Hi Wang,

The problem here is that you don't have the normalization values that were used when training for the models so the results will be incorrect without you supplying those at the time that your run model optimizer with the --mean_values and --scale_values parameter. I've reproduced the incorrect result with the mobilenet V1 224x224 model case, classification sample, and a different cat picture and then I added --scale_values [255,255,255] to the model optimizer command line. Let me know if this helps.

We are looking to improve documentation by putting the normalization parameters(--mean_values and --scale values) in documentation so that you can render the correct results.

Kind Regards,

Monique Jones

View solution in original post

0 Kudos
3 Replies
Monique_J_Intel
Employee
397 Views

Hi Wang,

The problem here is that you don't have the normalization values that were used when training for the models so the results will be incorrect without you supplying those at the time that your run model optimizer with the --mean_values and --scale_values parameter. I've reproduced the incorrect result with the mobilenet V1 224x224 model case, classification sample, and a different cat picture and then I added --scale_values [255,255,255] to the model optimizer command line. Let me know if this helps.

We are looking to improve documentation by putting the normalization parameters(--mean_values and --scale values) in documentation so that you can render the correct results.

Kind Regards,

Monique Jones

0 Kudos
fan__wang
Beginner
396 Views
Hi Monique:
 
Thanks for your reply, I tried the mobilenet_v1 and mobilenet_v2 with --mean_values [255, 255, 255] and --scale_values [255, 255, 255], the models are able to do the correct prediction.
Given a picture, the converted model can recognize it correctly, but compared with the output array of Tensorflow model from which the model is converted from,  there is severe loss of accuracy. I am not sure if this is a problem?
 
 
This is the output of mobilenet_v1 converted from tensorflow by using model optimizer:
0.517834 #283  (cat, tiger cat)
0.154584 #286
0.100501 #282
0.042195 #464
0.030102 #288
0.014180 #264
.......
 
the follows is the output of mobilenet_v1 of tensorflow:
 
0.570151 #283  (cat, tiger cat)
0.201431 #282
0.076349 #286
0.016527 #264
0.016098 #288
0.014925 #279
0.014090 #464
.......
 
Thanks.
Fan
~
~
0 Kudos
Monique_J_Intel
Employee
396 Views

Hi Wang,

The loss of accuracy would be due to the normalization values not being exactly what the training normalization values are. This can be found usually in the published paper on the model, in the model zoo, or comments of the source code of the model. You can also play with the values as well.

Kind Regards,

Monique Jones

0 Kudos
Reply