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.

EfficientDet D0

mfoglio
New Contributor I
1,443 Views

I am trying to convert an EfficientDet_D0 model to OpenVINO.  

python3 /opt/intel/openvino_2021.3.394/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name efficientdet-d0-tf
python3 /opt/intel/openvino_2021.3.394/deployment_tools/open_model_zoo/tools/downloader/converter.py \
--name efficientdet-d0-tf --mo /opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer

The commands lead to the error:

2021-04-07 23:07:09.517831: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
Traceback (most recent call last):
File "/home/ubuntu/public/efficientdet-d0-tf/model/model_inspect.py", line 29, in <module>
import inference
File "/home/ubuntu/public/efficientdet-d0-tf/model/inference.py", line 30, in <module>
from keras import efficientdet_keras
ImportError: cannot import name 'efficientdet_keras'
Traceback (most recent call last):
File "/opt/intel/openvino_2021.3.394/deployment_tools/open_model_zoo/models/public/efficientdet-d0-tf/pre-convert.py", line 38, in <module>
main()
File "/opt/intel/openvino_2021.3.394/deployment_tools/open_model_zoo/models/public/efficientdet-d0-tf/pre-convert.py", line 35, in main
], check=True)
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '--', '/home/ubuntu/public/efficientdet-d0-tf/model/model_inspect.py', '--runmode=saved_model', '--model_name=efficientdet-d0', '--ckpt_path=/home/ubuntu/public/efficientdet-d0-tf/efficientdet-d0', '--saved_model_dir=/home/ubuntu/public/efficientdet-d0-tf/efficientdet-d0_saved_model']' returned non-zero exit status 1.

FAILED:
efficientdet-d0-tf

 

I also tried to convert the model following your guide

wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d0.tar.gz
tar zxvf efficientdet-d0.tar.gz

python3 model_inspect.py --runmode=saved_model --model_name=efficientdet-d0 --ckpt_path=efficientdet-d0 --saved_model_dir=savedmodeldir

export MO_ROOT=/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/

export IMAGE_SIZE=512

python3 $MO_ROOT/mo.py \
--input_model savedmodeldir/efficientdet-d0_frozen.pb \
--transformations_config $MO_ROOT/extensions/front/tf/automl_efficientdet.json \
--input_shape [1,$IMAGE_SIZE,$IMAGE_SIZE,3] \
--reverse_input_channels

 but this leads to the following error:

