简体   繁体   English

如何向预训练的 caffe model 添加预处理层?

[英]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.我有一个预先训练好的图像分类 model 保存在 caffe 中,model 预计会得到灰度(单通道)图像。 I want to use this model in a tool that only provides input of RGB(three channels) to the model.我想在仅向 model 提供 RGB(三通道)输入的工具中使用此 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?无法更改此工具提供图像的方式,因此我想在输入层之前添加一个层,仅将输入转换为一个通道,这在 caffe 中可能吗? and how?如何?

I'm looking for a solution that doesn't require to define new layers to caffe if possible.如果可能的话,我正在寻找一种不需要为 caffe 定义新层的解决方案。

Note that I have the ".prototxt" and the ".weights" files of the model.请注意,我有 model 的“.prototxt”和“.weights”文件。

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.我之前在 tensorflow 中做过类似的事情,但我不知道这在 caffe 中是否可行,也没有在网上找到太多资料。

You can add a Python layer to do it for you.您可以添加一个Python层来为您完成。

What is a Python layer .什么是Python An example of such a layer can be found here .可以在此处找到此类层的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM