如何升级我的caffe模型,以便每次使用时都不会“升级”

时间:2016-03-04 21:11:51

标签: machine-learning deep-learning caffe pycaffe

我正在使用caffe和python(pycaffe)。我正在使用预建的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

如何正确升级文件,以免每次都发生这种情况。

2 个答案:

答案 0 :(得分:5)

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

升级非常简单。在$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

就是这样!

答案 1 :(得分:1)

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

希望这将有助于Windows用户