Model Optimizer arguments:
Common parameters:
- Path to the Input Model: /home/ubuntu/automl/efficientdet/savedmodeldir/efficientdet-d0_frozen.pb
- Path for generated IR: /home/ubuntu/automl/efficientdet/.
- IR output name: efficientdet-d0_frozen
- Log level: ERROR
- Batch: Not specified, inherited from the model
- Input layers: Not specified, inherited from the model
- Output layers: Not specified, inherited from the model
- Input shapes: [1,512,512,3]
- Mean values: Not specified
- Scale values: Not specified
- Scale factor: Not specified
- Precision of IR: FP32
- Enable fusing: True
- Enable grouped convolutions fusing: True
- Move mean values to preprocess section: None
- Reverse input channels: True
TensorFlow specific parameters:
- Input model in text protobuf format: False
- Path to model dump for TensorBoard: None
- List of shared libraries with TensorFlow custom layers implementation: None
- Update the configuration file with input/output node names: None
- Use configuration file used to generate the model with Object Detection API: None
- Use the config file: None
[ WARNING ] Failed to import Inference Engine Python API in: /opt/intel/openvino_2021.3.394/python/python3.6
[ WARNING ] /opt/intel/openvino_2021.3.394/python/python3.6/openvino/inference_engine/ie_api.so: undefined symbol: _ZNK15InferenceEngine10CNNNetwork9serializeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_
[ WARNING ] Failed to import Inference Engine Python API in: /opt/intel/openvino_2021.3.394/python/python3.6
[ WARNING ] /opt/intel/openvino_2021.3.394/python/python3.6/openvino/inference_engine/ie_api.so: undefined symbol: _ZNK15InferenceEngine10CNNNetwork9serializeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_
[ WARNING ] Could not find the Inference Engine Python API. At this moment, the Inference Engine dependency is not required, but will be required in future releases.
[ WARNING ] Consider building the Inference Engine Python API from sources or try to install OpenVINO (TM) Toolkit using "install_prerequisites.sh"
Model Optimizer version: 2021.3.0-2787-60059f2c755-releases/2021/3
2021-04-07 23:12:40.597702: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
[ 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 "AutomlEfficientDet (<class 'extensions.front.tf.AutomlEfficientDet.EfficientDet'>)": The node with name "convert_image" is not found in the graph. This node should provide scaled image output and is specified in the json file.
[ ERROR ] Traceback (most recent call last):
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 290, in apply_transform
for_graph_and_each_sub_graph_recursively(graph, replacer.find_and_replace_pattern)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/middle/pattern_match.py", line 60, in for_graph_and_each_sub_graph_recursively
for_each_sub_graph_recursively(graph, func)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/middle/pattern_match.py", line 54, in for_each_sub_graph_recursively
for_each_sub_graph(graph, recursive_helper)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/middle/pattern_match.py", line 39, in for_each_sub_graph
func(node[sub_graph_name])
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/middle/pattern_match.py", line 50, in recursive_helper
func(sub_graph)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/front/tf/replacement.py", line 48, in find_and_replace_pattern
self.transform_graph(graph, desc._replacement_desc['custom_attributes'])
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/extensions/front/tf/AutomlEfficientDet.py", line 74, in transform_graph
' in the json file.'.format(preprocessing_input_node_id)
AssertionError: The node with name "convert_image" is not found in the graph. This node should provide scaled image output and is specified in the json file.

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

Traceback (most recent call last):
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/main.py", line 345, in main
ret_code = driver(argv)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/main.py", line 309, in driver
ret_res = emit_ir(prepare_ir(argv), argv)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/main.py", line 252, in prepare_ir
graph = unified_pipeline(argv)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/pipeline/unified.py", line 29, in unified_pipeline
class_registration.ClassType.BACK_REPLACER
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 340, in apply_replacements
apply_replacements_list(graph, replacers_order)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 330, in apply_replacements_list
num_transforms=len(replacers_order))
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/utils/logger.py", line 124, in wrapper
function(*args, **kwargs)
File "/opt/intel/openvino_2021.3.394/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 318, in apply_transform
)) from err
Exception: Exception occurred during running replacer "AutomlEfficientDet (<class 'extensions.front.tf.AutomlEfficientDet.EfficientDet'>)": The node with name "convert_image" is not found in the graph. This node should provide scaled image output and is specified in the json file.

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

 

0 Kudos
5 Replies
mfoglio
New Contributor I
1,435 Views

Second method seems to work using


python3 $MO_ROOT/mo.py \
--input_shape=[1,512,512,3] \
--input=image_arrays \
--reverse_input_channels \
--input_model savedmodeldir/efficientdet-d0_frozen.pb \
--transformations_config $MO_ROOT/extensions/front/tf/automl_efficientdet.json

This is taken from https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/efficientdet-d0-tf/model.yml#L113 .

Is there a way to use the model.yml directly to generate the model?

0 Kudos
IntelSupport
Moderator
1,410 Views

Hi mfoglio,

Greetings to you.

I am glad that you can configure the OpenVINO Model Optimizer. Other than using the converter.py you also can convert your model into the IR representation using the Model Optimizer script. Hence, you can use a specific script to convert the Tensorflow Model into the IR which mo_tf.py.

 

Furthermore, I have tested the same workaround as you using the converter.py and getting the same issue. I will discuss this with the developer and update you with the information soon. It might be some configuration issues that are not compatible between the specific model and the converter.

 

Meanwhile, the .yml file cannot be used directly to generate the model. Only Model Optimizer or converter.py can be used.

 

Regards,

Aznie

 

0 Kudos
mfoglio
New Contributor I
1,393 Views

Thank you. Also, the second method actually generates a model that returns all zeros. I am not sure if I am using it the wrong way. More here: https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Model-returns-all-zeroes/m-p/1272176#M23454

0 Kudos
mfoglio
New Contributor I
1,391 Views

Problem solved: there is no need to normalize the image by dividing by 255.

0 Kudos
IntelSupport
Moderator
1,377 Views

Hi mgoglio,

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


Regards,

Aznie


0 Kudos
Reply