Forums - Converting Tensorflow based SqueezeDet to DLC

7 posts / 0 new
Last post
Converting Tensorflow based SqueezeDet to DLC
pratesh_reddy
Join Date: 16 Jul 18
Posts: 3
Posted: Tue, 2018-07-24 22:56

Hi,

I am trying to convert the TF based squeezeDet (https://github.com/BichenWuUCB/squeezeDet) into DLC format.

Was able to freeze the graph into .pb format. As I am not sure if SNPE supports the extra interpretation layers in SqueezeDet, I have frozen the graph only till the conv12 layer.

While freezing I'm giving following as output nodes:

conv12/kernels,conv12/kernels/read,conv12/biases,conv12/biases/read,conv12/convolution,conv12/bias_add

 

The frozen .pb file is at this link: https://drive.google.com/open?id=1B2w4swFgx0yFgcYvN488V7amghN8fwSL

The output of running TF's summarize_graph tool on the same .pb file is at : https://drive.google.com/open?id=1Q4KZ97ER4XiAMGIxCEjdvNpZHRfCxfvq

The list of nodes inside .pb file are saved in a txt file: https://drive.google.com/open?id=1BZpYxa3T1xGR8kfRGxBD4MIOyf4DeTpu

Now when I try to convert the above .pb file to DLC using

snpe-tensorflow-to-dlc --graph dlc/0till_conv12/frozen_graph.pb -i input_ph_node 520,924,3 --out_node conv12/kernels --out_node conv12/kernels/read --out_node conv12/biases --out_node conv12/biases/read --out_node conv12/convolution --out_node conv12/bias_add --dlc sqDet.dlc

I get following error:

WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (conv12/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (conv12/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire9/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (parallel_stack/ExpandDims) not consumed by converter: ExpandDims.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (parallel_stack/ParallelConcat) not consumed by converter: ParallelConcat.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire10/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (conv1/Relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (conv1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (pool1/MaxPool) not consumed by converter: MaxPool.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire11/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire2/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (pool5/MaxPool) not consumed by converter: MaxPool.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire3/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire6/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (pool3/MaxPool) not consumed by converter: MaxPool.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/expand3x3/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire7/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/expand1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/expand1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/expand1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire4/concat) not consumed by converter: ConcatV2.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/squeeze1x1/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/squeeze1x1/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/squeeze1x1/relu) not consumed by converter: Relu.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/expand3x3/convolution) not consumed by converter: Conv2D.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire5/expand3x3/bias_add) not consumed by converter: BiasAdd.
WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (fire8/expand3x3/relu) not consumed by converter: Relu.
ERROR - Conversion failed: ERROR_TF_OPERATION_NOT_MAPPED_TO_LAYER: Some operations in the Tensorflow graph were not resolved to a layer. You can use --allow_unconsumed_node
 Type your code in the box. To create a new line within the box use SHIFT + ENTER. 

Looks like the error is related to SNPE not being able to detect the conv2D,Relu etc layers and map them to its own suppoted layers.

If the try snpe-tensorflow-to-dlc with --allow_unconsumed_node then only the input layer is getting coverted to DLC leaving out all the other layers. The DLC with just input layer is at:  https://drive.google.com/open?id=12dgEKUdo6OsTOpNeaM0NX1NpQs5660QI

If I run snpe-dlc-info on the above DLC file, one can clearly see that only the input layer is getting frozen.

DLC info for /home/snpe-sdk/models/visteon_od/sqDet.dlc
Model Version: N/A
------------------------------------------------------------------------------------------------------------------
| Id | Name            | Type | Inputs          | Outputs         | Out Dims  | Parameters                       |
------------------------------------------------------------------------------------------------------------------
| 0  | input_ph_node:0 | data | input_ph_node:0 | input_ph_node:0 | 520x924x3 | input_preprocessing: passthrough |
|    |                 |      |                 |                 |           | input_type: default              |
Total parameters 0 (0 MB assuming single precision float)
Total MACs per inference: 0 (0%)
Converter command: snpe-tensorflow-to-dlc verbose=False out_node=['conv12/kernels', 'conv12/kernels/read', 'conv12/biases', 'conv12/biases/read', 'conv12/convolution', 'conv12/bias_add'] allow_unconsumed_nodes=True model_version=None input_dim=[['input_ph_node', '520,924,3']] in_type=None
DLC created with converter version: 1.15.0.0


 

Any help in finding out where I am going wrong. How do I make sure that SNPE detects the SqueezeDet layers.

Thanks.

 

*/
  • Up0
  • Down0
suriyalshorav15
Join Date: 31 Aug 18
Posts: 3
Posted: Mon, 2018-10-01 16:57

Hi Pratesh did you solved the problem of not converting the layers ?

  • Up0
  • Down0
rbgreenway
Join Date: 3 Dec 18
Posts: 1
Posted: Fri, 2018-12-07 09:51

Did you ever figure this out?  I'm getting the exact error stream from a very simple network I created with Keras/Tensorflow that is simply:

Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 122, 9, 128)       1024      
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 17, 9, 128)        0         
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 13, 9, 128)        82048     
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 2, 9, 128)         0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 2304)              0         
_________________________________________________________________
dropout_1 (Dropout)          (None, 2304)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 512)               1180160   
_________________________________________________________________
dense_2 (Dense)              (None, 6)                 3078      
=================================================================

Super simple.  Trains perfectly, but same behavior as you described when trying to convert to dlc. 

Please post any progress that you may have made, since Qualcomm support seems to have ignored your post.

 

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Fri, 2018-12-28 02:27
It was the same issue faced during the conversion.
The solution we found was to convert the TensorFlow based SqueezeDet model into Caffe Model and then convert it into the DLC format. 
 
Prerequisite: Please make sure the Caffe is installed and the Environment variable is set using following command:
user@user:~$ source <path_to_snpe_folder>/bin/envsetup.sh -c ~/caffe
 
To make it more simple, please download "squeezedet.caffemodel" and "squeezedet.prototxt" files.
 
Once downloaded, convert them using snpe-caffe-to-dlc command as given below –
user@user:~$ snpe-caffe-to-dlc -c squeezedet.prototxt -b squeezeDet.caffemodel -d squeezeDet.dlc
Once the conversion is success check the DLC file details using following command.
user@user:~$ snpe-dlc-info -i squeezeDet.dlc

 

  • Up0
  • Down0
suriyalshorav15
Join Date: 31 Aug 18
Posts: 3
Posted: Tue, 2019-01-08 11:16

Is it possible that networks other than sqeezenet will work the same way like you said the conversion to caffe model first and then .dlc ? Is this valid for all the model ? Please reply

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Tue, 2019-03-12 08:09

Yes, It is possible to convert one model to other framework based model. There are lots of tools available online for model conversion. MMDNN is one of the model conversion tool with which you can try out first.

  • Up0
  • Down0
dishita.mehtalia
Join Date: 23 Dec 19
Posts: 1
Posted: Tue, 2020-01-28 13:57

Can someone post the squeezedet.dlc files here 

  • 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.