MarcBS / keras

Keras' fork with several new functionalities. Caffe2Keras converter, multimodal layers, etc.
https://github.com/MarcBS/keras
Other
225 stars 58 forks source link

Error converting Places365 caffe models to keras #28

Open tonizzz opened 7 years ago

tonizzz commented 7 years ago

Hi, I'm trying to convert the pre-trained model Places 365 VGG (https://github.com/metalbubble/places365) model but I'm getting the error below.

Do you think the error is related to the converter or to the model? is it something that might be fixed or workarounded somehow? thanks

python -m  caffe2keras.py -load_path '/tmp/vgg/' -prototxt 'deploy_vgg16_places365.prototxt' -caffemodel 'vgg16_places365.caffemodel'
Using Theano backend.
Converting model...
CREATING MODEL
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 101, in _get_module_details
    loader = get_loader(mod_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
    return find_loader(fullname)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader
    for importer in iter_importers(fullname):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers
    __import__(pkg)
  File "/Users/tonizornoza/projects/misc/keras/keras/caffe/caffe2keras.py", line 45, in <module>
    main(args)
  File "/Users/tonizornoza/projects/misc/keras/keras/caffe/caffe2keras.py", line 34, in main
    model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
  File "keras/caffe/convert.py", line 43, in caffe_to_keras
    debug)
  File "keras/caffe/convert.py", line 202, in create_model
    input_layers = Flatten(name=name + '_flatten')(input_layers)
  File "keras/engine/topology.py", line 569, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "keras/engine/topology.py", line 632, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "keras/engine/topology.py", line 168, in create_node
    output_shapes = to_list(outbound_layer.get_output_shape_for(input_shapes[0]))
  File "keras/layers/core.py", line 479, in get_output_shape_for
    '(got ' + str(input_shape[1:]) + '. '
ValueError: The shape of the input to "Flatten" is not fully defined (got (0, 7, 512). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.
nabilasan commented 7 years ago

hello, i found this error when converting Places 250 CNN

File "caffe2keras.py", line 43, in main(args) File "caffe2keras.py", line 32, in main model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug) File "/home/nabila/keras/keras/caffe/convert.py", line 64, in caffe_to_keras load_weights(model, weights) File "/home/nabila/keras/keras/caffe/convert.py", line 455, in load_weights model.get_layer(layer.name).set_weights(weights[layer.name]) File "/home/nabila/keras/keras/engine/topology.py", line 966, in set_weights str(weights)[:50] + '...') ValueError: You called set_weights(weights) on layer "conv1_1" with a weight list of length 2, but the layer was expecting 0 weights. Provided weights: [array([[[[ -6.61635473e-02, -6.69440255e-02, -2...