-
Notifications
You must be signed in to change notification settings - Fork 9
/
setdataset.m
51 lines (51 loc) · 1.97 KB
/
setdataset.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
% set the dataset that the algorithm uses. In particular, this
% affects the behavior of getimgs and getimg.
%
% idx is a unique integer to identify the dataset.
%
% imgs is a struct with the fields:
% - 'fullname': a cell array of labels, such that
% [datadir '/' imgs.fullname{i}] will resolve to the absolute
% path of an image.
% - 'label': (optional) an index into the labelnames cell array
% for the image's label.
%
% imgs will be stored in dswork in the location .ds.imgs{idx}, in memory
% and on disk. idx will be stored in ds.conf.currimset (note that this
% is a relative url; it will only be set for the current directory. getimg
% reads the value from this location).
%
% datadir: the directory containing all of your data
%
% labelnames: names for each label used in the dataset.
%
% weburl: an optional url that points to the web-accessible
% location of datadir, i.e. such that [imgsurl '/' imgs.fullname{i}]
% lets you download the image. Relying on this value is not recommended;
% in the context prediction and discriminative mode seeking projects, it
% is used only in html displays.
%
% This information will be stored in .ds.conf.gbz{idx}.
function setdataset(idx,imgs,datadir,labelnames, weburl)
global ds;
dsup('ds.conf.currimset',idx);
if(nargin>1)
if(~exist('weburl','var'))
weburl='';
end
if(datadir(end)~=filesep)
datadir=[datadir filesep];
end
gbz=struct('labelnames',{labelnames},'imgsurl',weburl,'cutoutdir',datadir,'ctrelname','');
mydir=dspwd;
dscd('.ds');
dsup(['ds.imgs{' num2str(idx) '}'],imgs);
dsup(['ds.conf.gbz{' num2str(idx) '}'],gbz);
dscd(mydir);
dsup(['ds.conf.gbz{' num2str(idx) '}'],gbz);% TODO: this should really only be kept in
% the root .ds.conf; relying on the
% non-root ds.conf creates
% unintuitive behavior.
dssave;
end
end