caffe之提取任意層特徵並進行視覺化

weixin_33866037發表於2017-07-07

Caffe提取任意層特徵並進行視覺化 (caffe-master/examples/_temp下面)
blog.csdn.net/l494926429/article/details/51982620 

現在Caffe的Matlab介面 (matcaffe3) 和python介面都非常強大, 可以直接提取任意層的feature map以及parameters, 所以本文僅僅作為參考, 更多最新的資訊請參考:
caffe.berkeleyvision.org/tutorial/interfaces.html 

原圖

conv1層視覺化結果 (96個filter得到的結果)

資料模型與準備

安裝好Caffe後,在examples/images資料夾下有兩張示例影象,本文即在這兩張影象上,用Caffe提供的預訓練模型,進行特徵提取,並進行視覺化。
1. 進入caffe根目錄,建立臨時資料夾,用於存放所需要的臨時檔案

mkdir examples/_temp

2. 根據examples/images資料夾中的圖片,建立包含影象列表的txt檔案,並新增標籤(0)

#生成temp.txt檔案,包含圖片路徑列表
find `pwd`/examples/images -type f -exec echo {} \; > examples/_temp/temp.txt
#生成file_list.txt檔案,但是其中為啥標籤都是0啊,不管
sed "s/$/ 0/" examples/_temp/temp.txt > examples/_temp/file_list.txt

補充:find `pwd`/examples/images -type f

輸出:

/home/echo/caffe-master/examples/images/fish-bike.jpg
/home/echo/caffe-master/examples/images/cat_gray.jpg
/home/echo/caffe-master/examples/images/cat gray.jpg
/home/echo/caffe-master/examples/images/cat.jpg

相關文章