Help with VDSR example code

15 views (last 30 days)
Elad Soll
Elad Soll on 17 Jan 2020
Commented: adarsh a on 25 Apr 2022
Hi,
I'm tring to learn VDSR network through matlab example:
I followed step by step the example which use the pre-trained network, but command panel shows me error: Error in test (line 46)
"Iresidual = activations(net,Iy_bicubic,21);
Undefined function 'activations' for input
arguments of type 'struct'.
Error in test (line 46)
Iresidual = activations(net,Iy_bicubic,41);"
can someone help me tell me how to fix the problem? my code is:
clear all;
%% download pretrained VDSR network:
net = load('trainedVDSR-Epoch-100-ScaleFactors-234.mat');
%% create sample low-resolution image:
exts = {'.jpg','.png'};
% fileNames contain 21 images:
fileNames = {'sherlock.jpg','car2.jpg','fabric.png','greens.jpg','hands1.jpg','kobi.png', ...
'lighthouse.png','micromarket.jpg','office_4.jpg','onion.png','pears.png','yellowlily.jpg', ...
'indiancorn.jpg','flamingos.jpg','sevilla.jpg','llama.jpg','parkavenue.jpg', ...
'peacock.jpg','car1.jpg','strawberries.jpg','wagon.jpg'};
%using image processing toolbox:
filePath = [fullfile(matlabroot,'toolbox','images','imdata') filesep];
filePathNames = strcat(filePath,fileNames);
testImages = imageDatastore(filePathNames,'FileExtensions',exts);
% display the testing images as a montage:
montage(testImages);
%% selecting one image to use as the reference image for SR:
% Index of image to read from the test image datastore
close all;
indx = 1;
Ireference = readimage(testImages,indx);
Ireference = im2double(Ireference);
imshow(Ireference);
title('High-Resolution Reference Image');
%% creating low-resolution image by using imresize
close all;
scaleFactor = 0.25;
Ilowres = imresize(Ireference,scaleFactor,'bicubic');
imshow(Ilowres);
title('Low-Resolution Image');
%% improving image resolution using pre-trained VDSR network:
close all;
[nrows,ncols,np] = size(Ireference);
Ibicubic = imresize(Ilowres,[nrows ncols],'bicubic');
% converting low resolution image from rgb2yuv
Iycbcr = rgb2ycbcr(Ilowres);
Iy = Iycbcr(:,:,1);
Icb = Iycbcr(:,:,2);
Icr = Iycbcr(:,:,3);
% up-scaling YUV image by bicubic interpulation:
Iy_bicubic = imresize(Iy,[nrows ncols],'bicubic');
Icb_bicubic = imresize(Icb,[nrows ncols],'bicubic');
Icr_bicubic = imresize(Icr,[nrows ncols],'bicubic');
%% passing the up-scalied images through trained VDSR network:
Iresidual = activations(net,Iy_bicubic,41);
Iresidual = double(Iresidual);
imshow(Iresidual,[]);
title('Residual Image from VDSR');

Answers (1)

Subhadeep Koley
Subhadeep Koley on 22 Jan 2020
The function activations was introduced inside Neural Network Toolbox in MATLAB R2016a. You can type the command ver to check whether the Neural Network Toolbox is installed or not.
ver;
Also make sure you are using MATLAB version R2016a or later.
Hope this helps!

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!