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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when converting VGG16_SOD from caffe to tensorflow

seanchung2 opened this issue · comments

Hi,

Here's the model: link

Again this happens when trying to convert from IR to tensorflow, but with different error code:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 68, in <module>
    tester = TestTF()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 16, in __init__
    super(TestTF, self).__init__()
  File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/examples/imagenet_test.py", line 119, in __init__
    self.MainModel = __import__(self.args.n)
  File "VGG16_SOD.py", line 81
    fc8-SOD100_0    = tf.contrib.layers.flatten(relu7)
SyntaxError: can't assign to operator

Can you please check it out?

Thank you.

Hi @seanchung2.

Fixed. Please update to newest code. Thanks very much.

Command:

$ python -m mmdnn.conversion._script.convertToIR -f caffe -d kit_imagenet -n deploy.prototxt -w VGG16_SOD_finetune.caffemodel

$ python -m mmdnn.conversion._script.IRToCode -f tensorflow -n kit_imagenet.pb -d kit_imagenet.py -w kit_imagenet.npy

$ python -m mmdnn.conversion.examples.tensorflow.imagenet_test -n kit_imagenet.py -w kit_imagenet.npy --dump ./vgg19_sod.ckpt

Tensorflow file is saved as [./vgg19_sod.ckpt], generated by [kit_imagenet.py] and [kit_imagenet.npy].

On running the last command I get this error

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/sid/MMdnn/mmdnn/conversion/examples/tensorflow/imagenet_test.py", line 106, in <module>
    raise ValueError("Need to provide the model type of Tensorflow model.")
ValueError: Need to provide the model type of Tensorflow model.

Hi @Siddhant24
Now the way of dumping tensorflow model updates. You need to add "--dump_tag SERVING or TRAINING." .Here is README

@namizzz Yes that fixed the error. But instead of the messageTensorflow file is saved as [./vgg19_sod.ckpt], generated by [kit_imagenet.py] and [kit_imagenet.npy]., I get the following message Tensorflow file is saved as [b'vgg19_sod.ckpt/saved_model.pb'], generated by [kit_imagenet.py] and [kit_imagenet.npy].

commented

i cannot solve the error, and it is not solved at any of issues
File "c:\users\mba\anaconda3\lib\site-packages\mmdnn\conversion_script\conver
tToIR.py", line 89, in _convert
from mmdnn.conversion.pytorch.pytorch_parser import PytorchParser
File "c:\users\mba\anaconda3\lib\site-packages\mmdnn\conversion\pytorch\pytorc
h_parser.py", line 12, in
from mmdnn.conversion.pytorch.pytorch_graph import PytorchGraph
File "c:\users\mba\anaconda3\lib\site-packages\mmdnn\conversion\pytorch\pytorc
h_graph.py", line 12, in
from torch.jit import _unique_state_dict
ImportError: cannot import name '_unique_state_dict'