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.
6498 Discussions

Custom DenseNet image classifier conversion problem

msolmaz
Employee
1,409 Views

I have used transfer learning and trained a classifier in Tensorflow 2. I am able to run inference using TF easily. I am having hard time converting to Openvino format using Model Optimizer. Specifically, I am not satisfying the input/output node names. Please also see the attached image from model.summary()

using CLI, here are the commands and error messages I receive:

command: python mo.py --saved_model_dir="BestModel\model" --input_shape=[1,300,300,1] --mean_values=[255,255,255] --scale_values=[-255,-255,-255] --data_type=FP32 --output_dir="\openvino_model" --log_level=ERROR

error message: [ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.front.user_data_repack.UserDataRepack'>): Original placeholders: 'serving_default_InputLayer, saver_filename'. Freezing was requested for ''. --input_shape was provided without --input. Can not deduce which node shape to override

 

command: python mo.py --saved_model_dir="BestModel\model" --input="InputLayer" -b=1 --output="dense_3" --mean_values=[255,255,255] --scale_values=[-255,-255,-255] --data_type=FP32 --output_dir="\openvino_model" --log_level=ERROR

error message: [ FRAMEWORK ERROR ] Cannot load input model: dense_3 is not in graph

 

command: python mo.py --saved_model_dir="BestModel\model" --input="InputLayer" -b=1 --mean_values=[255,255,255] --scale_values=[-255,-255,-255] --data_type=FP32 --output_dir="\openvino_model" --log_level=ERROR

error message: [ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.front.user_data_repack.UserDataRepack'>): No node with name InputLayer

 

I am missing something but I am not able to see anything from documentation. 

Labels (1)
0 Kudos
1 Solution
msolmaz
Employee
1,373 Views

I am using transfer learning and DenseNet architecture, no custom layers so far.

I used an earlier version of TF (2.4) and skipped the mean and scale values, the conversion worked. I can always scale images before sending them to inferencing.

View solution in original post

6 Replies
msolmaz
Employee
1,401 Views

UPDATE:

I used an earlier version of TF (2.4) and the Model Optimizer went further.  But the problem statement changed: I believe the negative Scale values is not available to use with MO. Here is the error code:

function_optimizer: Graph size after: 2345 nodes (1730), 2402 edges (1787), time = 96.03ms.
function_optimizer: function_optimizer did nothing. time = 2.464ms.

[ ERROR ] -------------------------------------------------
[ ERROR ] ----------------- INTERNAL ERROR ----------------
[ ERROR ] Unexpected exception happened.
[ ERROR ] Please contact Model Optimizer developers and forward the following information:
[ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID (<class 'extensions.middle.AddMeanScaleValues.AddMeanScaleValues'>)":
[ ERROR ] Traceback (most recent call last):
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 276, in apply_transform
replacer.find_and_replace_pattern(graph)
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\extensions\middle\AddMeanScaleValues.py", line 123, in find_and_replace_pattern
AddMeanScaleValues.apply_scale(graph, input_node, node_mean_scale_values)
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\extensions\middle\AddMeanScaleValues.py", line 66, in apply_scale
AddMeanScaleValues.insert_pre_processing(graph, input_node, node_mean_scale_values, preprocessing_name='scale')
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\extensions\middle\AddMeanScaleValues.py", line 45, in insert_pre_processing
assert value.size == input_node.shape[features_dim_idx] or value.size == 1
AssertionError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\main.py", line 394, in main
ret_code = driver(argv)
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\main.py", line 356, in driver
ret_res = emit_ir(prepare_ir(argv), argv)
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\main.py", line 252, in prepare_ir
graph = unified_pipeline(argv)
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\pipeline\unified.py", line 17, in unified_pipeline
class_registration.ClassType.BACK_REPLACER
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 328, in apply_replacements
apply_replacements_list(graph, replacers_order)
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 318, in apply_replacements_list
num_transforms=len(replacers_order))
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\utils\logger.py", line 111, in wrapper
function(*args, **kwargs)
File "C:\Program Files (x86)\Intel\openvino_2021.4.582\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 306, in apply_transform
)) from err
Exception: Exception occurred during running replacer "REPLACEMENT_ID (<class 'extensions.middle.AddMeanScaleValues.AddMeanScaleValues'>)":

[ ERROR ] ---------------- END OF BUG REPORT --------------
[ ERROR ] -------------------------------------------------

0 Kudos
Iffa_Intel
Moderator
1,386 Views

Greetings,


first and foremost, may I know which topology are you using for this Tensorflow model?

Did you implement any custom layer to this model?

Please help to provide your model files for validation purposes (if possible).

Plus, your conversion commands and inferencing commands, etc.


Sincerely,

Iffa


0 Kudos
msolmaz
Employee
1,374 Views

I am using transfer learning and DenseNet architecture, no custom layers so far.

I used an earlier version of TF (2.4) and skipped the mean and scale values, the conversion worked. I can always scale images before sending them to inferencing.

Iffa_Intel
Moderator
1,363 Views

Hi,


did you manage to solve this issue or did you accidentally press reply that as a solution?

If you did solve it, I'll proceed to close this thread.


If not, please help to provide the information I requested before, especially model files.



Sincerely,

Iffa


0 Kudos
msolmaz
Employee
1,352 Views

My solution was not to use mean and scale values, and converting back to TF v2.4. So yes, it was resolved on its own.

0 Kudos
Iffa_Intel
Moderator
1,342 Views

Thanks for clarifying!


Intel will no longer monitor this thread since this issue has been resolved. If you need any additional information from Intel, please submit a new question. 


Sincerely,

Iffa


0 Kudos
Reply