Windows Caffe 學習筆記(二)提取特徵
阿新 • • 發佈:2019-01-06
這次的筆記是記錄如何從預先訓練的模型中提取特徵。仍然是由於Windows版本Caffe的問題,繞了一些彎路。
正文如下:
1.選擇執行的資料
在examples/下新建一個資料夾,命名為_temp:
選擇使用系統自帶的examples\images下的圖片:
將它們的路徑,寫成一個文字文件,命名為file_list.txt。 在每個路徑的最後加上0,官方文件的解釋是:“The
ImageDataLayer
we’ll
use expects labels after each filenames, so let’s add a 0 to the end of each line”
file_list.txt截圖如下:2.定義特徵提取網路結構 將examples/eature_extraction/imagenet_val.prototxt複製到之前新建的_temp資料夾。 在實際過程中,從資料集中減去影象均值可以顯著的改善分類的準確率,所以使用ILSVRC資料集的均值影象,具體位置在data/ilsvrc12/imagenet_mean.binaryproto. 開啟imagenet_val.prototxt,修改以下兩個路徑,對應準確即可:
3.提取特徵 首先去models\bvlc_reference_caffenet資料夾中,檢視是否有bvlc_reference_caffenet.caffemodel檔案。若沒有,需要自行下載。下載地址在此資料夾的readme文件中:
<span style="font-size:14px;">cd ../../
"Build/x64/Debug/extract_features.exe" examples/_temp/bvlc_reference_caffenet.caffemodel examples/_temp/imagenet_val.prototxt conv5 examples/_temp/features 10 leveldb
pause</span>
注意:1.我是先cd進入Caffe的根目錄,所以程式碼中的路徑這樣填寫。進入examples/_temp/features,檢視: