microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.79k stars 964 forks source link

UnboundLocalError: local variable 'x' referenced before assignment #671

Open moonjiaoer opened 5 years ago

moonjiaoer commented 5 years ago

Platform (like ubuntu 16.04/win10):ubuntu 18.04

Python version:3.6.7

Source framework with version (like Tensorflow 1.4.1 with GPU):Tensorflow 1.13.1

Destination framework with version (like CNTK 2.3 with GPU):

Pre-trained model path (webpath or webdisk path):

Running scripts: WARNING:tensorflow:From /home/wangyuejiao/.local/lib/python3.6/site-packages/tensorflow/python/tools/strip_unused_lib.py:86: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version. Instructions for updating: Use tf.compat.v1.graph_util.extract_sub_graph Traceback (most recent call last): File "/media/wangyuejiao/DATA/MMdnn-master/mmdnn/conversion/_script/convert.py", line 123, in _main() File "/media/wangyuejiao/DATA/MMdnn-master/mmdnn/conversion/_script/convert.py", line 102, in _main ret = convertToIR._convert(ir_args) File "/media/wangyuejiao/DATA/MMdnn-master/mmdnn/conversion/_script/convertToIR.py", line 59, in _convert parser = TensorflowParser2(args.weights, inputshape, args.inNodeName, args.dstNodeName) File "/media/wangyuejiao/DATA/MMdnn-master/mmdnn/conversion/tensorflow/tensorflow_frozenparser.py", line 157, in init input_map[in_nodes[i] + ':0'] = x UnboundLocalError: local variable 'x' referenced before assignment

moonjiaoer commented 5 years ago

@rainLiuplus Thx for your help,It works! but I got new issue here:

"Tensorflow has not supported operator [IteratorFromStringHandleV2] with name [superpoint/IteratorFromStringHandleV2]. "

I thought it means the MMdnn can not support this op when convert the pb file to the caffe model. Do you have any suggestion for this issue? Thanks!

rainLiuplus commented 5 years ago

Hi @moonjiaoer Seems it is an operator related to data processing. But MMdnn does not support such ops for that they vary from framework to framework. Thus just converting the network architecture may skip this issue. Thanks!

moonjiaoer commented 5 years ago

Hi @rainLiuplus Thx for your reply. but I don't know how to skip this op? Do you mean I can modify the MMdnn code? Or I need to generate a new pb without this op?

rainLiuplus commented 5 years ago

@moonjiaoer, just skip them via specifying input and output names like --inNodeName your_input --dstNodeName your_dst

moonjiaoer commented 5 years ago

2019-06-04 19-16-55 的屏幕截图 2019-06-04 19-17-43 的屏幕截图 2019-06-04 19-17-59 的屏幕截图

Hi @rainLiuplus I tried your method it's good but still can't solve my issue. the figure I uploaded is part of my network. The new issue is quantification. You can see the node which named "FakeQuantWithMinMaxVars" that's the new problem. This node will set in the whole network for much times I think it's hard to skip. Could I modified the MMdnn code to skip this node?

rainLiuplus commented 5 years ago

Hi @moonjiaoer, could you upload this model then I can help you add this op? Thanks

moonjiaoer commented 5 years ago

Hi @rainLiuplus Thanks for your help. could you send me your email address? the model is nearly 78mb.

rainLiuplus commented 5 years ago

@moonjiaoer, The company mailbox can't receive such a large attachment, and maybe it will be more convenient to upload it to a public cloud.

zxp771 commented 5 years ago

Hi @rainLiuplus Sorry for the late reply. Here is the link :https://drive.google.com/open?id=1NiGi8O9VyAdj7mWYdzT8E210UKXjjAAz BTW this is my colleague‘s account.

rainLiuplus commented 5 years ago

Hi @zxp771, may I ask the complete conversion script? Thanks

zxp771 commented 5 years ago

Hi @rainLiuplus This network is SuperPoint which based on tensorflow, We want to convert the tensorflow's pb file to the caffe model.

Thx for your help and patience.

moonjiaoer commented 5 years ago

Hi @rainLiuplus

Sorry to disturb. Have you tried to convert the model we sent to you?

Thx

moonjiaoer commented 5 years ago

Hi @rainLiuplus

Do you have any update for this issue?

rainLiuplus commented 5 years ago

Hi @moonjiaoer, sorry, I am busy recently. For this issue, the key problem is that the quant op has no counterpart in Caffe. Thus to solve this issue need to register a new quant op in Caffe.
I will add the support of this op into the work plan. Or maybe you could try to add it first? For guidance on how to add operators, please refer to this. Thanks!

zxp771 commented 5 years ago

Hi @rainLiuplus

Thx for your reply. We'll try it first and hope you can bring some good news soon

Thx