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

Can't convert Googlenet from MINC database #376

Open aespielberg opened 6 years ago

aespielberg commented 6 years ago

Platform (like ubuntu 16.04/win10): Ubuntu 16.04

Python version: Anaconda Python 3.6 (Willing to use any)

Source framework with version (like Tensorflow 1.4.1 with GPU): Caffe 1.0

Destination framework with version (like CNTK 2.3 with GPU): Tensorflow 1.10.1 CPU

Pre-trained model path (webpath or webdisk path): MINC googlenet http://opensurfaces.cs.cornell.edu/publications/minc/

Running scripts: mmconvert -sf caffe -in minc-model/deploy-googlenet.prototxt -iw minc-model/googlenet.caffemodel -df tensorflow -om .

Gives error:

Traceback (most recent call last):
  File "/home/user/anaconda3/bin/mmconvert", line 11, in <module>
    sys.exit(_main())
  File "/home/user/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convert.py", line 102, in _main
    ret = convertToIR._convert(ir_args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 16, in _convert
    transformer = CaffeTransformer(args.network, args.weights, "tensorflow", inputshape[0], phase = args.caffePhase)
TypeError: 'NoneType' object is not subscriptable

Any idea as to why this would be?

namizzz commented 6 years ago

hi @aespielberg , you need to provide '--inputshape'

aespielberg commented 6 years ago

mmconvert -sf caffe -in minc-model/deploy-googlenet.prototxt -iw minc-model/googlenet.caffemodel -df tensorflow -om . --inputshape 10,3,244,244

gives the same error.

On Mon, Aug 27, 2018 at 12:32 AM namizzz notifications@github.com wrote:

hi @aespielberg https://github.com/aespielberg , you need to provide '--inputshape'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/MMdnn/issues/376#issuecomment-416111397, or mute the thread https://github.com/notifications/unsubscribe-auth/ADbqdOOOzIJcRm1wjMlREiXO0zeqHk1Wks5uU3ZEgaJpZM4WM6YN .

namizzz commented 6 years ago

Hi @aespielberg , you need to use --inputShape 224,224,3 or 3,244,244. Could your please copy the complete error here?

aespielberg commented 6 years ago

mmconvert -sf caffe -in minc-model/deploy-googlenet.prototxt -iw minc-model/googlenet.caffemodel -df tensorflow -om . --inputshape 3,244,244

Traceback (most recent call last): File "/home/aespielberg/anaconda3/bin/mmconvert", line 11, in sys.exit(_main()) File "/home/aespielberg/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convert.py", line 102, in _main ret = convertToIR._convert(ir_args) File "/home/aespielberg/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 16, in _convert transformer = CaffeTransformer(args.network, args.weights, "tensorflow", inputshape[0], phase = args.caffePhase) TypeError: 'NoneType' object is not subscriptable

On Mon, Aug 27, 2018 at 12:44 AM namizzz notifications@github.com wrote:

Hi @aespielberg https://github.com/aespielberg , you need to use --inputShape 224,224,3 or 3,244,244. Could your please copy the complete error here?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/MMdnn/issues/376#issuecomment-416112857, or mute the thread https://github.com/notifications/unsubscribe-auth/ADbqdNVysIO7nsIPFu_Qj67yFDWQhmN7ks5uU3lHgaJpZM4WM6YN .

namizzz commented 6 years ago

Hi @aespielberg , It's inputShape not inputshape

aespielberg commented 6 years ago

Fixing that creates the following error:

WARNING: Logging before InitGoogleLogging() is written to STDERR
I0901 20:33:58.149339  2084 net.cpp:51] Initializing net from parameters: 
state {
  phase: TEST
  level: 0
}
I0901 20:33:58.149395  2084 net.cpp:255] Network initialization done.
W0901 20:33:58.149574  2084 _caffe.cpp:139] DEPRECATION WARNING - deprecated use of Python interface
W0901 20:33:58.149597  2084 _caffe.cpp:140] Use this instead (with the named "weights" parameter):
W0901 20:33:58.149601  2084 _caffe.cpp:142] Net('minc-model/deploy-googlenet.prototxt', 1, weights='minc-model/minc-googlenet.caffemodel')
I0901 20:33:58.149633  2084 net.cpp:51] Initializing net from parameters: 
state {
  phase: TEST
  level: 0
}
I0901 20:33:58.149659  2084 net.cpp:255] Network initialization done.
Type                 Name                                          Param               Output
----------------------------------------------------------------------------------------------
IR network structure is saved as [cd66eeb3f0334fc1a02807267150e9e0.json].
IR network structure is saved as [cd66eeb3f0334fc1a02807267150e9e0.pb].
IR weights are saved as [cd66eeb3f0334fc1a02807267150e9e0.npy].
Parse file [cd66eeb3f0334fc1a02807267150e9e0.pb] with binary format successfully.
Target network code snippet is saved as [cd66eeb3f0334fc1a02807267150e9e0.py].
Traceback (most recent call last):
  File "/home/aespielberg/.local/bin/mmconvert", line 11, in <module>
    sys.exit(_main())
  File "/home/aespielberg/.local/lib/python3.6/site-packages/mmdnn/conversion/_script/convert.py", line 112, in _main
    dump_code(args.dstFramework, network_filename + '.py', temp_filename + '.npy', args.outputModel, args.dump_tag)
  File "/home/aespielberg/.local/lib/python3.6/site-packages/mmdnn/conversion/_script/dump_code.py", line 12, in dump_code
    MainModel = imp.load_source('MainModel', network_filepath + '.py')
  File "/usr/lib/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "cd66eeb3f0334fc1a02807267150e9e0.py", line 25
    return ,
namizzz commented 6 years ago

Hi @aespielberg , I have test the conversion in python2. It works. image

  File "cd66eeb3f0334fc1a02807267150e9e0.py", line 25
    return ,

It seems some problems in emitted code file because usually "return" shows in line 100+ . Could you please try the step-by-step conversion ? and paste the code file here for us to debug?

mmtoir -f caffe -w ./issue/minc-model/minc-googlenet.caffemodel -n ./issue/minc-model/deploy-googlenet.prototxt --inputShape 3,244,244 -d tensorflow_caffe_googlenet
mmtocode -f tensorflow -w tensorflow_caffe_googlenet.npy -n tensorflow_caffe_googlenet.pb -d tf_googlenet.py
HoKyo commented 2 years ago

Hi @aespielberg , I have test the conversion in python2. It works.

Hi @namizzz . Could you please share the converted tensorflow model?