MMdnn icon indicating copy to clipboard operation
MMdnn copied to clipboard

Can't convert Googlenet from MINC database

Open aespielberg opened this issue 6 years ago • 8 comments

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?

aespielberg avatar Aug 26 '18 19:08 aespielberg

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

namizzz avatar Aug 27 '18 04:08 namizzz

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 [email protected] 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 .

aespielberg avatar Aug 27 '18 04:08 aespielberg

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

namizzz avatar Aug 27 '18 04:08 namizzz

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 [email protected] 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 .

aespielberg avatar Aug 27 '18 04:08 aespielberg

Hi @aespielberg , It's inputShape not inputshape

namizzz avatar Aug 27 '18 04:08 namizzz

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 ,

aespielberg avatar Sep 02 '18 03:09 aespielberg

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

namizzz avatar Sep 07 '18 05:09 namizzz

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

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

HoKyo avatar Aug 30 '22 13:08 HoKyo