Caffe 碎碎念


Window Data Layer

window data layer 的數據是存在硬盤上的圖片, 需要在一個txt里指定用於訓練或測試的圖片以及bounding box, bounding box 對應的標簽, 以及bounding box和ground truth bounding box的overlap, 一個例子如下

# 0
/home/xxx/0001.jpg
3
641
677
7
1 1.0 353 356 393 396
1331 0.5 338 344 379 384
3964 0.7 339 336 379 376
4533 0 334 330 374 370
4689 1.0 330 324 370 364
4865 1.0 335 319 375 359
4927 1.0 341 313 381 353
# 1
/home/xxx/0002.jpg
3
600
400
3
1 1.0 353 356 393 396
1331 0.5 338 344 379 384
3964 0.7 339 336 379 376

其中第一行是圖片的index, 從0開始, 接下來三行依此是圖片的channel, height, width, 接下來一行表示 bounding box 數量. 再接下來的每一行都是一個bounding box, 第一個數字表示label, 第二個數字表示與真實goundtruth 的overlap, 接下來的四個數字表示x1, y1, x2, y2.

 

最后, 在prototxt里這樣定義

layers {
  name: "data"
  type: WINDOW_DATA
  top: "data"
  top: "label"
  window_data_param {
    source: "window_data_train.txt"
    batch_size: 128
    crop_size: 256 # 要把bounding box warp到的大小
    fg_threshold: 0.5 # 與ground truth 大於 fg_threshold 的bbox才作為正陽本
    bg_threshold: 0.5 # 與ground truth 小於 bg_threshold 的bbox才作為正陽本
    fg_fraction: 0.25 # 一個batch中正陽本數量的比例
    crop_mode: "warp"
  }
  transform_param {
    mean_value: 128
    mean_value: 128
    mean_value: 128
    mirror: false
  }
  include: { phase: TRAIN }
}

 

 

 

負樣本的label是任意的, 但是overlap要小於threshold (絕對負樣本可以將overlap 設置為 0)

2. 如果 fg_fraction 小於 1, 並且如果一個dataset (TRAIN phase / TEST phase) 中沒有負樣本, 那么邏輯上就是矛盾的, caffe會報錯 (但是錯誤內容是比較莫名其妙的) , 比如:

I0507 09:58:46.192163 21762 net.cpp:113] Setting up fc6
*** Aborted at 1430963926 (unix time) try "date -d @1430963926" if you are using GNU date ***
PC: @     0x7f5ad296f0db caffe::WindowDataLayer<>::InternalThreadEntry()
*** SIGFPE (@0x7f5ad296f0db) received by PID 21762 (TID 0x7f5aacde6700) from PID 18446744072947691739; stack trace: ***
    @     0x7f5ad1b19d40 (unknown)
    @     0x7f5ad296f0db caffe::WindowDataLayer<>::InternalThreadEntry()
    @     0x7f5aca2d6a4a (unknown)
    @     0x7f5ac9839182 start_thread
    @     0x7f5ad1bdd47d (unknown)
    @                0x0 (unknown)
./train.sh: line 2: 21762 Floating point exception(core dumped) ./external/caffe/build/tools/caffe train -gpu 1 -solver external/my_models/lsp_window_data/lsp_solver.prototxt

3. 如果bbox坐標超過了image 的大小, 但是bbox有一部分在圖像內部, 這種情況是允許的.

LMDB/LevelDB

需要在prototxt里面指定圖像大小, 程序內部會check設定的大小是否和數據實際大小一致. 所以數據一旦存儲后就不能再改變大小.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM