Contents

% DEMO: Applying an ensemble of Exemplar-SVMs
% This function can generate a nice HTML page by calling:
% publish('esvm_quick_demo.m','html')
%
% Copyright (C) 2011-12 by Tomasz Malisiewicz
% All rights reserved.
%
% This file is part of the Exemplar-SVM library and is made
% available under the terms of the MIT license (see COPYING file).
% Project homepage: https://github.com/quantombone/exemplarsvm

addpath(genpath(pwd));
cls = 'voc2007-bus';

Download and load pre-trained VOC2007 bus models

[models, M, test_set] = esvm_download_models(cls);
params = esvm_get_default_params;

%We can speed things (2x) up by turning of detections on image flips
%params.detect_add_flip = 0;

%We can also speed things up by taking a subset of models
%[models,M] = esvm_subset_of_models(models,M,1:100);

%If VOC is locally installed, let models point to local images, not URLs
local_dir = '/Users/tomasz/projects/pascal/VOCdevkit/';
if isdir(local_dir)
  [models] = esvm_update_voc_models_to_local(models, local_dir);
end
Found voc2007-bus.mat, not downloading

Load one image, and apply bus detector

I1 = imread('000858.jpg');
esvm_apply_and_show_exemplars(I1, models, M, params);
Warning: Models have images as URLs
 -- If you want to apply detectors to a LOT of images, download the PASCAL VOC2007 dataset locally and call :
[models]=esvm_update_voc_models_to_local(models,local_dir);
 --image 00001/00001: 229 exemplars took 5.337sec, #windows=00124, max=-0.475 
Applying M-matrix to 1 images:.took 0.007sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=5.270
Warning: loading image from URL
Warning: loading image from URL

Create an array of images, and apply bus detector

I2 = imread('009021.jpg');
I3 = imread('009704.jpg');
Iarray = {I2, I3};
esvm_apply_and_show_exemplars(Iarray, models, M, params);
Warning: Models have images as URLs
 -- If you want to apply detectors to a LOT of images, download the PASCAL VOC2007 dataset locally and call :
[models]=esvm_update_voc_models_to_local(models,local_dir);
 --image 00001/00001: 229 exemplars took 5.235sec, #windows=00145, max=-0.679 
Applying M-matrix to 1 images:.took 0.013sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=3.311
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001: 229 exemplars took 4.473sec, #windows=00071, max=-0.747 
Applying M-matrix to 1 images:.took 0.006sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=1.643
Warning: loading image from URL
Warning: loading image from URL

Create URL-based set of images, and apply bus detector

%Show image filepaths
cat(1,test_set{1:5})

%Apply detector
esvm_apply_and_show_exemplars(test_set(1:5), models, M, params);
ans =

http://people.csail.mit.edu/~tomasz/VOCdevkit/VOC2007/JPEGImages/000014.jpg
http://people.csail.mit.edu/~tomasz/VOCdevkit/VOC2007/JPEGImages/000054.jpg
http://people.csail.mit.edu/~tomasz/VOCdevkit/VOC2007/JPEGImages/000188.jpg
http://people.csail.mit.edu/~tomasz/VOCdevkit/VOC2007/JPEGImages/000195.jpg
http://people.csail.mit.edu/~tomasz/VOCdevkit/VOC2007/JPEGImages/000231.jpg

Warning: Models have images as URLs
 -- If you want to apply detectors to a LOT of images, download the PASCAL VOC2007 dataset locally and call :
[models]=esvm_update_voc_models_to_local(models,local_dir);
 --image 00001/00001:Warning: loading image from URL
 229 exemplars took 4.785sec, #windows=00080, max=-0.823 
Applying M-matrix to 1 images:.took 0.004sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=0.544
Warning: loading image from URL
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001:Warning: loading image from URL
 229 exemplars took 5.344sec, #windows=00144, max=-0.542 
Applying M-matrix to 1 images:.took 0.009sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=6.454
Warning: loading image from URL
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001:Warning: loading image from URL
 229 exemplars took 3.772sec, #windows=00082, max=-0.558 
Applying M-matrix to 1 images:.took 0.004sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=1.250
Warning: loading image from URL
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001:Warning: loading image from URL
 229 exemplars took 5.711sec, #windows=00087, max=-0.793 
Applying M-matrix to 1 images:.took 0.004sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=1.990
Warning: loading image from URL
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001:Warning: loading image from URL
 229 exemplars took 5.756sec, #windows=00098, max=-0.749 
Applying M-matrix to 1 images:.took 0.008sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=1.673
Warning: loading image from URL
Warning: loading image from URL
Warning: loading image from URL

Set image path directory, and apply bus detector

Idirectory = '/v2/SUN/Images/b/bus_depot/outdoor/';
if isdir(Idirectory)
  Ilist = get_file_list(Idirectory);
  Ilist = Ilist(1:min(5,length(Ilist)));

  %Virtually resize all images to 200 max dim
  MAXDIM = 500;
  Ilist = cellfun2(@(x)(@()imresize_max(convert_to_I(x),MAXDIM)), ...
                   Ilist);
  esvm_apply_and_show_exemplars(Ilist, models, M, params);
else
  fprintf(1,'Note: not applying because %s is not a directory\n',...
          Idirectory);
end
Warning: Models have images as URLs
 -- If you want to apply detectors to a LOT of images, download the PASCAL VOC2007 dataset locally and call :
[models]=esvm_update_voc_models_to_local(models,local_dir);
 --image 00001/00001: 229 exemplars took 4.388sec, #windows=00029, max=-0.876 
Applying M-matrix to 1 images:.took 0.002sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=0.154
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001: 229 exemplars took 4.682sec, #windows=00124, max=-0.768 
Applying M-matrix to 1 images:.took 0.012sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=2.509
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001: 229 exemplars took 4.340sec, #windows=00082, max=-0.702 
Applying M-matrix to 1 images:.took 0.007sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=0.784
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001: 229 exemplars took 5.107sec, #windows=00122, max=-0.667 
Applying M-matrix to 1 images:.took 0.006sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=1.524
Warning: loading image from URL
Warning: loading image from URL
 --image 00001/00001: 229 exemplars took 5.702sec, #windows=00281, max=-0.741 
Applying M-matrix to 1 images:.took 0.016sec
Applying NMS (OS thresh=0.300)
Propagating scores onto raw detections
Showing detection # 1, score=2.052
Warning: loading image from URL
Warning: loading image from URL