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.8k stars 965 forks source link

Getting ValueError: axes don't match array #934

Open massanf opened 2 years ago

massanf commented 2 years ago

Platform (like ubuntu 16.04/win10): Ubuntu 22.04 LTS

Python version: conda 4.13.0 Python 3.10.4

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

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

Pre-trained model path (webpath or webdisk path): https://github.com/henzler/single-image-tomography

Running scripts: mmconvert -sf caffe -in deploy.prototxt -iw hourglass256x128x128_iter_150000.caffemodel -df tensorflow -om caffe

I want to run this model on my comptuer. I'm trying to convert it from Caffe to Tensorflow, but I'm having some difficulty in doing it. I really don't know what I'm doing or where I'm doing things wrong and I've been stuck here for hours. I would really be glad if someone could help.

I'm currently getting this error:

------------------------------------------------------------
    WARNING: PyCaffe not found!
    Falling back to a pure protocol buffer implementation.
    * Conversions will be drastically slower.
    * This backend is UNTESTED!
------------------------------------------------------------

Warning: parameters not reshaped for node: [BatchNorm] bn_conv1_b
Warning: parameters not reshaped for node: [BatchNorm] bn1_branch1
Warning: parameters not reshaped for node: [BatchNorm] bn1_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bn1_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bn1_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bn4_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bn4_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bn4_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bn5_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bn5_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bn5_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bn6_branch1
Warning: parameters not reshaped for node: [BatchNorm] bn6_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bn6_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bn6_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low1_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low1_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low1_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low2_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low2_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low2_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low5_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low5_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low5_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low1_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low1_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low1_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low2_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low2_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low2_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low5_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low5_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low5_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low1_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low1_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low1_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low2_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low2_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low2_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low5_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low5_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low5_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low1_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low1_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low1_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low2_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low2_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low2_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low5_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low5_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low5_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low6_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low6_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low6_branch2c
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low7_branch2a
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low7_branch2b
Warning: parameters not reshaped for node: [BatchNorm] bnhg1_low6_low6_low6_low7_branch2c
Traceback (most recent call last):
  File "/home/mfujita/anaconda3/envs/mmdnn/bin/mmconvert", line 8, in <module>
    sys.exit(_main())
  File "/home/mfujita/anaconda3/envs/mmdnn/lib/python3.10/site-packages/mmdnn/conversion/_script/convert.py", line 102, in _main
    ret = convertToIR._convert(ir_args)
  File "/home/mfujita/anaconda3/envs/mmdnn/lib/python3.10/site-packages/mmdnn/conversion/_script/convertToIR.py", line 16, in _convert
    transformer = CaffeTransformer(args.network, args.weights, "tensorflow", inputshape[0], phase = args.caffePhase)
  File "/home/mfujita/anaconda3/envs/mmdnn/lib/python3.10/site-packages/mmdnn/conversion/caffe/transformer.py", line 336, in __init__
    graph = graph.transformed([DataReshaper({ # Reshape the parameters to TensorFlow's ordering
  File "/home/mfujita/anaconda3/envs/mmdnn/lib/python3.10/site-packages/mmdnn/conversion/caffe/graph.py", line 287, in transformed
    graph = transformer(graph)
  File "/home/mfujita/anaconda3/envs/mmdnn/lib/python3.10/site-packages/mmdnn/conversion/caffe/transformer.py", line 151, in __call__
    node.reshaped_data = weights.transpose(transpose_order)
ValueError: axes don't match array