-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I don't understand which command I have to write to convert a model #8
Comments
As it explained in the README file, you can use the caffe2keras.py as a command line tool the following way:
where you just have to include the path to your model files (your_path) and the names of the prototxt (your_prototxt) and caffemodel (your_caffemodel) files included in that path. The converted model will be stored by default in your_path. I have just updated the README file for making this more clear. |
You mean I have to write this command line in the Terminal ? |
When I use this line in the terminal there is this error : google.protobuf.text_format.ParseError: 37:2 : Message type "caffe.LayerParameter" has no field named "scale_param". Do you understand why ? Thank you very much for your help ! |
This error is probably caused because the parameter 'scale_param' is relatively new in the .prototxt files. I have just updated the file caffe_pb2.py in the repo, which is in charge of controlling the valid .prototxt parameters. Re-sync your cloned files with the new changes and try it again, it should work properly now. |
Hi, I am really sorry but it still doesn't work. I'm getting this error even after the sync : Traceback (most recent call last): May be this is because I don't know how to use caffe_pb2. py ? |
That error is thrown because the layer BatchNorm was not implemented in the converter yet. |
Still the same type of error : Traceback (most recent call last): |
Same error as @cyrilgarcia009 . To add more context: I am trying to convert Resnet50 from https://github.com/KaimingHe/deep-residual-networks. Link to proto and weights: https://onedrive.live.com/?authkey=%21AAFW2-FVoxeVRck&id=4006CBB8476FF777%2117887&cid=4006CBB8476FF777 |
Thanks for the context @ternaus. I have applied some new changes to the converter and ResNets can be correctly transferred to Keras. As an example you can use the weights and prototxt provided by @ternaus. Just as a reminder, don't forget to add the following layer as the first layer in your prototxt files: layer { I have not checked the performance of the converted model, so please, if any of you apply some validation report the results comparison here for considering any possible modification. Thanks. |
I was able to convert ResNet50 with the current commit and adding the data layer, but wasn't able to get inference working.
https://github.com/MarcBS/keras/blob/master/keras/layers/normalization.py#L193 Some debugging info that doesn't quite make sense:
I'm not all that familiar with keras/theano, but bn_conv1 has one input and output node and it's conv1 and caffe's separate batchnorm scale layer. It's not anywhere near a skip connection or addition (I searched the json and yaml files). Not sure how to get more information as to how x and self.called_with differ. Here is a graphviz of the converted model: Assuming it was accidentally getting recompiled , I removed the explicit compile step and got this error (same as if replacing mode=0 with mode=2 in the model files):
only change to test_converted.py was replacing the 3 losses with one when compiling. model.summary() looks reasonable around that area. |
I am really sorry but I just don't understand what I can use to convert a model from caffe to keras.
I have a folder with two files (prototxt and caffemodel), but I don't understand how to convert it. Can you help me please ?
The text was updated successfully, but these errors were encountered: