Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 2.4 KB

README.md

File metadata and controls

31 lines (25 loc) · 2.4 KB

Models conversion

Contents:


Caffe to Keras:

How to use: python3 caffe2keras_converter.py <prototxt> <caffemodel> <output_dir> [--verbose]
Arguments:

  • prototxt: The filename (full path including file extension) of the '.prototxt' file that contains the Caffe model definition
  • caffemodel: The filename (full path including file extension) of the '.caffemodel' file that contains the network's parameters
  • output_dir: The path to the directory where to save the Keras model and the file where you want the code to be written in

High-level description: the net's weights are taken with caffe_weight_converter.py which also manipulates them in order to match Keras' requirements.
create_nn_struct.py goes through the Caffe net and creates an equivalent network structure in Keras. It generates also the Python file containing the source code necessary to create that structure, so it's possible to manually modify or check it.


Keras to Caffe:

How to use: python3 keras2caffe_converter.py <keras_model> <output_dir> [--caffemodel_name CAFFEMODEL_NAME] [--prototxt PROTOTXT]
Arguments:

  • keras_model: The filename (full path including extension) of the file that contains the Keras model
  • output_dir: The path to the output directory where to save the caffemodel (and prototxt if necessary)
  • --caffemodel_name CAFFEMODEL_NAME: The name (without extension) of the file where to save the Caffe model
  • --prototxt PROTOTXT: The filename (full path including file extension) of the '.prototxt' file that defines the Caffe model

High-level description:
If no prototxt file was passed as argument, keras2caffe/create_prototxt.py will automatically generate one by going through the Keras input model to grasp all the information needed to create one.
Then the weights are copied from the Keras model, manipulated to match Caffe's requirements and put into the newly created Caffe NN.