-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautoclust_initial.m
executable file
·65 lines (61 loc) · 2.23 KB
/
autoclust_initial.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% Author: Carl Doersch (cdoersch at cs dot cmu dot edu)
% Before negative mining, initialize each detector using
% ds.batch.round.posFeatures
% as positive examples and ds.initFeatsNeg as negatives.
% ds.batch.round.assignedClust specifies which positive
% examples belong to which detector (detector ids in
% ds.batch.round.selectedClust). Resulting detectors
% are saved in ds.batch.round.firstDet. ds.batch.round.firstResult
% contains additional metadata about the scores of positives, etc.
myaddpath();
clustId=ds.batch.round.selectedClust(dsidx);
%if(~dsfield(ds,'initPatchesNeg'))
dsload('ds.init*');
dsload('ds.batch.round.assignedClust');
dsload('ds.batch.round.posFeatures');
%dsload('ds.batch.round.posPatches');
%end
%ds
%ds.savestate
posInds = ds.batch.round.assignedClust == clustId;
%posFeatures = ds.batch.round.posFeatures(posInds, :);
%features = [posFeatures; ds.initFeatsNeg];
%patchpos=ds.batch.round.posPatches(posInds);
%if(isfield(patchpos,'clust'))
% patchpos=rmfield(patchpos,'clust');
%end
%if(isfield(patchpos,'detScore'))
% patchpos=rmfield(patchpos,'detScore');
%end
%if(isfield(patchpos,'imidx'))
% isvalid=ismember([patchpos.imidx],ds.batch.round.totrainon);
%end
%negpats=ds.initPatchesNeg;
%if(isfield(negpats,'imidx'))
% isvalid=ismember([negpats.imidx],ds.batch.round.totrainon);
%else
% isvalid=true(size(negFeatures,1))
%end
%negFeatures=ds.initFeatsNeg;
%if(isfield(patchpos,'imidx'))
% isvalid=ismember([patchpos.imidx],ds.batch.round.totrainon);
%else
% isvalid=true(size(patchpos,1))
%end
%posFeatures=posFeatures(isvalid,:)
%patches = [patchpos(:);ds.initPatchesNeg];
labels = [ones(sum(posInds), 1); ...
ones(size(ds.initFeatsNeg, 1), 1) * -1];
features=[ds.batch.round.posFeatures(posInds, :);ds.initFeatsNeg];
fprintf('Training SVM ... ');
size(labels)
size(features)
ds.conf.params.svmflags
model = mySvmTrain(labels, features, ds.conf.params.svmflags, false);
[predictedLabels, accuracy, decision] = mySvmPredict(labels, ...
features, model);
%'firstDetsavestate'
%ds.savestate.batch.round.firstDet{2}
ds.batch.round.firstDet{dsidx}=model;
ds.batch.round.firstResult{dsidx} = struct('predictedLabels', predictedLabels, 'accuracy', ...
accuracy, 'decision', decision);