Commit 73205ed3 authored by Ross Girshick's avatar Ross Girshick
Browse files

option to run demo in CPU mode

parent ec3f0c8f
function rcnn_demo()
function rcnn_demo(use_gpu)
% rcnn_demo(use_gpu)
% Run the R-CNN demo on a test image. Set use_gpu = false to run
% in CPU mode. (GPU mode is the default.)
% AUTORIGHTS
% ---------------------------------------------------------
% Copyright (c) 2014, Ross Girshick
%
% This file is part of the R-CNN code and is available
% under the terms of the Simplified BSD License provided in
% LICENSE. Please retain this notice and LICENSE if you use
% this file (or any portion of it) in your project.
% ---------------------------------------------------------
rcnn_model_file = './data/rcnn_models/voc_2012/rcnn_model_finetuned.mat';
......@@ -6,7 +19,18 @@ if ~exist(rcnn_model_file, 'file')
error('You need to download the R-CNN precomputed models. See README.md for details.');
end
use_gpu = true;
if ~exist('use_gpu', 'var') || isempty(use_gpu)
use_gpu = true;
end
modes = {'CPU', 'GPU'};
fprintf('~~~~~~~~~~~~~~~~~~~\n');
fprintf('Running in %s mode\n', modes{use_gpu+1});
fprintf('(To run in %s mode, call rcnn_demo(%d) instead)\n', ...
modes{~use_gpu+1}, ~use_gpu);
fprintf('Press any key to continue\n');
pause;
fprintf('Initializing R-CNN model (this might take a little while)\n');
rcnn_model = rcnn_load_model(rcnn_model_file, use_gpu);
fprintf('done\n');
......@@ -19,7 +43,7 @@ dets = rcnn_detect(im, rcnn_model);
showboxes(im, dets{2}(1,:));
title(sprintf('bicycle conf = %.3f', dets{2}(1,end)));
fprintf('\n> Press any key to see the top scoring person detection.');
fprintf('Press any key to see the top scoring person detection\n');
pause;
% show top scoring person detection
......
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