Giter VIP home page Giter VIP logo

caffe_weight_converter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

caffe_weight_converter's Issues

AttributeError: module 'caffe' has no attribute 'Net'

Hi,

I tried running your code with the following specs:
Python 2.7
Windows 10 OS
Protobuf 2.5
and caffe framework for windows downloaded from https://github.com/BVLC/caffe/tree/windows and pasted the python folder with caffe module in my python 2.7/lib/site-packages. Upon running, I get the following error:

Traceback (most recent call last):
File "caffe_weight_converter.py", line 401, in
main(args)
File "caffe_weight_converter.py", line 368, in main
verbose=argv.verbose)
File "caffe_weight_converter.py", line 132, in convert_caffemodel_to_keras
verbose=False)
File "caffe_weight_converter.py", line 323, in convert_caffemodel_to_dict
net = caffe.Net(prototxt_filename, 1, weights=caffemodel_filename)
AttributeError: module 'caffe' has no attribute 'Net'

C:\Users\rubee\PycharmProjects\caffe_weight_converter-master>

Any help will be highly appreciated.

Thanks in advance

Convert convolutional layers from Caffe to Keras

Hi, I have successfully used your tool to convert a custom-trained ResNet101 model from Caffe to Keras 2.2.4 with Tensorflow 1.9 backend. However, it seems that the output of the first convolutional layer is slightly different, despite the weights being loaded correctly, the padding is apparently correct and the output maps have the same size. Both input images are in BGR order.

Do you have any insight as to whether this is normal or are there differences that cannot be 100% compensated?

Error-when converting a .caffemodel file to a Keras

