-
Notifications
You must be signed in to change notification settings - Fork 60
/
generate_valid_ranklabel.m
69 lines (57 loc) · 1.82 KB
/
generate_valid_ranklabel.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
%% set path
start = clock;
data_path = '../../data/Rank_dataset_test/';
level1_path = [data_path,'DF2K_valid_patch_esrgan'];
level2_path = [data_path,'DF2K_valid_patch_srgan'];
level3_path = [data_path,'DF2K_valid_patch_srres'];
ranklabel_path = [data_path,'/DF2K_train_NIQE.txt'];
level1_dir = fullfile(pwd,level1_path);
level2_dir = fullfile(pwd,level2_path);
level3_dir = fullfile(pwd,level3_path);
% Number of pixels to shave off image borders when calcualting scores
shave_width = 4;
% Set verbose option
verbose = true;
%% Calculate scores and save
addpath utils
addpath(genpath(fullfile(pwd,'utils')));
%% Reading file list
level1_file_list = dir([level1_dir,'/*.png']);
level2_file_list = dir([level2_path,'/*.png']);
level3_file_list = dir([level3_path,'/*.png']);
im_num = length(level1_file_list)
%fprintf(' %f\n',im_num);
%% Calculating scores
txtfp = fopen(ranklabel_path,'w');
tic;
pp = parpool('local',28);
pp.IdleTimeout = 9800
disp('Already initialized'); %Strating
fprintf('-------- Strating -----------');
parfor ii=(1:im_num)
[scoresname,scoresniqe] = parcal_niqe(ii,level3_dir,level3_file_list,im_num)
level3_name{ii} = scoresname;
level3_niqe(ii) = scoresniqe;
end
parfor ii=(1:im_num)
[scoresname,scoresniqe] = parcal_niqe(ii,level2_dir,level2_file_list,im_num)
level2_name{ii} = scoresname;
level2_niqe(ii) = scoresniqe;
end
parfor ii=(1:im_num)
[scoresname,scoresniqe] = parcal_niqe(ii,level1_dir,level1_file_list,im_num)
level1_name{ii} = scoresname;
level1_niqe(ii) = scoresniqe;
end
toc;
delete(pp)
txtfp = fopen(ranklabel_path,'w');
for ii=(1:im_num)
fprintf(txtfp,level3_name{ii});
fprintf(txtfp,' %f\n',level3_niqe(ii));
fprintf(txtfp,level2_name{ii});
fprintf(txtfp,' %f\n',level2_niqe(ii));
fprintf(txtfp,level1_name{ii});
fprintf(txtfp,' %f\n',level1_niqe(ii));
end
fclose(txtfp);