Skip to content
Advertisement

How to add a preprocessing layer to a pretrained caffe model?

I have a pre-trained image classification model saved in caffe, the model is expected to get grayscale(one channel) images. I want to use this model in a tool that only provides input of RGB(three channels) to the model. It is not possible to change the way this tool provides images so I thought of adding a layer before the input layer that transforms the input to one channel only, is that possible in caffe? and how?

I’m looking for a solution that doesn’t require to define new layers to caffe if possible.

Note that I have the “.prototxt” and the “.weights” files of the model.

I previously did a similar thing in tensorflow but I don’t know if this is possible in caffe and didn’t find much material online.

Advertisement

Answer

You can add a Python layer to do it for you.

What is a Python layer. An example of such a layer can be found here.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement