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.
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
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.
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
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.
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
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
Hi, matsamouli
Your model input_name is "Preprocessor/sub" not "image_tensor".
My code is: