我怎样才能升级我的 caffe 模型,这样它就不会 'upgrade' 每次我使用它

how can i upgrade my caffe model so it doesn't 'upgrade' every time I use it

我在 python(pycaffe) 中使用 caffe。我正在使用预建 alexnet model from model zoo

从这个页面: https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet

每次使用模型时,代码如下:

net = caffe.Classifier('deploy.prototxt','bvlc_alexnet.caffemodel',
                   channel_swap=(2,1,0),
                   raw_scale=255,
                   image_dims=(256, 256))

caffe 告诉我文件格式旧,需要升级文件。这不应该只发生一次吗?

E0304 20:52:57.356480 12716 upgrade_proto.cpp:609] Attempting to upgrade input file specified using deprecated transformation parameters: /tmp/bvlc_alexnet.caffemodel
I0304 20:52:57.356554 12716 upgrade_proto.cpp:612] Successfully upgraded file specified using deprecated data transformation parameters.     E0304 20:52:57.356564 12716 upgrade_proto.cpp:614] Note that future Caffe releases will only support transform_param messages for transformation fields.
E0304 20:52:57.356580 12716 upgrade_proto.cpp:618] Attempting to upgrade input file specified using deprecated V1LayerParameter: /tmp/bvlc_alexnet.caffemodel
I0304 20:52:59.307096 12716 upgrade_proto.cpp:626] Successfully upgraded file specified using deprecated V1LayerParameter

我怎样才能正确升级文件,以免每次都发生这种情况。

当您加载模型时,caffe 会升级您的 prototxt 和二进制原型,但不会覆盖您正在使用的原始文件。这就是您不断收到此消息的原因。

升级非常简单。在 $CAFFE_ROOT/build/tools 中,您会发现两个二进制文件:upgrade_net_proto_binaryupgrade_net_proto_text。只需将它们应用到您的 deploy.prototxtbvlc_alexnet.caffemodel 并保存结果:

~$ mv deploy.prototxt deploy_old.prototxt
~$ mv bvlc_alexnet.caffemodel bvlc_alexnet_old.caffemodel
~$ $CAFFE_ROOT/build/tools/upgrade_net_proto_text deploy_old.prototx deploy.prototxt
~$ $CAFFE_ROOT/build/tools/upgrade_net_proto_binary bvlc_alexnet_old.caffemodel bvlc_alexnet.caffemodel

就是这样!

感谢 Shai 的
但是,如果您在 Windows upgrade_net_proto_binaryupgrade_net_proto_text 中,.exe 文件在 path-to-caffe-master/caffe/build/tools/Release 中。

希望这对 Windows 用户

有帮助