flyyufelix / DenseNet-Keras

DenseNet Implementation in Keras with ImageNet Pretrained Models
MIT License
566 stars 264 forks source link

conversion tool #3

Closed ahundt closed 7 years ago

ahundt commented 7 years ago

I'm curious, what did you use to actually convert the weights from caffe to keras?

flyyufelix commented 7 years ago

A detailed account of converting weight for ResNet152 can be found in my blog post here: https://flyyufelix.github.io/2017/03/23/caffe-to-keras.html. I basically used the same method to convert weight for DenseNet :)

ahundt commented 7 years ago

Ah I had given this utility a go https://github.com/ethereon/caffe-tensorflow/issues/112 and ran into the linked problem, but had not seen https://github.com/OdinLin/caffe2keras.

How does that account for ceil_mode as mentioned in https://github.com/ethereon/caffe-tensorflow/issues/112? I'm interested to determine if the algorithms are exactly the same or if there is a slight difference.

Also someone might have updated your model to work for more than the old version of keras at https://github.com/azavea/raster-vision/blob/92bbf8fdb66e6b612326cb7e896e804fe4eec90f/src/rastervision/common/models/densenet169.py

flyyufelix commented 7 years ago

Yes, I remember this is the tricky part. First you have to edit a few files in Caffe to incorporate the ceil_mode. See this commit:

https://github.com/BVLC/caffe/pull/3057/files

Then you have to recompile Caffe and use the caffe_pb2.py (located at python/caffe/proto) to read protobuf content (i.e. caffemodel) with python.

ahundt commented 7 years ago

Thanks, that was helpful!