Forums - snpe-tensorflow-to-dlc conversion error for mobilenet ssd model

7 posts / 0 new
Last post
snpe-tensorflow-to-dlc conversion error for mobilenet ssd model
matsamouli
Join Date: 13 Jun 21
Posts: 2
Posted: Wed, 2021-07-14 20:26

Hi all,

I am trying to convert my mobilenet ssd model trained on my own dataset using snpe-tensorflow-to-dlc tool. I have encountered errors regarding wrong input and output nodes for my model. I have tried the mobilenet ssd conversion topic present in snpe topic but got the same error. How to figure out the input and output nodes of my model and What are the parameters i have to set to convert to dlc successfully. Thank You in advance.

  • Up0
  • Down0
achalhoub
Join Date: 12 May 21
Posts: 6
Posted: Thu, 2021-07-15 06:36

Hello matsamouli,

If you're using TensorFlow 2.X, you can used the following command to inspect the inputs/outputs of your SavedModel: saved_model_cli show --all --dir 'path to saved_model directory'

 

For TensorFlow 1.X, you can inspect your frozen graph using summarize_graph (https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/gr...)

Typically, the input node for a TF2 SavedModel is input_tensor and the output nodes are detection_boxes, detection_scores, detection_classes, num_detections. Those are the arguments used with snpe-tensorflow-to-dlc.

 

I hope this is helpful.

Best,

Ahmad

 

  • Up0
  • Down0
matsamouli
Join Date: 13 Jun 21
Posts: 2
Posted: Mon, 2021-07-19 23:56

Hi ahmad,

 

Thanks for your reply. I am trying to convert trained ssd mobilenet v2 model.

 

command: snpe-tensorflow-to-dlc --input_network ./models/ssd_mobilenet/saved_model --input_dim input_tensor "1,320,320,3" --out_node detection_classes --out_node detection_boxes --out_node detection_scores --out_node num_detections --output_path mobilenet_ssd.dlc --show_unconsumed_nodes --debug

 

From the above command i get this error.

2021-07-20 11:56:44,635 - 405 - WARNING - ERROR_TF_FALLBACK_TO_ONDEMAND_EVALUATION: Unable to resolve operation output shapes in single pass. Using on-demand evaluation! 2021-07-20 11:56:44,637 - 188 - INFO - INFO_ALL_BUILDING_NETWORK: ============================================================== Building Network ==============================================================

2021-07-20 11:56:44,639 - 157 - DEBUG_1 - Added buffer named input_tensor:0 of shape [1, 320, 320, 3]

2021-07-20 11:57:32,557 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/TensorArrayUnstack/TensorListFromTensor) of type (TensorListFromTensor) is not supported by converter.

2021-07-20 11:57:32,560 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/TensorArrayV2_2) of type (TensorListReserve) is not supported by converter.

2021-07-20 11:57:32,560 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/StopGradient_1) of type (StopGradient) is not supported by converter.

2021-07-20 11:57:32,560 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/TensorArrayV2Stack/TensorListStack) of type (TensorListStack) is not supported by converter.

2021-07-20 11:57:32,560 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/while) of type (StatelessWhile) is not supported by converter.

2021-07-20 11:57:32,560 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/StopGradient_2) of type (StopGradient) is not supported by converter.

2021-07-20 11:57:32,560 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/TensorArrayV2Stack_1/TensorListStack) of type (TensorListStack) is not supported by converter.

2021-07-20 11:57:32,560 - 193 - WARNING - WARNING_TF_OP_NOT_SUPPORTED: Operation (StatefulPartitionedCall/map/TensorArrayV2_1) of type (TensorListReserve) is not supported by converter.

2021-07-20 11:57:32,565 - 193 - WARNING - WARNING_TF_LAYER_NOT_CONSUMED: Layer (StatefulPartitionedCall/ssd_mobile_net_v2keras_feature_extractor/model/Conv1/Conv2D) of type (Convolution) is not consumed by converter.

2021-07-20 11:57:32,565 - 193 - WARNING - WARNING_TF_LAYER_NOT_CONSUMED: Layer (StatefulPartitionedCall/ssd_mobile_net_v2keras_feature_extractor/model/block_9_depthwise_relu/Relu6) of type (Relu6) is not consumed by converter.

2021-07-20 11:57:32,565 - 193 - WARNING - WARNING_TF_LAYER_NOT_CONSUMED: Layer (StatefulPartitionedCall/ssd_mobile_net_v2keras_feature_extractor/FeatureMaps/layer_19_2_Conv2d_3_3x3_s2_256_batchnorm/FusedBatchNormV3) of type (BatchNormalization) is not consumed by converter.

