Code Monkey home page Code Monkey logo

Comments (21)

kashif avatar kashif commented on June 10, 2024 1

@slashstar you can get it from here (580MB), if I have enough space on dropbox in a few mins 🙈 :

https://www.dropbox.com/s/xnm9j3ftc1zh8tc/vgg_face_model_weights.h5?dl=0

from deep-learning-models.

fchollet avatar fchollet commented on June 10, 2024

Consider creating a PR to add these weights (you can upload the files on gDrive for now and I will include them in the repo). Caffe models can be automatically converted to Keras models.

from deep-learning-models.

IvanDrokin avatar IvanDrokin commented on June 10, 2024

@fchollet, can you explain how to convert Caffe model to Keras model? There is VGG-16 model trained on 205places dataset, and i want to use it in Keras. I tried to use @MarcBS code for conversion, but didn't succeed on it.

from deep-learning-models.

fchollet avatar fchollet commented on June 10, 2024

I was referring to the code by @MarcBS. Why isn't it working? Marc, can you help?

from deep-learning-models.

victorhcm avatar victorhcm commented on June 10, 2024

It seems the prototxt provided with VGG-FACE is an old version (see ethereon/caffe-tensorflow#44). Take a look at this comment, it points out the changes you'll have to do in VGG_FACE_deploy.prototxt.

EDIT: I modified the prototxt and it worked. Here is the updated one.

from deep-learning-models.

victorhcm avatar victorhcm commented on June 10, 2024

The model did convert, however when I tried to load it I got the following error:

AssertionError: Keyword argument not understood: b_learning_rate_multiplier

I tried to load it based on @MarcBS code:

from keras.models import Sequential, Graph, model_from_json
from keras.optimizers import SGD
import numpy as np
import copy
model = model_from_json(open('./Keras_model_structure.json').read())

from deep-learning-models.

fchollet avatar fchollet commented on June 10, 2024

Try to only load/save the weights, not the model topology.

On 24 August 2016 at 06:06, Victor Hugo [email protected] wrote:

The model did convert, however when I tried to load it I got the following
error:

AssertionError: Keyword argument not understood: b_learning_rate_multiplier

I tried to load it based on @MarcBS code
https://github.com/MarcBS/keras/blob/master/keras/caffe/test_converted.py
:

from keras.models import Sequential, Graph, model_from_json
from keras.optimizers import SGD
import numpy as np
import copy
model = model_from_json(open('./Keras_model_structure.json').read())


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AArWbzLlFtoaLKnicYa7hOoL70GGUfrkks5qjEG4gaJpZM4JeGxo
.

from deep-learning-models.

victorhcm avatar victorhcm commented on June 10, 2024

It also didn't work, but I think it might be something related to the conversion.

In [12]: model = load_model('./Keras_model_weights.h5')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-9925206257bf> in <module>()
----> 1 model = load_model('./Keras_model_weights.h5')

/usr/local/lib/python2.7/dist-packages/Keras-1.0.6-py2.7.egg/keras/models.pyc in load_model(filepath, custom_objects)
    124     model_config = f.attrs.get('model_config')
    125     if model_config is None:
--> 126         raise ValueError('No model found in config file.')
    127     model_config = json.loads(model_config.decode('utf-8'))
    128     model = model_from_config(model_config, custom_objects=custom_objects)

ValueError: No model found in config file.

from deep-learning-models.

kgrm avatar kgrm commented on June 10, 2024

I think @fchollet meant to try to define the model in the python script and try to load the weights via model.load_weights.

from deep-learning-models.

MarcBS avatar MarcBS commented on June 10, 2024

@victorhcm, I am sorry for not being able to answer sooner. I tried converting the model with your .prototxt and testing it and it worked fine for me. For clarification here I write the steps that I followed:

For all the following steps (either conversion and test) we must use the keras fork in this link.

Conversion

  • Copy the files VGG_FACE.caffemodel and VGG_FACE_deploy_updated.prototxt into to same folder (e.g. '/VGG_Face')
  • Run the following command inside the directory '/keras/caffe':

python caffe2keras.py -load_path '/VGG_Face/' -prototxt 'VGG_FACE_deploy_updated.prototxt' -caffemodel 'VGG_FACE.caffemodel'

Test

  • Inside the same directory, modify the file 'test_converted_VGG_FACE.py' (see file here). Change the model_path and the path to the image used for testing.
  • Run the following command:

python test_converted_VGG_FACE.py

from deep-learning-models.

kashif avatar kashif commented on June 10, 2024

I have this more or less working... I will send a PR soonish... just in case someone else is working on this.

from deep-learning-models.

EncodeTS avatar EncodeTS commented on June 10, 2024

I've already upload the weights of VGG_Face,please refer to fchollet/deep-learning-models#15.

from deep-learning-models.

abskjha avatar abskjha commented on June 10, 2024

Hi,
@kashif , @victorhcm : Can you share the converted weighted of vgg-face?
Thanks.

from deep-learning-models.

abskjha avatar abskjha commented on June 10, 2024

@kashif , Thanks for sharing the network weights.

from deep-learning-models.

danielvarga avatar danielvarga commented on June 10, 2024

@kashif FYI it's not there anymore.

from deep-learning-models.

staywithme23 avatar staywithme23 commented on June 10, 2024

@danielvarga did you get it? @slashstar The link doesn't work.

from deep-learning-models.

kashif avatar kashif commented on June 10, 2024

sorry @danielvarga @adwin5 my dropbox got too full... i am putting it back...

https://www.dropbox.com/s/xnm9j3ftc1zh8tc/vgg_face_model_weights.h5?dl=0

can you try?

from deep-learning-models.

danielvarga avatar danielvarga commented on June 10, 2024

Got it, thank you! I've uploaded it to

http://people.mokk.bme.hu/~daniel/vgg_face_model_weights.h5

@kashif Is this okay with you? If yes: I won't give any hard promises that the above link stays live for a long time, but my expectation is that it does.

from deep-learning-models.

bienbinod avatar bienbinod commented on June 10, 2024

@MarcBS
Hi,

First of all, thank you for such an amazing module for converting caffe model to keras model.
I followed the instructions that you mentioned in this thread to generate the keras version of VGG face and I could convert it successfully. I used test_converted_VGG_FACE.py to test on the new face images and it works when I use your script from the same location where you are keeping. But when I bring out your script from the directory where you are keeping and run to make a prediction, it shows following error. Could you please comment on it, why its not working? I have latest keras 1.2.2 installed on my machine. I tried downgrading the version to 1.2.0 and tried to run, it still does not work.

     `Using Theano backend.
       Preparing test image.
       Loading model.
       Traceback (most recent call last):
       File "test_converted_VGG_FACE.py", line 52, in <module>
       model = model_from_json(open(model_path+'/Keras_model_structure.json').read())
       File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/models.py", line 210, in model_from_json
       return layer_from_config(config, custom_objects=custom_objects)
       File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/utils/layer_utils.py", line 38, in layer_from_config
       return layer_class.from_config(config['config'], custom_objects=custom_objects)
       File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/engine/topology.py", line 2575, in from_config
process_layer(layer_data)
      File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/engine/topology.py", line 2553, in process_layer
custom_objects=custom_objects)
      File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/utils/layer_utils.py", line 40, in layer_from_config
return layer_class.from_config(config['config'])
      File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/engine/topology.py", line 1016, in from_config
return cls(**config)
      File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/layers/convolutional.py", line 388, in __init__
super(Convolution2D, self).__init__(**kwargs)
     File "/Users/XXX/anaconda2/envs/python2/lib/python2.7/site-packages/keras/engine/topology.py", line 323, in __init__
    raise TypeError('Keyword argument not understood:', kwarg)
   TypeError: ('Keyword argument not understood:', u'b_learning_rate_multiplier')

`

from deep-learning-models.

MarcBS avatar MarcBS commented on June 10, 2024

@bienbinod, thank you for your feedback.
If you are using the original Keras repo your converted models won't work. You must use this Keras fork, given that the converter also uses that specific version.

from deep-learning-models.

bienbinod avatar bienbinod commented on June 10, 2024

@MarcBS Thanks for your quick reply. I did as you suggested and it works.

from deep-learning-models.

Related Issues (20)

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.