2016-03-04 32 views
3

我正在用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)) 

朱古力告訴我,文件格式是舊的,它需要升級文件。這不應該只發生一次?

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 

我怎樣才能正確地升級文件,以便這不會每一次發生。

回答

5

當您加載模型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 

就是這樣!

1

非常感謝Shai爲您的help
但是,如果您在Windowsupgrade_net_proto_binaryupgrade_net_proto_text.exe文件在path-to-caffe-master/caffe/build/tools/Release

希望這會幫助Windows用戶