2021-07-20 11:57:32,565 - 193 - WARNING - WARNING_TF_LAYER_NOT_CONSUMED: Layer (StatefulPartitionedCall/ssd_mobile_net_v2keras_feature_extractor/model/block_15_depthwise_relu/Relu6) of type (Relu6) is not consumed by converter. . . . .

.

.

.

2021-07-20 11:57:32,594 - 193 - WARNING - Output node detection_classes, specified via command line, does not exist in graph.

2021-07-20 11:57:32,594 - 193 - WARNING - Output node detection_boxes, specified via command line, does not exist in graph.

2021-07-20 11:57:32,594 - 193 - WARNING - Output node detection_scores, specified via command line, does not exist in graph.

2021-07-20 11:57:32,595 - 193 - WARNING - Output node num_detections, specified via command line, does not exist in graph.

2021-07-20 11:57:32,595 - 183 - ERROR - Conversion FAILED! Traceback (most recent call last):

File "/home/mouli/snpe-sdk/snpe-1.51.0.2663/bin/x86_64-linux-clang/snpe-tensorflow-to-dlc",

line 71, in main() File "/home/mouli/snpe-sdk/snpe-1.51.0.2663/bin/x86_64-linux-clang/snpe-tensorflow-to-dlc",

line 67, in main raise e File "/home/mouli/snpe-sdk/snpe-1.51.0.2663/bin/x86_64-linux-clang/snpe-tensorflow-to-dlc",

line 56, in main optimized_graph = optimizer.optimize(ir_graph) File "/home/mouli/snpe-sdk/snpe-1.51.0.2663/lib/python/qti/aisw/converters/common/converter_ir/op_graph_optimizations.py", line 189, in optimize remove_disconnected_nodes(graph) File "/home/mouli/snpe-sdk/snpe-1.51.0.2663/lib/python/qti/aisw/converters/common/converter_ir/op_graph_optimizations.py", line 406, in remove_disconnected_nodes raise ValueError("After pruning disconnected nodes, this model is empty.")

ValueError: After pruning disconnected nodes, this model is empty. It shows TF_LAYER_NOT_CONSUMED error.

 

1) Is it due to the gpu support not available on my device or snpe doesn't support mobilenet v2 model for conversion.

 

Thanks in advance.

  • Up0
  • Down0
achalhoub
Join Date: 12 May 21
Posts: 6
Posted: Tue, 2021-07-20 05:07

Hello matsamouli,

I actually struggled with this same exact problem for a while but have just found a solution to it yesterday!

Please refer to this comment (https://github.com/tensorflow/models/issues/10120#issuecomment-881984975) for how to solve it.

Best,

Ahmad

  • Up0
  • Down0
SahilBandar
Join Date: 23 May 18
Posts: 37
Posted: Thu, 2021-08-12 03:47

Hello matsamouli,

If you are trying to use the ssd_mobilnetV2 model which is trained on Tensorflow 1.X. There you might face issue because of the old model of tensorflow. In order to fix the issue. Please follow the below steps.

 

  1. Downlaod the ssd_mobilenetv2_2 model from the link given: https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2
  2. Please do use of this model for your transfer learning, train the model and save it back as saved_model format.
  3. Make sure that you have installed tensorflow 2.2 and above,
  4. Make sure that you have sourced the envsetup.sh with the latest tensorflow path in order to convert the model.
  5. Now run the command given below to convert the model in DLC format.
    snpe-tensorflow-to-dlc --input_network <PATH_TO_THE_SAVED_MODEL_OF_TF> -d input_tensor 1,320,320,3 --out_node num_detections --out_node detection_boxes --out_node detection_classes --out_node detection_scores -o <MODEL_SAVEPATH.dlc>
  6. NOTE: input node name is input_tensor.

Environment Setup:

Tensorflow 2.3.1
python 3.6
SNPE 1.51.x
Ubuntu 18.04

Hope this will resolve your issue.

Regards,
Sahil Bandar

  • Up0
  • Down0
shanghui_eml
Join Date: 13 Oct 21
Posts: 6
Posted: Thu, 2021-10-14 03:07

I also encountered the same problem, but I don't understand the solution you said. Can you explain it in more detail? thank you very much.

SNPE version=1.52

TensorFlow=1.15

  • Up0
  • Down0
shanghui_eml
Join Date: 13 Oct 21
Posts: 6
Posted: Thu, 2021-10-14 06:01

Hi, matsamouli

Your model input_name is "Preprocessor/sub" not "image_tensor".

My  code is:

snpe-tensorflow-to-dlc \
    --input_dim Preprocessor/sub 1,300,300,3 \
    --input_network xxx.pb
    --out_node num_detections \
    --out_node detection_classes \
    --out_node detection_boxes \
    --out_node detection_scores \
    --output_path xxx.dlc \
    --show_unconsumed_nodes \
    --debug
 
May this can help you.
  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.