pierluigiferrari / caffe_weight_converter Goto Github PK
View Code? Open in Web Editor NEWCaffe-to-Keras weight converter. Can also export weights as Numpy arrays for further processing.
License: GNU General Public License v3.0
Caffe-to-Keras weight converter. Can also export weights as Numpy arrays for further processing.
License: GNU General Public License v3.0
Hello.
I run code on google colab and two other system that installed caffe by pycaffe, and when run code,
resulting runtime died!.
I want convert this caffemode :
https://github.com/liulei01/DRBox/tree/master/examples/rbox/deploy/vehicle
deploy.prototxt and RBOX_CAR_RBOX_300x300_CAR_VGG_0.3_iter_120000.caffemodel.
please help me.
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
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?
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!
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
[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.
When calculating mean and variance, factor layer['weights'][2] should be considered.
Line 199: mean = layer['weights'][0] / layer['weights'][2]
Does one need to use Cmake to download caffe to use this repository or does conda install work with it?
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
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
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
I am trying to extract weights from a pruned VGG16 caffemodel however it outputs a 1kb h5 file giving 0 layers processed. The link to the model https://github.com/yihui-he/channel-pruning/releases/tag/VGG-16_3C4x
The zip file contains both caffemodel and prototxt.
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!
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.