forked from phoenix104104/LapSRN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_LapSRN.m
58 lines (46 loc) · 1.56 KB
/
demo_LapSRN.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
clear all;
% -------------------------------------------------------------------------
% Description:
% Script to demo LapSRN for one image
%
% Citation:
% Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution
% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang
% IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017
%
% Contact:
% Wei-Sheng Lai
% University of California, Merced
% -------------------------------------------------------------------------
img_filename = 'emma.jpg';
%% parameters
opts.scale = 4; % SR upsampling scale
opts.gpu = 1; % GPU ID
%% setup paths
addpath(genpath('utils'));
addpath(fullfile(pwd, 'matconvnet/matlab'));
vl_setupnn;
%% Load pretrained odel
model_filename = fullfile('pretrained_models', sprintf('LapSRN_x%d.mat', opts.scale));
fprintf('Load %s\n', model_filename);
net = load(model_filename);
net = dagnn.DagNN.loadobj(net.net);
net.mode = 'test' ;
if( opts.gpu ~= 0 )
gpuDevice(opts.gpu)
net.move('gpu');
end
%% Load GT image
fprintf('Load %s\n', img_filename);
img_GT = im2double(imread(img_filename));
img_GT = mod_crop(img_GT, opts.scale);
%% Generate LR image
img_LR = imresize(img_GT, 1/opts.scale);
%% apply LapSRN
fprintf('Apply LapSRN for %dx SR\n', opts.scale);
img_HR = SR_LapSRN(img_LR, net, opts);
%% show results
img_LR = imresize(img_LR, opts.scale);
figure, imshow(cat(2, img_LR, img_HR, img_GT));
title(sprintf('Bicubic %dx | LapSRN %dx | Ground Truth', opts.scale, opts.scale));