Hello Pierluigiferrari and everyone,
I want to convert an FSSD.caffe model (COCO models - https://github.com/lzx1413/CAFFE_SSD/tree/fssd) to an HDF5 file (keras).
I use Python = 3.6.5, caffe =1.0, h5py = 2.7.1 which are installed by anaconda3
I follow your source code and here is code that I wrote:

from caffe_weight_converter import convert_caffemodel_to_keras, convert_caffemodel_to_dict
output_filename = './output'
prototxt_filename = './models/deploy.prototxt'
caffemodel_filename = './models/VGG_coco_SSD_300x300_iter_400000.caffemodel'
cm = convert_caffemodel_to_keras(output_filename,
prototxt_filename,
caffemodel_filename,
include_layers_without_weights=False,
include_unknown_layer_types=True,
keras_backend='tf',
verbose=True)
When running source code I got error:

[libprotobuf ERROR google/protobuf/text_format.cc:288] Error parsing text-format caffe.NetParameter: 814:14: Message type "caffe.LayerParameter" has no field named "norm_param".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0507 20:49:23.393383 25808 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /media/hieu/Data/Deep_leaning/Keras/convert_caffe_to_keras/caffe_weight_converter-master/models/deploy.prototxt
*** Check failure stack trace: ***

Please help me to solve this error
Thank you very much!

Code not running. How to fix this?

Hey! Thanks for providing the code. I have all the dependencies installed in my CPU but unfortunately I am unable to run your code for converting my caffemodel weights to .h5 file for using it in Keras. Kindly request you to help me out in resolving the error shown below. Your help is much appreciated!

Error:
rishis-mbp:caffe_weight_converter rishimadhok$ python2 caffe_weight_converter.py 'converted_weights' '/Users/rishimadhok/UCF101/train_val_video_jigsaw_newMVNlayer+xavier.prototxt' '/Users/rishimadhok/UCF101/N100_original_permute_iter_306000.caffemodel' --verbose
/usr/local/lib/python2.7/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
[libprotobuf ERROR google/protobuf/text_format.cc:288] Error parsing text-format caffe.NetParameter: 16:14: Message type "caffe.TransformationParameter" has no field named "hash_file".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0226 19:05:49.480474 2068673280 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /Users/rishimadhok/GATech/Visualization/ModelsForVisualization/UCF101/train_val_video_jigsaw_newMVNlayer+xavier.prototxt
*** Check failure stack trace: ***
Abort trap: 6

model not convertible

[libprotobuf ERROR C:\Users\guillaume\work\caffe-builder\build_v140_x64\packages\protobuf\protobuf_download-prefix\src\protobuf_download\src\google\protobuf\text_format.cc:298] Error parsing text-format caffe.NetParameter: 14:18: Message type "caffe.TransformationParameter" has no field named "resize_param".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0627 22:54:44.400454 3928 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: feature_fusion_SSD\test.prototxt
*** Check failure stack trace: ***

Does this mean I have a similar problem as in #3 ? I haven't tried loading some basic network yet, as you suggested, but the original paper repo at https://github.com/lzx1413/CAFFE_SSD/tree/fssd/cmake doesn't seem to use a custom version of caffe, nor are there any custom layers. I would like to avoid training model the model from scratch.

Batch Norm Caffe to Keras incorrect

When calculating mean and variance, factor layer['weights'][2] should be considered.
Line 199: mean = layer['weights'][0] / layer['weights'][2]

Message type "caffe.LayerParameter" has no field named "prior_box_param"

Does anyone know how to fix this unsupported op?

[libprotobuf ERROR google/protobuf/text_format.cc:274] Error parsing text-format caffe.NetParameter: 2423:19: Message type "caffe.LayerParameter" has no field named "prior_box_param".
WARNING: Logging before InitGoogleLogging() is written to STDERR

ArgumentError in Net.__init__(Net, str, int)

Hi, I'm trying to convert this model: https://drive.google.com/file/d/1fNffD6kAJ5JItVJLgNJP8bTV1WmcjXBF/view?usp=sharing

But I'm getting this error:

Traceback (most recent call last):
File "caffe_weight_converter.py", line 401, in
main(args)
File "caffe_weight_converter.py", line 368, in main
verbose=argv.verbose)
File "caffe_weight_converter.py", line 132, in convert_caffemodel_to_keras
verbose=False)
File "caffe_weight_converter.py", line 323, in convert_caffemodel_to_dict
net = caffe.Net(prototxt_filename, 1, weights=caffemodel_filename)
Boost.Python.ArgumentError: Python argument types in
Net.init(Net, str, int)
did not match C++ signature:
init(N5boost6python3api6objectE, Ss, Ss, i)
init(N5boost6python3api6objectE, Ss, i)

I'm using the following packages:

caffe/1.0.0-rc3-bilinear
tensorflow/1.9.0-py36-gpu
keras/2.0.8-py36

does "caffe.LayerParameter" has no field named "interp_param". mean that i try to convert a layer that doesn't work?

I try to convert ICnet weights (https://github.com/hszhao/ICNet/tree/master/evaluation/model)
and get the following error:
[libprotobuf ERROR google/protobuf/text_format.cc:288] Error parsing text-format caffe.NetParameter: 20:16: Message type "caffe.LayerParameter" has no field named "interp_param".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0307 11:29:02.966812 2308428608 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: icnet_cityscapes_bnnomerge.prototxt
*** Check failure stack trace: ***
Abort trap: 6

ImportError: dynamic module does not define module export function (PyInit__caffe)

Facing the above issue while trying to convert these files. I have successfully installed caffe and ran the tests in the documentation to cross-check.

Here is the complete error:

Traceback (most recent call last):
File "caffe_weight_converter.py", line 22, in
import caffe
File "/home/manideep/Desktop/caffe_weight_converter/caffe/python/caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/manideep/Desktop/caffe_weight_converter/caffe/python/caffe/pycaffe.py", line 13, in
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver,
ImportError: dynamic module does not define module export function (PyInit__caffe)

Please provide solution!

Caffe version compatibility

Can you post the link to the appropriate version of the Caffe and PyCaffe to be used with the following requirements:

OS: Windows 10
Python 3.6
Tensorflow-gpu 1.12
CUDA 9

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.