Skip to content
Browse files

update function names again

  • Loading branch information...
1 parent 54ad76c commit 0ffe88d67c77bd0cfce101f031bba99327b4058b @quantombone quantombone committed Jan 18, 2012
View
11 esvm_apply_and_show_exemplars.m
@@ -1,7 +1,9 @@
-function esvm_apply_and_show_exemplars(imageset, models, M)
+function esvm_apply_and_show_exemplars(imageset, models, M, params)
% We apply the ensemble of Exemplar-SVMs represented by [models,M] onto
% the sequence of images [imageset], and display images without
-% saving anything
+% saving anything. Takes as input optional [params], which default
+% to the default ones.
+%
% Copyright (C) 2011-12 by Tomasz Malisiewicz
% All rights reserved.
%
@@ -36,7 +38,10 @@ function esvm_apply_and_show_exemplars(imageset, models, M)
end
end
-params = esvm_get_default_params;
+if ~exist('params','var')
+ params = esvm_get_default_params;
+end
+
params.calibration_propagate_onto_raw = 1;
for i = 1:length(imageset)
%Get local detections
View
17 esvm_demo_apply.m
@@ -12,6 +12,13 @@
%% 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/';
@@ -21,19 +28,21 @@
%% Load one image, and apply bus detector
I1 = imread('000858.jpg');
-esvm_apply_and_show_exemplars(I1, models, M);
+esvm_apply_and_show_exemplars(I1, models, M, params);
%% 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);
+esvm_apply_and_show_exemplars(Iarray, models, M, params);
%% 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);
+esvm_apply_and_show_exemplars(test_set(1:5), models, M, params);
%% Set image path directory, and apply bus detector
Idirectory = '/v2/SUN/Images/b/bus_depot/outdoor/';
@@ -45,7 +54,7 @@
MAXDIM = 500;
Ilist = cellfun2(@(x)(@()imresize_max(convert_to_I(x),MAXDIM)), ...
Ilist);
- esvm_apply_and_show_exemplars(Ilist, models, M);
+ esvm_apply_and_show_exemplars(Ilist, models, M, params);
else
fprintf(1,'Note: not applying because %s is not a directory\n',...
Idirectory);
View
30 esvm_demo_train_synthetic.m
@@ -12,38 +12,44 @@
addpath(genpath(pwd))
%% Create a synthetic dataset of circles on a random background
-Npos = 100;
-Nneg = 100;
+Npos = 20;
+Nneg = 20;
[pos_set,neg_set] = esvm_generate_dataset(Npos,Nneg);
+models_name = 'circle';
+
%% Set exemplar-initialization parameters
params = esvm_get_default_params;
params.init_params.sbin = 4;
params.init_params.MAXDIM = 6;
params.model_type = 'exemplar';
params.dataset_params.display = 1;
+
%if localdir is commented out, no local saving happens
-%params.dataset_params.localdir = '/nfs/baikal/tmalisie/synthetic/';
+params.dataset_params.localdir = '/nfs/baikal/tmalisie/synthetic/';
%%Initialize exemplar stream
stream_params.stream_set_name = 'trainval';
-stream_params.stream_max_ex = 20;
+stream_params.stream_max_ex = 1;
stream_params.must_have_seg = 0;
stream_params.must_have_seg_string = '';
stream_params.model_type = 'exemplar'; %must be scene or exemplar
-%assign pos_set as variable
+%assign pos_set as variable, because we need it for visualization
stream_params.pos_set = pos_set;
+stream_params.cls = models_name;
%% Get the positive stream
e_stream_set = esvm_get_pascal_stream(stream_params, ...
params.dataset_params);
+% break it up into a set of held out negatives, and the ones used
+% for mining
val_neg_set = neg_set((Nneg/2+1):end);
neg_set = neg_set(1:((Nneg/2)));
%% Initialize Exemplars
initial_models = esvm_initialize_exemplars(e_stream_set, params, ...
- 'initial');
+ models_name);
%% Set exemplar-svm training parameters
train_params = params;
@@ -52,38 +58,38 @@
train_params.detect_exemplar_nms_os_threshold = 1.0;
train_params.detect_max_windows_per_exemplar = 100;
-train_params.CACHE_FILE = 1;
%% Perform Exemplar-SVM training
[models] = esvm_train_exemplars(initial_models, ...
neg_set, train_params);
+%% Create validation set from positives and extra negatives
val_params = params;
val_params.detect_exemplar_nms_os_threshold = 0.5;
val_params.gt_function = @esvm_load_gt_function;
val_set = cat(1, pos_set(:), val_neg_set(:));
-val_params.val_set = val_set;
val_set_name = 'valset';
%% Apply trained exemplars on validation set
val_grid = esvm_detect_imageset(val_set, models, val_params, val_set_name);
%% Perform Platt calibration and M-matrix estimation
-M = esvm_perform_calibration(val_grid, models, val_params);
+M = esvm_perform_calibration(val_grid, val_set, models, val_params);
%% Define test-set
+Ntest = 20;
test_params = params;
test_params.detect_exemplar_nms_os_threshold = 0.5;
-Ntest = 200;
[stream_test] = esvm_generate_dataset(Ntest);
test_set = cellfun2(@(x)x.I, stream_test);
+test_set_name = 'testset';
%% Apply on test set
-test_grid = esvm_detect_imageset(test_set, models, test_params);
+test_grid = esvm_detect_imageset(test_set, models, test_params, test_set_name);
%% Apply calibration matrix to test-set results
test_struct = esvm_pool_exemplar_dets(test_grid, models, M, test_params);
%% Show top detections
maxk = 20;
allbbs = esvm_show_top_dets(test_struct, test_grid, test_set, models, ...
- params, maxk);
+ params, maxk, test_set_name);
View
21 esvm_detect.m
@@ -254,30 +254,31 @@
sizes2 = cellfun(@(x)x.model.hg_size(2),models);
S = [max(sizes1(:)) max(sizes2(:))];
-templates = zeros(S(1),S(2),features,length(models));
-templates_x = zeros(S(1),S(2),features,length(models));
-template_masks = zeros(S(1),S(2),features,length(models));
+fsize = params.init_params.features();
+templates = zeros(S(1),S(2),fsize,length(models));
+templates_x = zeros(S(1),S(2),fsize,length(models));
+template_masks = zeros(S(1),S(2),fsize,length(models));
for i = 1:length(models)
- t = zeros(S(1),S(2),features);
+ t = zeros(S(1),S(2),fsize);
t(1:models{i}.model.hg_size(1),1:models{i}.model.hg_size(2),:) = ...
models{i}.model.w;
templates(:,:,:,i) = t;
- template_masks(:,:,:,i) = repmat(double(sum(t.^2,3)>0),[1 1 features]);
+ template_masks(:,:,:,i) = repmat(double(sum(t.^2,3)>0),[1 1 fsize]);
if (~isempty(params.nnmode)) || ...
(isfield(params,'wtype') && ...
strcmp(params.wtype,'dfun')==1)
- x = zeros(S(1),S(2),features);
+ x = zeros(S(1),S(2),fsize);
x(1:models{i}.model.hg_size(1),1:models{i}.model.hg_size(2),:) = ...
reshape(models{i}.model.x(:,1),models{i}.model.hg_size);
templates_x(:,:,:,i) = x;
end
end
-%maskmat = repmat(template_masks,[1 1 1 features]);
+%maskmat = repmat(template_masks,[1 1 1 fsize]);
%maskmat = permute(maskmat,[1 2 4 3]);
%templates_x = templates_x .* maskmat;
@@ -288,7 +289,7 @@
pyr_N = cellfun(@(x)prod([size(x,1) size(x,2)]-S+1),t.hog);
sumN = sum(pyr_N);
-X = zeros(S(1)*S(2)*features,sumN);
+X = zeros(S(1)*S(2)*fsize,sumN);
offsets = cell(length(t.hog), 1);
uus = cell(length(t.hog),1);
vvs = cell(length(t.hog),1);
@@ -298,7 +299,7 @@
s = size(t.hog{i});
NW = s(1)*s(2);
ppp = reshape(1:NW,s(1),s(2));
- curf = reshape(t.hog{i},[],features);
+ curf = reshape(t.hog{i},[],fsize);
b = im2col(ppp,[S(1) S(2)]);
offsets{i} = b(1,:);
@@ -317,7 +318,7 @@
uus = cat(2,uus{:});
vvs = cat(2,vvs{:});
-% m.model.w = zeros(S(1),S(2),features);
+% m.model.w = zeros(S(1),S(2),fsize);
% m.model.b = 0;
% temp_params = params;
% temp_params.detect_save_features = 1;
View
3 esvm_initialize_exemplars.m
@@ -150,7 +150,6 @@
allfiles{i} = m;
end
-
% %Print the bounding box overlap between the initial window and
% %the final window
% finalos = getosmatrix_bb(m.gt_box, m.model.bb(1,:));
@@ -162,7 +161,7 @@
%Show the initialized exemplars
if params.dataset_params.display == 1
- show_exemplar_frames({m}, 1, params.dataset_params);
+ esvm_show_exemplar_frames({m}, 1, params.dataset_params);
drawnow
snapnow;
end
View
18 esvm_perform_calibration.m
@@ -1,4 +1,4 @@
-function M = esvm_perform_calibration(grid, models, params, CACHE_FILES)
+function M = esvm_perform_calibration(grid, val_set, models, params)
% 1. Perform LABOO calibration procedure and 2. Learn a combination
% matrix M which multiplexes the detection results (by compiling
% co-occurrence statistics on true positives)
@@ -10,20 +10,14 @@
% available under the terms of the MIT license (see COPYING file).
% Project homepage: https://github.com/quantombone/exemplarsvm
-if isfield(params,'CACHE_BETAS') && params.CACHE_BETAS==1%~exist('CACHE_FILES','var')
- CACHE_FILES = 1;
-else
- CACHE_FILES = 0;
-end
-
%% Perform calibration
-betas = esvm_perform_platt_calibration(grid, models, ...
- params, CACHE_FILES);
+betas = esvm_perform_platt_calibration(grid, val_set, models, ...
+ params);
+%% Estimate the co-occurrence matrix M
if ~(isfield(params,'SKIP_M') && params.SKIP_M==1)
- %% Estimate the co-occurrence matrix M
- [M] = esvm_estimate_M(grid, models, params, CACHE_FILES);
-
+ M = esvm_estimate_M(grid, models, params);
end
+%concatenate results
M.betas = betas;
View
28 esvm_show_top_dets.m
@@ -1,13 +1,11 @@
function allbbs = esvm_show_top_dets(test_struct, grid, ...
test_set, models, params, ...
maxk, set_name)
-
-
% Show maxk top detections for [models] where [grid] is the set of
% detections from the set [test_set], [test_struct] contains final
-% boxes after calibration and is obtained from applying calibration
-% If [set_name] is present, then results are saved based on naming
-% convention into www/ subfolder
+% boxes after pooling and calibration. If [dataset_params.localdir] is
+% present, then results are saved based on naming convention into a
+% "www" subfolder. maxk is the number of top detections we show
%
% NOTE: this function requires some cleanup, but is functional
%
@@ -20,13 +18,13 @@
allbbs = [];
-if exist('set_name','var') && length(set_name)>0
+if length(params.dataset_params.localdir) > 0
CACHE_FILES = 1;
else
CACHE_FILES = 0;
- set_name = '';
end
+
%Default exemplar-inpainting show mode
%SHOW_MODE = 1;
@@ -111,18 +109,20 @@
wwwdir = sprintf('%s/www/%s.%s%s/',params.dataset_params.localdir,...
set_name, ...
models{1}.models_name,test_struct.calib_string);
- if ~exist(wwwdir,'dir') && exist('CACHE_FILES','var') && (CACHE_FILES == 1)
+ if ~exist(wwwdir,'dir') && (CACHE_FILES == 1)
mkdir(wwwdir);
end
- filer = sprintf('%s/%05d%s',wwwdir,k,suffix);
+ filer = sprintf('%s/%05d%s.png',wwwdir,k,suffix);
filerlock = [filer '.lock'];
- if 0 %fileexists(filer) || (mymkdir_dist(filerlock) == 0)
+
+ if CACHE_FILES && (fileexists(filer) || (mymkdir_dist(filerlock) == 0))
counter = counter + 1;
+ fprintf(1,'Already showed detection # %d, score=%.3f\n', k, bbs(bb(counter),end));
continue
end
- fprintf(1,'Showing top detection %d\n', k);
+ fprintf(1,'Showing detection # %d, score=%.3f\n', k, bbs(bb(counter),end));
allbbs(k,:) = bbs(bb(counter),:);
curb = bb(counter);
@@ -235,9 +235,9 @@
drawnow
snapnow
- if exist('CACHE_FILES','var') && CACHE_FILES == 1
+ if CACHE_FILES == 1
%print(gcf,'-depsc2',filer);
- print(gcf,'-dpng',[filer '.png']);
+ print(gcf,'-dpng',filer);
%finalfile = strrep(filer,'.eps','.pdf');
%unix(sprintf('zsh "ps2pdf -dEPSCrop -dPDFSETTINGS=/prepress %s %s"',...
% filer,finalfile));
@@ -246,7 +246,7 @@
% unix(sprintf('rm %s',filer));
%end
- if exist(filerlock,'dir')
+ if CACHE_FILES && exist(filerlock,'dir')
rmdir(filerlock);
end
end
View
28 esvm_train_exemplars.m
@@ -52,9 +52,10 @@
DUMPDIR = sprintf('%s/www/svs/%s/',params.dataset_params.localdir, ...
new_models_name);
-if CACHE_FILE==1 && params.dataset_params.display ==1 && ~exist(DUMPDIR,'dir')
- mkdir(DUMPDIR);
-end
+%display of SV pdfs disabled
+%if CACHE_FILE==1 && params.dataset_params.display ==1 && ~exist(DUMPDIR,'dir')
+% mkdir(DUMPDIR);
+%end
final_directory = ...
sprintf('%s/models/%s/',params.dataset_params.localdir,...
@@ -65,9 +66,6 @@
mkdir(final_directory);
end
-%NOTE: why was this here?
-%mining_params.final_directory = final_directory;
-
% randomize chunk orderings
if CACHE_FILE == 1
myRandomize;
@@ -76,11 +74,6 @@
ordering = 1:length(models);
end
-%always use random ordering
-%if params.dataset_params.display == 1
-% ordering = 1:length(ordering);
-%end
-
models = models(ordering);
allfiles = cell(length(models), 1);
for i = 1:length(models)
@@ -89,23 +82,14 @@
[complete_file] = sprintf('%s/%s.mat',final_directory,m.name);
[basedir, basename, ext] = fileparts(complete_file);
-
- % Create a naming scheme for saving files
- %filer2fill = sprintf('%s/%%s.%s.mat',final_directory, ...
- % m.name);
-
filer2fill = sprintf('%s/%%s.%s.mat',basedir,basename);
- filer2final = sprintf('%s/%s.mat',basedir,basename);
-
- %filer2final = sprintf('%s/%s.mat',final_directory, ...
- % m.name);
+ filer2final = sprintf('%s/%s.mat',basedir,basename);
allfiles{i} = filer2final;
% Check if we are ready for an update
filerlock = [filer2final '.mining.lock'];
-
if CACHE_FILE == 1
if fileexists(filer2final) || (mymkdir_dist(filerlock) == 0)
continue
@@ -148,8 +132,6 @@
m.total_mines = total_mines;
m = esvm_mine_train_iteration(m, params.training_function);
- %total_mines = m.mining_stats{end}.total_mines;
-
if ((total_mines >= params.train_max_mined_images) || ...
(isempty(m.mining_queue))) || ...
(m.iteration == params.train_max_mine_iterations)
View
10 features/esvm_pyramid.m
@@ -9,15 +9,13 @@
% available under the terms of the MIT license (see COPYING file).
% Project homepage: https://github.com/quantombone/exemplarsvm
-
-if isscalar(params)
+if isnumeric(params)
sbin = params;
elseif isfield(params,'sbin')
sbin = params.sbin;
elseif isfield(params,'init_params') && ...
- isfield(params.init_params,'params') && ...
- isscalar(params.init_params.params)
-
+ isfield(params.init_params,'sbin') && ...
+ isnumeric(params.init_params.sbin)
sbin = params.init_params.sbin;
else
error('esvm_pyramid: cannot find sbin inside params');
@@ -69,7 +67,7 @@
return;
end
- feat{i} = params.features(scaled,sbin);
+ feat{i} = params.init_params.features(scaled,sbin);
%if we get zero size feature, backtrack one, and dont produce any
%more levels
View
10 internal/esvm_estimate_M.m
@@ -1,5 +1,4 @@
-function M = esvm_estimate_M(grid, models, params, ...
- CACHE_FILES)
+function M = esvm_estimate_M(grid, models, params)
% Given a bunch of detections, learn the M boosting matrix, which
% makes a final boxes's score depend on the co-occurrence of certain
% "friendly" detections
@@ -14,7 +13,9 @@
neighbor_thresh = params.calibration_neighbor_thresh;
count_thresh = params.calibration_count_thresh;
-if ~exist('CACHE_FILES','var')
+if length(params.dataset_params.localdir) > 0
+ CACHE_FILES = 1;
+else
CACHE_FILES = 0;
end
@@ -159,12 +160,13 @@
plot(scores,os,'r.')
xlabel('Detection Score')
ylabel('OS wrt gt')
+ title('w/o calibration')
subplot(1,2,2)
plot(r,os,'r.')
xlabel('Detection Score')
ylabel('OS wrt gt')
- title('w/ M-matrx')
+ title('w/ M-matrix')
drawnow
snapnow
View
44 internal/esvm_get_pascal_stream.m
@@ -13,20 +13,21 @@
if ~exist('dataset_params','var')
dataset_params.localdir = '';
- stream_params.cache_file = 0;
-end
-
-if ~isfield(stream_params,'cache_file')
- stream_params.cache_file = 0;
+ CACHE_FILE = 0;
+elseif exist('dataset_params','var') && isfield(dataset_params,'localdir') ...
+ && length(dataset_params.localdir)>0
+ CACHE_FILE = 1;
+else
+ dataset_params.localdir = '';
+ CACHE_FILE = 0;
end
if ~isfield(stream_params,'cls')
- stream_params.cls='';
+ stream_params.cls = '';
end
-
basedir = sprintf('%s/models/streams/',dataset_params.localdir);
-if stream_params.cache_file == 1 && ~exist(basedir,'dir')
+if CACHE_FILE == 1 && ~exist(basedir,'dir')
mkdir(basedir);
end
streamname = sprintf('%s/%s-%s-%d-%s%s.mat',...
@@ -36,34 +37,32 @@
stream_params.model_type,...
stream_params.must_have_seg_string);
-if stream_params.cache_file && fileexists(streamname)
+if CACHE_FILE && fileexists(streamname)
fprintf(1,'Loading %s\n',streamname);
load(streamname);
return;
end
-if length(stream_params.cls)>0
+if length(stream_params.cls)>0 && isfield(dataset_params,'clsimgsetpath') ...
+ && isfield(stream_params,'stream_set_name')
%% Load ids of all images in trainval that contain cls
[ids,gt] = textread(sprintf(dataset_params.clsimgsetpath,stream_params.cls,...
stream_params.stream_set_name),...
'%s %d');
ids = ids(gt==1);
all_recs = cellfun2(@(x)sprintf(dataset_params.annopath,x),ids);
- %BUG: make sure this works on voc training regular style
-
-
+ %BUG(TJM):??? make sure this works on voc training regular style
else
+
%assume that we don't have cls, we have a cell array of these
-
all_recs = cellfun2(@(x)x.recs,stream_params.pos_set);
all_I = cellfun2(@(x)x.I,stream_params.pos_set);
ids = cell(size(all_recs));
for i = 1:length(ids)
ids{i} = sprintf('%08d',i);
end
-
end
@@ -77,9 +76,9 @@
else
recs = all_recs{i};
end
- %recs = PASreadrecord(sprintf(dataset_params.annopath,curid));
+
if stream_params.must_have_seg && (recs.segmented == 0)
- %SKip over unsegmented images
+ %skip over unsegmented images
continue
end
@@ -89,7 +88,6 @@
filename = all_I{i};
end
-
if strcmp(stream_params.model_type,'exemplar')
for objectid = 1:length(recs.objects)
isinclass = ismember({recs.objects(objectid).class},{stream_params.cls});
@@ -100,9 +98,7 @@
if (recs.objects(objectid).difficult==1) | ...
~isinclass
continue
- end
-
-
+ end
fprintf(1,'.');
res.I = filename;
@@ -119,7 +115,7 @@
fg{end+1} = res;
if length(fg) == stream_params.stream_max_ex
- if stream_params.cache_file == 1
+ if CACHE_FILE == 1
save(streamname,'fg');
end
return;
@@ -146,7 +142,7 @@
fg{end+1} = res;
if length(fg) == stream_params.stream_max_ex
- if stream_params.cache_file == 1
+ if CACHE_FILE == 1
save(streamname,'fg');
end
return;
@@ -156,6 +152,6 @@
end
end
-if stream_params.cache_file == 1
+if CACHE_FILE == 1
save(streamname,'fg');
end
View
11 internal/esvm_initialize_goalsize_exemplar.m
@@ -41,7 +41,9 @@
I_real_pad = pad_image(I, ARTPAD);
%Get the hog feature pyramid for the entire image
+clear params;
params.detect_levels_per_octave = 10;
+params.init_params = init_params;
[f_real,scales] = esvm_pyramid(I_real_pad, params);
%Extract the regions most overlapping with Ibox from each level in the pyramid
@@ -63,7 +65,7 @@
model.x = curfeats;
%Fire inside self-image to get detection location
-[model.bb, model.x] = get_target_bb(model, I);
+[model.bb, model.x] = get_target_bb(model, I, init_params);
%Normalized-HOG initialization
model.w = reshape(model.x,size(model.w)) - mean(model.x(:));
@@ -145,8 +147,9 @@
end
-function [target_bb,target_x] = get_target_bb(model,I)
-%Get the id of the top detection
+function [target_bb,target_x] = get_target_bb(model, I, init_params)
+%Get the bounding box of the top detection
+
mmm{1}.model = model;
mmm{1}.model.hg_size = size(model.w);
localizeparams.detect_keep_threshold = -100000.0;
@@ -156,7 +159,7 @@
localizeparams.detect_add_flip = 0;
localizeparams.detect_pyramid_padding = 5;
localizeparams.dfun = 0;
-
+localizeparams.init_params = init_params;
[rs,t] = esvm_detect(I,mmm,localizeparams);
target_bb = rs.bbs{1}(1,:);
View
3 internal/esvm_load_result_grid.m
@@ -49,10 +49,9 @@
%if we got here, then the final file isn't there, and we were able
%to write a lock file successfully
-
baser = sprintf('%s/detections/%s-%s/',dataset_params.localdir,setname, ...
models_name);
-fprintf(1,'base directory: %s\n',baser);
+%fprintf(1,'base directory: %s\n',baser);
%with the dir command partial results could be loaded
%files = dir([baser 'result*mat']);
View
34 internal/esvm_perform_platt_calibration.m
@@ -1,9 +1,12 @@
-function [betas] = esvm_perform_platt_calibration(grid, models, ...
- params, CACHE_FILES)
+function [betas] = esvm_perform_platt_calibration(grid, imageset, models, ...
+ params)
% Perform calibration by learning the sigmoid parameters (linear
-% transformation of svm scores) for each model independently. If we
-% perform an operation such as NMS, we will now have "comparable"
-% scores. This is performed on the 'trainval' set for PASCAL VOC.
+% transformation of svm scores) for each model independently. This
+% type of SVM classifier calibration is due to John Platt who used
+% this trick to convert SVM output scors into probabilities for
+% comparison. If we perform an operation such as NMS, we will now
+% have "comparable" scores. This is performed on the 'trainval' set
+% for PASCAL VOC.
%
% Copyright (C) 2011-12 by Tomasz Malisiewicz
% All rights reserved.
@@ -18,7 +21,9 @@
return;
end
-if ~exist('CACHE_FILES','var')
+if length(params.dataset_params.localdir) > 0
+ CACHE_FILES = 1;
+else
CACHE_FILES = 0;
end
@@ -226,26 +231,29 @@
figure(1)
clf
subplot(1,2,1)
- plot(all_scores,all_os,'r.')
+
xs = linspace(min(all_scores),max(all_scores),1000);
fx = @(x)(1./(1+exp(-beta(1)*(x-beta(2)))));
- hold on
plot(xs,fx(xs),'b','LineWidth',2)
+ hold on
+ plot(all_scores,all_os,'r.','MarkerSize',14)
+
axis([min(xs) max(xs) 0 1])
xlabel('SVM score')
ylabel(sprintf('Max Overlap Score with %s',models{exid}.cls))
title(sprintf('Learned Sigmoid \\beta=[%.3f %.3f]',beta(1), ...
beta(2)))
+
subplot(1,2,2)
Iex = convert_to_I(models{exid}.I);
imagesc(Iex)
plot_bbox(models{exid}.gt_box)
axis image
axis off
- title(sprintf('Topdets Calibration Ex %s.%d.%s',...
+ title(sprintf('Exemplar %s.%d.%s',...
models{exid}.curid,...
models{exid}.objectid, ...
models{exid}.cls))
@@ -265,15 +273,17 @@
models{exid}.model.svbbs = bbs_show;
m2 = models(exid);
- if isfield(params,'val_set')
- m2{1}.train_set = params.val_set;
+ if length(imageset) > 0
+ m2{1}.train_set = imageset;
m2{1}.model.svbbs(:,6) = 1;
m2{1}.model.svxs = [];
figure(445)
clf
imagesc(esvm_show_det_stack(m2{1},8))
+ axis image
+ axis off
drawnow
- title(sprintf('Calib Ex %s.%d.%s',...
+ title(sprintf('Topdets Ex %s.%d.%s',...
models{exid}.curid,...
models{exid}.objectid, ...
models{exid}.cls))
View
20 util/display/show_exemplar_frames.m → internal/esvm_show_exemplar_frames.m
@@ -1,14 +1,15 @@
-function show_exemplar_frames(allmodels, N_PER_PAGE, dataset_params)
-%% Draw the initialized exemplar frames as a 1x3 row of 3 images
+function esvm_show_exemplar_frames(allmodels, N_PER_PAGE, dataset_params)
+% Draw the initialized exemplar frames as a 1x3 row of 3 images
% Shows these 3 fields: input+gtbb+template, template mask+gtbb, HOG descriptor
% The visualization really shows what the template region is, and
% its relation to the ground-truth selection region
-
-% if ~iscell(models)
-% m = models;
-% clear models;
-% models{1} = m;
-% end
+%
+% 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
if ~exist('dataset_params','var')
dataset_params = [];
@@ -63,14 +64,13 @@ function show_exemplar_frames(allmodels, N_PER_PAGE, dataset_params)
curos,range(u)+1,range(v)+1));
subplot(N,3,o+3)
- hogim = HOGpicture(repmat(m.model.mask,[1 1 features]).* ...
+ hogim = HOGpicture(repmat(m.model.mask,[1 1 size(m.model.w,3)]).* ...
m.model.w);
imagesc(hogim)
axis image
axis off
grid on
title('HOG features')
drawnow
-
end
end
View
2 internal/esvm_update_svm.m
@@ -23,7 +23,7 @@
end
if length(m.model.mask(:)) ~= numel(m.model.w)
- m.model.mask = repmat(m.model.mask,[1 1 features]);
+ m.model.mask = repmat(m.model.mask,[1 1 m.model.hg_size(3)]);
m.model.mask = logical(m.model.mask(:));
end

0 comments on commit 0ffe88d

Please sign in to comment.
Something went wrong with that request. Please try again.