-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
install_p2.m
153 lines (132 loc) · 6.38 KB
/
install_p2.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2019 Mahmoud Afifi
% York University, Canada
% Email: [email protected] - [email protected]
% Permission is hereby granted, free of charge, to any person obtaining
% a copy of this software and associated documentation files (the
% "Software"), to deal in the Software with restriction for its use for
% research purpose only, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included
% in all copies or substantial portions of the Software.
%
% The Software is provided "as is", without warranty of any kind.
%
% Please cite the following work if this program is used:
% Mahmoud Afifi, Brian Price, Scott Cohen, and Michael S. Brown, Image Recoloring Based on Object Color Distributions, Eurographics 2019 - Short Papers, 2019
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
function install_p2()
%%
% Our method is a data-driven approach that requires Scene Parsing dataset
% to be installed. Also, our algorithm requires pre-computed files to be
% located in specific directories. These files include the distribution of
% object color distributions (DoD) as explained in the paper. We also rely
% on the earth mover's distance (EMD) to compute the similarity between input
% color palettes and our training color palettes. To do that, we need to
% compile the mex file of EMD. Finally, our algorithm requires an
% object-based semantic segmentation model to run. We use RefineNet in our
% experiments. Accordingly, we require to install and setup MatConvNet and
% RefineNet.
% The installation includes five parts which are:
% 1- Adding paths to Matlab
% 2- Compile EMD mex files
% 3- Downloading Scene Parsing dataset
% 4- Install our pre-computed data (DoDs)
% 5- Install and setup MatConvNet and RefineNet.
% This function will do the last part for you. Be sure that Git is already
% installed. Be sure also that you already installed Visual Studio 2015 or
% greater for Windows or GCC 4.8 and LibJPEG for Linux OS (that is required
% to compile Mex files of MatConvNet. For more information, please visit:
% http://www.vlfeat.org/matconvnet/install/
% Please choose one of the mentioned compilers as the compiler for Mex
% files based on your OS. To choose a compiler, please use the following
% Matlab commands: mex -setup C++ and mex -setup C'
%%
% If you want to do the installation manually, please follow the
% instructions in the ReadMe file
%%
current = pwd;
disp('----------------------------------------------');
disp('Part 5/5 (setup MatConvNet and RefineNet)...');
disp('----------------------------------------------');
disp('Now, we will install MatConvNet and RefineNet in SS_CNN directory. Be sure that Git is already installed.');
disp('This part requires Visual Studio 2015 or greater for Windows OS or GCC 4.8 and LibJPEG for Linux OS. For more information, please visit: http://www.vlfeat.org/matconvnet/install/');
disp('Please choose one of the mentioned compilers as the compiler for Mex files based on your OS');
disp('To choose a compiler, please use the following Matlab commands: mex -setup C++ and mex -setup C');
prompt =('Continue? [Y/N]:');
str = input(prompt,'s');
while isempty(str)
str = input(prompt,'s');
end
switch lower(str)
case 'n'
return;
case 'y'
system(sprintf('git clone https://github.com/guosheng/refinenet.git %s', fullfile('SS_CNN','RefineNet')));
disp('Copying required files for RefineNet to MatconvNet...');
bases = fullfile('SS_CNN','RefineNet','main','my_matconvnet_resnet',{'+dagnn',...
'@DagNN','impl'});
target_bases = fullfile('SS_CNN','RefineNet','libs','matconvnet','matlab',{'+dagnn',fullfile('+dagnn','@DagNN'),fullfile('src','bits','impl')});
for b = 1 : length(bases)
files= dir(fullfile(bases{b},'*.m'));
if isempty(files)
files= dir(fullfile(bases{b},'*.cpp')); files = {files(:).name}';
files_= dir(fullfile(bases{b},'*.cu')); files = [files;{files_(:).name}];
else
files = {files(:).name};
end
for f = 1 : length(files)
copyfile(fullfile(bases{b},files{f}),fullfile(target_bases{b},files{f}));
end
end
disp('Required files were copied!');
disp('Compiling ... ');
disp('Start compiling...');
cd (fullfile('SS_CNN','RefineNet','libs','matconvnet'));
addpath('matlab');
disp('Compiling MatConvNet for CPU...');
error = 0;
try
vl_compilenn;
disp('Compilred for CPU.');
catch
error =1;
disp('Error during installing MatConvNet .. please visit http://www.vlfeat.org/matconvnet/install/');
end
%disp('Compiling MatConvNet for GPU ... be sure that CUDA is install');
%try
% vl_compilenn('enableGpu', true);
% disp('Compilred for GPU.');
%catch
% disp('Error during installing MatConvNet .. please visit http://www.vlfeat.org/matconvnet/install/');
%end
cd(current);
if error==0
disp('Installing pre-trained RefineNet model for semantic segmentation...');
web('https://drive.google.com/uc?export=download&id=1-HDFsWsO-ziSH_ZinwbmRaDgwso8zECv');
disp('Check your web browser!');
prompt =('When you finish downloading, please copy and paste the file fullname (for example, C:\\users\\Documents\\refinenet_res152_ade.mat): ');
str = input(prompt,'s');
while isempty(str)
str = input(prompt,'s');
end
while exist(str,'file')==0
disp('File is not found! Please, be sure that the file is already downloaded and provide a correct file fullname.');
str = input(prompt,'s');
while isempty(str)
str = input(prompt,'s');
end
end
error=1;
while error == 1
try
movefile(str,fullfile('SS_CNN','RefineNet','model_trained','refinenet_res152_ade.mat'));
error = 0;
catch
end
end
disp('Part 5 is done!');
end
end