Commit 480dcd30 authored by Ross Girshick's avatar Ross Girshick
Browse files

add threshold to demo

parent e07c1d46
...@@ -15,6 +15,10 @@ function rcnn_demo(demo_choice, use_gpu) ...@@ -15,6 +15,10 @@ function rcnn_demo(demo_choice, use_gpu)
% this file (or any portion of it) in your project. % this file (or any portion of it) in your project.
% --------------------------------------------------------- % ---------------------------------------------------------
clf;
thresh = -1;
if ~exist('demo_choice', 'var') || isempty(demo_choice) if ~exist('demo_choice', 'var') || isempty(demo_choice)
demo_choice = 'PASCAL'; demo_choice = 'PASCAL';
end end
...@@ -56,24 +60,28 @@ rcnn_model = rcnn_load_model(rcnn_model_file, use_gpu); ...@@ -56,24 +60,28 @@ rcnn_model = rcnn_load_model(rcnn_model_file, use_gpu);
fprintf('done\n'); fprintf('done\n');
th = tic; th = tic;
dets = rcnn_detect(im, rcnn_model); dets = rcnn_detect(im, rcnn_model, thresh);
fprintf('Total %d-class detection time: %.3fs\n', ... fprintf('Total %d-class detection time: %.3fs\n', ...
length(rcnn_model.classes), toc(th)); length(rcnn_model.classes), toc(th));
% show top scoring bicycle detection all_dets = [];
ind = strmatch('bicycle', rcnn_model.classes); for i = 1:length(dets)
showboxes(im, dets{ind}(1,:)); all_dets = cat(1, all_dets, ...
title(sprintf('bicycle score = %.3f', dets{ind}(1,end))); [i * ones(size(dets{i}, 1), 1) dets{i}]);
drawnow; end
fprintf('Showing the top scoring bicycle detection\n');
fprintf('Press any key to continue\n');
pause;
% show top scoring person detection [~, ord] = sort(all_dets(:,end), 'descend');
ind = strmatch('person', rcnn_model.classes); for i = 1:length(ord)
showboxes(im, dets{ind}(1,:)); score = all_dets(ord(i), end);
title(sprintf('person score = %.3f', dets{ind}(1,end))); if score < 0
drawnow; break;
end
cls = rcnn_model.classes{all_dets(ord(i), 1)};
showboxes(im, all_dets(ord(i), 2:5));
title(sprintf('det #%d: %s score = %.3f', ...
i, cls, score));
drawnow;
pause;
end
fprintf('Showing the top scoring person detection\n'); fprintf('No more detection with score >= 0\n');
function dets = rcnn_detect(im, rcnn_model) function dets = rcnn_detect(im, rcnn_model, thresh)
% AUTORIGHTS % AUTORIGHTS
% --------------------------------------------------------- % ---------------------------------------------------------
% Copyright (c) 2014, Ross Girshick % Copyright (c) 2014, Ross Girshick
...@@ -38,7 +38,8 @@ th = tic(); ...@@ -38,7 +38,8 @@ th = tic();
num_classes = length(rcnn_model.classes); num_classes = length(rcnn_model.classes);
dets = cell(num_classes, 1); dets = cell(num_classes, 1);
for i = 1:num_classes for i = 1:num_classes
scored_boxes = cat(2, boxes, scores(:,i)); I = find(scores(:, i) > thresh);
scored_boxes = cat(2, boxes(I, :), scores(I, i));
keep = nms(scored_boxes, 0.3); keep = nms(scored_boxes, 0.3);
dets{i} = scored_boxes(keep, :); dets{i} = scored_boxes(keep, :);
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment