forked from keras-team/keras
-
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
Better support for Deconv and Crop layers #38
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akshaychawla
commented
Apr 20, 2017
- support for converting deconvolution and crop layers from caffe to keras. Very useful if one is working with image segmentation models.
- sample deploy.prototxt and tests are added in keras/caffe/models/segmentation/ to check the implementation.
- A sample output is shown in keras/caffe/models/segmentation/mini_proof.png.
- 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.
- 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.
- 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.
I tested it and it is working great! |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.