yun-liu / RCF

Richer Convolutional Features for Edge Detection
Other
752 stars 259 forks source link

How can i test results of model on my own datasets? #70

Closed luoboganer closed 5 years ago

luoboganer commented 5 years ago

Hello! I have finished the process of training and inference, and I have done NMS operation for inference results. but do you know how to generate ground truth in .mat format for my own datasets? Currently we only have the ground truth file in .png format. Because I find they are necessary input for evaluation tool in Structured Edge Detection Toolbox and benchmark of BSDS500!

Thank you for your time!

yun-liu commented 5 years ago

Two choices here. (1) You can convert your ground truth into the format of standard BSDS500 dataset. Specifically, please set the groundTruth{1,1}.Boundaries to your ground truth and just ignore the data field of groundTruth{1,1}.Segmentation. For multiple ground truth of an image, you can just use a cell array of groundTruth. (2) You can also read and modify the benchmark code to enable it to load .png ground truth. It is easy and only several lines of code are needed to be modified.

luoboganer commented 5 years ago

Oh, so sorry! I have solved this problem, but I forgot to close this issue. Here is the script for implementing your method one, I hope it is useful for others! Thank you very much!

gt_png_path='./gt/';  % original ground truth with .png format
gt_mat_path='./gt_mat/'; % destination directory to save generated ground truth with .mat format

iids=dir(fullfile(gt_png_path,'*.png')); 

for i = 1:numel(iids),
    pngFile = fullfile(gt_png_path,iids(i).name);
    % assert(exist('pngFile','file')==true)
    matFile = fullfile(gt_mat_path, strcat(iids(i).name(1:end-4),'.mat'));
    if exist(matFile,'file')
        continue;
    end
    groundTruth={struct('Boundaries',logical(imread(pngFile)))};
    save(matFile,'groundTruth');
    fprintf('%d\t',i);
    disp(pngFile);
end