邊緣檢測相關(guān)論文所用到的評測代碼都是基于bsds500數(shù)據(jù)集的benchmarks娃循。
bsds500介紹
berkeley segmentation data set (bsds500)是伯克利大學(xué)computer vision group提供的數(shù)據(jù)集可以用來圖像分割
和物體邊緣檢測
。該數(shù)據(jù)集包含200
張訓(xùn)練圖笛质,100
張驗證圖捞蚂,200
張測試圖;所有真值用.mat文件保存敲霍,包含segmentation和boundaries丁存,每張圖片對應(yīng)真值有五個,為5個人標(biāo)注的真值柱嫌,訓(xùn)練時真值可采用平均值或者用來擴充數(shù)據(jù),評測代碼中會依次對這五個真值都做對比与学。
壓縮包中包含三個子文件:
- bench用于評測自己方法的指標(biāo),主要為matlab的.m文件晕窑,核心文件
correspondPixels.cc
文件需要編譯卵佛,如果是Linux64位電腦則不需要編譯源文件,因為已有編譯好的correspondPixels.mexa64
文件在里面疾牲。MATLAB工具必不可少衙解,如何編譯后面在講。 - BSDS500為數(shù)據(jù)集內(nèi)容
數(shù)據(jù)集擴充
最近很多關(guān)于邊緣檢測的深度學(xué)習(xí)論文2019BDCN蚓峦、2017CRF、2015HED等都對bsds500的訓(xùn)練集和驗證集共300張圖片進行了數(shù)據(jù)擴充霍转,包括旋轉(zhuǎn)
一汽、翻轉(zhuǎn)
、尺度縮放
沾谓。HED擴充之后的數(shù)據(jù)集地址:http://vcl.ucsd.edu/hed/HED-BSDS.tar戳鹅,該數(shù)據(jù)集有1.3GB共28800張訓(xùn)練圖,該數(shù)據(jù)集未給出測試集真值枫虏,評測時仍需要用到之前bsds500中的真值隶债。
邊緣評測
評測可以直接使用伯克利BSDS500中的benchmarks評測∷蓝铮或者使用HED的評測腳本,考慮到相關(guān)邊緣檢測論文評測前都會對方法結(jié)果進行非極大值抑制虏两,推薦使用HED的評測腳本世剖,它包含了非極大值抑制代碼。地址:https://github.com/s9xie/hed_release-deprecated/tree/master/examples/eval祖凫。它的readme.txt為:
In our experiment, the evaluation pipeline is
1. Store the edge prediction results in IPython Notebook to individual .mat files using scipy.io.savmat() function.
2. using nms_process.m to get NMS processed png files.
3. using EvalEdge.m to get the final evaluation results.
4. To get the "late merging" results reported in the paper, run merge_res.m (simply add up nms processed files).
You still need to download Piotr's edge toolbox to make this work.
This is highly redundant, and for now we release these scripts so that the reported results can be exactly reproduced. (Numerical precision of edge map saved can affect the performance a little bit, e.g. directly save the png files before NMS)
We plan to port the NMS code and evaluation code to python very soon.
Contact s9xie(AT)eng.ucsd.edu for questions.
根據(jù)readme內(nèi)容酬凳,一步一步操作:
本電腦MATLAB為2015b
- 在Python中使用scipy.io.savmat()函數(shù)把每張待預(yù)測圖片保存成.mat格式,保存之后矩陣中元素的取值范圍要求為0到1售滤,代表像素點為邊緣的概率台诗,實際上為網(wǎng)絡(luò)sigmoid激活后輸出結(jié)果赐俗。
- 下載Edge Toolbox
下載地址:https://github.com/pdollar/edges,使用之前需要Matlab Toolbox:https://pdollar.github.io/toolbox/
-
Matlab Toolbox說明:
我選擇最新版3.50粱快,如果是64位的Windows/Linux/Mac則不需要編譯叔扼,否則請在Matlab中的命令行中執(zhí)行toolboxCompile,或者直接運行toolboxCompile.m文件瓜富。
例如這是編譯好的三個文件:
其中后綴mexa64代表Linux64位与柑,mexmaci64代表Mac64位,mexw64代表Windows64位丑念。 - Edge Toolbox說明
64位的Windows/Linux則不需要編譯结蟋,否則請在matlab的命令窗口編譯,使用時需要把對應(yīng)編譯好的edgesNmsMex文件放入到與nms_process.m
同目錄下
同目錄下非常重要挠将,否則會導(dǎo)致無法找到對應(yīng)參數(shù)類型的edgesNmsMex函數(shù)
Please compile mex code from within Matlab (note: win64/linux64 binaries included):
mex private/edgesNmsMex.cpp -outdir private [OMPPARAMS]
Here [OMPPARAMS] are parameters for OpenMP and are OS and compiler dependent.
Windows: [OMPPARAMS] = '-DUSEOMP' 'OPTIMFLAGS="$OPTIMFLAGS' '/openmp"'
Linux V1: [OMPPARAMS] = '-DUSEOMP' CFLAGS="\$CFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp"
Linux V2: [OMPPARAMS] = '-DUSEOMP' CXXFLAGS="\$CXXFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp"
To compile without OpenMP simply omit [OMPPARAMS]; note that code will be single threaded in this case.
- 運行nms_process.m產(chǎn)生非極大值抑制后的邊緣結(jié)果
- 運行EvalEdge.m得到評測結(jié)果。
結(jié)束
最終給出我的文件夾內(nèi)容:
其中
source
為Edge Toolbox的內(nèi)容乳丰,toolbox
為Matlab Toolbox的內(nèi)容内贮,這里已經(jīng)把編譯好的edgesNmsMex放到了與nms_process.m同目錄下。一定要記得添加路徑什燕,簡單粗暴直接:具體評測相關(guān)內(nèi)容可參考HED:
https://github.com/s9xie/hed
非常感謝屎即!
本人已畢業(yè)許久事富,且不從事相關(guān)工作,如有問題還請自行解決5窭蕖<!