我如何升级我的caffe模型,使它不会每次都“升级”

时间:2021-10-15 21:15:36

I am using caffe with python(pycaffe). I am using the prebuilt alexnet model from model zoo.

我使用caffe和python(pycaffe)。我使用的是模型动物园里预制的alexnet模型。

from this page: https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet

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

Every time I use the model, with this code:

每次我使用这个模型时,我都会用下面的代码:

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

caffe tells me the file format is old and it needs to upgrade the file. Shouldn't this happen only once?

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

how can I properly upgrade the file so that this doesn't happen every single time.

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

2 个解决方案

#1


5  

When you load the model caffe upgrades your prototxt and binary proto, but does not override the original files you are using. This is why you keep getting this message.

当您装载caffe模型时,您将升级您的prototxt和二进制原型,但是不会覆盖您正在使用的原始文件。这就是为什么你不断地得到这个信息。

Upgrading is very straight forward. In $CAFFE_ROOT/build/tools you'll find two binaries: upgrade_net_proto_binary and upgrade_net_proto_text. Simply apply them to your deploy.prototxt and bvlc_alexnet.caffemodel and save the results:

升级是非常直接的。在$咖啡因_root /build/tools中,您将找到两个二进制文件:upgrade_net_proto_binary和upgrade_net_proto_text。只需将它们应用到部署中。prototxt bvlc_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

And that's it!

这是它!

#2


1  

Thank you for Shai for your help.
However, if you are in Windows upgrade_net_proto_binary and upgrade_net_proto_text .exe files are in path-to-caffe-master/caffe/build/tools/Release.

感谢Shai的帮助。但是,如果您在Windows upgrade_net_proto_binary和upgrade_net_proto_text .exe文件中,那么它们的路径是-to-caffe-master/caffe/build/tools/Release。

Hope this will help Windows users

希望这能帮助Windows用户

#1


5  

When you load the model caffe upgrades your prototxt and binary proto, but does not override the original files you are using. This is why you keep getting this message.

当您装载caffe模型时,您将升级您的prototxt和二进制原型,但是不会覆盖您正在使用的原始文件。这就是为什么你不断地得到这个信息。

Upgrading is very straight forward. In $CAFFE_ROOT/build/tools you'll find two binaries: upgrade_net_proto_binary and upgrade_net_proto_text. Simply apply them to your deploy.prototxt and bvlc_alexnet.caffemodel and save the results:

升级是非常直接的。在$咖啡因_root /build/tools中,您将找到两个二进制文件:upgrade_net_proto_binary和upgrade_net_proto_text。只需将它们应用到部署中。prototxt bvlc_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

And that's it!

这是它!

#2


1  

Thank you for Shai for your help.
However, if you are in Windows upgrade_net_proto_binary and upgrade_net_proto_text .exe files are in path-to-caffe-master/caffe/build/tools/Release.

感谢Shai的帮助。但是,如果您在Windows upgrade_net_proto_binary和upgrade_net_proto_text .exe文件中,那么它们的路径是-to-caffe-master/caffe/build/tools/Release。

Hope this will help Windows users

希望这能帮助Windows用户