-
Notifications
You must be signed in to change notification settings - Fork 3
/
make_imdb.m
96 lines (73 loc) · 2.91 KB
/
make_imdb.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
function make_imdb(imdb_filename, opts)
% -------------------------------------------------------------------------
% Description:
% generate imdb file for training LapCSN
%
% Input:
% - imdb_filename : imdb file name
% - opts : options generated from init_opts()
%
% Citation:
% An efficient deep convolutional laplacian pyramid architecture for CS reconstruction at low sampling ratios
% Wenxue Cui, Heyao Xu, Xinwei Gao, Shengping Zhang, Feng Jiang, Debin Zhao
% IEEE International Conference on Acoustics, Speech and Signal
% Processing (ICASSP), 2018
%
% Contact:
% WenxueCui
% wenxuecui@stu.hit.edu.cn
% Harbin Institute of Technology, China
% -------------------------------------------------------------------------
addpath('utils');
%% settings
img_ext = 'png';
list_dir = fullfile('lists');
output_dir = fullfile('imdb');
if( ~exist(output_dir, 'dir') )
mkdir(output_dir);
end
%% training data
train_list = {};
for d = 1:length(opts.train_dataset)
image_dir = fullfile('datasets', opts.train_dataset{d});
list_filename = fullfile(list_dir, sprintf('%s.txt', opts.train_dataset{d}));
image_list = load_list(list_filename);
num_image = length(image_list);
for i = 1:num_image
filename = fullfile(image_dir, sprintf('%s.%s', image_list{i}, img_ext));
fprintf('%s %d / %d: %s\n', opts.train_dataset{d}, i, num_image, filename);
if( ~exist(filename, 'file') )
error('%s does not exist!\n', filename);
end
train_list{i} = filename;
end
end
num_train = length(train_list);
%% validation data
valid_list = {};
for d = 1:length(opts.valid_dataset)
image_dir = fullfile('datasets', opts.valid_dataset{d}, 'GT');
list_filename = fullfile(list_dir, sprintf('%s.txt', opts.valid_dataset{d}));
image_list = load_list(list_filename);
num_image = length(image_list);
for i = 1:num_image
filename = fullfile(image_dir, sprintf('%s.%s', image_list{i}, img_ext));
fprintf('%s %d / %d: %s\n', opts.valid_dataset{d}, i, num_image, image_list{i});
if( ~exist(filename, 'file') )
error('%s does not exist!\n', filename);
end
valid_list{i} = filename;
end
end
num_valid = length(valid_list);
fprintf('Collect %d training images\n', num_train);
fprintf('Collect %d validation images\n', num_valid);
%% build imdb
clear images;
images.filename = [train_list'; valid_list'];
images.set = 2 * ones(1, num_train + num_valid); % set = 2 for validation data
images.set(1:num_train) = 1; % set = 1 for training data
%% save imdb
fprintf('Save %s\n', imdb_filename);
save(imdb_filename, 'images', '-v7.3');
end