Skip to content
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

Better support for Deconv and Crop layers #38

Merged
merged 8 commits into from
Apr 21, 2017
Merged

Better support for Deconv and Crop layers #38

merged 8 commits into from
Apr 21, 2017

Conversation

akshaychawla
Copy link

  1. support for converting deconvolution and crop layers from caffe to keras. Very useful if one is working with image segmentation models.
  2. sample deploy.prototxt and tests are added in keras/caffe/models/segmentation/ to check the implementation.
  3. A sample output is shown in keras/caffe/models/segmentation/mini_proof.png.
  4. Slight change in caffe_to_keras function in convert.py. In case input_dim from config.input_dim[:] is an empty list, the dimensions are sourced from the "data" layer, have a look at the code once.
  5. Softmax now supports inputs of type (Batchsize, classes, height, width) which occurs in image segmentation networks and converts it to the format (Batchsize, height*width, classes) which can be given to standard softmax activation in Keras.
  6. When copying over weights, Deconvolution weights are copied in the same way as convolution weights. I added a zeros vector to weights_b in case has_bias is False.

2. Input_dim was coming in as an empty tuple so I modified the implementation
   to take the input dimensions from the first data layer.
3. convert_weights is able to copy weights for deconv layer also.
4. Able to convert voc-fcn8s proto+cafemodel to keras and run inference.
   The output is NOT yet exactly the same as caffe, so I'm working on that.
5. Using a slightly separate copy of create_model, TODO: merge with original copy
   of create_model

 Changes to be committed:
	modified:   keras/caffe/caffe2keras.py
	modified:   keras/caffe/convert.py
	new file:   keras/caffe/models/segmentation/deploy.prototxt
	new file:   keras/caffe/models/segmentation/fcn8s-heavy-pascal.caffemodel

 Changes not staged for commit:
	deleted:    keras/caffe/models/Keras_model_structure.json
	deleted:    keras/caffe/models/Keras_model_weights.h5
   present in folder.
2. Added caffemodel-url.txt that has instructions on how to download
   fcn8s-heavy-pascal.caffemodel file.
@MarcBS
Copy link
Owner

MarcBS commented Apr 21, 2017

I tested it and it is working great!

@MarcBS MarcBS merged commit 51cb559 into MarcBS:master Apr 21, 2017
@akshaychawla
Copy link
Author

Yay :) I've also been working towards adding a Scale layer which is used in voc-fcn8s-allatonce (https://github.com/shelhamer/fcn.berkeleyvision.org/tree/master/voc-fcn8s-atonce), will make a PR when that's ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants