Augmentations via Rotation, Shearing, Scaling, Reflection
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi professionals,
I am trying to code the augmentation for a small dataset and would like to perform Augmentations via Rotation, Shearing, Scaling, Reflection for adding accuracy and efficiency with my classification process!
I am having a challenge to understand the affine function as this is constantly arguing for the correct variable. I have implemented and followed the example from here!!https://uk.mathworks.com/help/deeplearning/examples/bounding-box-augmentation-using-computer-vision-toolbox.html?searchHighlight=augmented%20rotation%2C%20shearing%2C%20scaling&s_tid=doc_srchtitle
The affine command constantly argues but this is the exact example from the matlab link provided!!
Can a professional guide me please?
tform = randomAffine2d("Rotation",[-50 50]);
my error is:
Undefined function or variable 'randomAffine2d'.
my code:
clearvars
clear
close all
clc
net =alexnet;
%% Step 1 Creating Filenames /Loading Data
load('SgTruth.mat');
load('RCNNLayers.mat');
load('Alexnlayers.mat');
save Alexnlayers.mat net;
save RCNNLayers.mat net;
save rcnnGuns.mat SgTruth
load('rcnnGuns.mat', 'SgTruth', 'net')
inputSize =net.Layers(1).InputSize
net.Layers
total_images = size(SgTruth,1);
%% Step 3 Adding Image Directory For Path To Image Data
imDir = fullfile(matlabroot, 'toolbox', 'vision', 'visiondata','gunsGT')
addpath(imDir)
%% Step 4 Accessing Contents Of Folder TrainingSet Using Datastore
imds =imageDatastore(imDir,'IncludeSubFolders',true,'LabelSource','Foldernames')
%% Step 5 Splitting Inputs Into Training and Testing Sets
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7,'randomized')
disp('The Size Of Images Are')
size(imdsTrain)
%% Step 12 Replacing Final Layer/Last 3 Configure For Network classes
layersTransfer = net.Layers(1:end-3);
%% Step 13 Specifying Image Categories/Clases:
numClasses = numel(categories(imdsTrain.Labels));
Tlayers = [
layersTransfer
fullyConnectedLayer(1,'Name','fc8','WeightLearnRateFactor',10,'BiasLearnRateFactor',10);
softmaxLayer('name', 'Softmax')
classificationLayer('Name','ClassfLay')];
%% Warp Image & Pixel Labels
% Creates A Randomized 2-D Affine Transformation From A Combination Of Rotation,
% Rotate Input Properties By An Angle Selected Randomly From Range [-50,50] Degrees.
pixelRange = [-30 30];
[imdsTrain,imdsValidation] = digitTrain4DArrayData;
imageAugmenter = imageDataAugmenter('RandRotation',[-180 180],...
'RandXReflection',true,...
'RandYReflection',true,...
'RandXTranslation',pixelRange, ...
'RandYTranslation',pixelRange)
augimdsTrain = augmentedImageSource(inputSize(1:2),imdsTrain,imdsValidation,...
'DataAugmentation',imageAugmenter)
augimdsTrain.MiniBatchSize = 16
augimdsTrain.reset()
tform1 = randomAffine2d('Rotation',[35 55]);
0 Commenti
Risposte (1)
Bhargavi Maganuru
il 12 Feb 2020
I guess you’re using earlier version of MATLAB. The function ‘randomAffine2d’ is a new feature introduce in R2019b release, so you would get error if you’re using it in earlier versions.
1 Commento
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!