remove mirror from augmentation for step three
This commit is contained in:
parent
4e3e385e18
commit
bc52bd699b
@ -207,31 +207,4 @@ grid on
|
||||
title(sprintf('Average Precision = %.2f', ap))
|
||||
|
||||
|
||||
% ----- Helper functions
|
||||
|
||||
% function data = augmentData(data)
|
||||
% % Randomly flip images and bounding boxes horizontally.
|
||||
% tform = randomAffine2d('XReflection',true);
|
||||
% sz = size(data{1});
|
||||
% rout = affineOutputView(sz,tform);
|
||||
% data{1} = imwarp(data{1},tform,'OutputView',rout);
|
||||
%
|
||||
% % Sanitize box data, if needed.
|
||||
% data{2} = helperSanitizeBoxes(data{2}, sz);
|
||||
%
|
||||
% % Warp boxes.
|
||||
% data{2} = bboxwarp(data{2},tform,rout);
|
||||
% end
|
||||
%
|
||||
% function data = preprocessData(data,targetSize)
|
||||
% % Resize image and bounding boxes to targetSize.
|
||||
% sz = size(data{1},[1 2]);
|
||||
% scale = targetSize(1:2)./sz;
|
||||
% data{1} = imresize(data{1},targetSize(1:2));
|
||||
%
|
||||
% % Sanitize box data, if needed.
|
||||
% data{2} = helperSanitizeBoxes(data{2}, sz);
|
||||
%
|
||||
% % Resize boxes.
|
||||
% data{2} = bboxresize(data{2},scale);
|
||||
% end
|
||||
|
@ -33,13 +33,12 @@
|
||||
% adjustable parameters
|
||||
% - if there is no trained net, it can be trained with this script:
|
||||
% set doTraining to true
|
||||
% - the training can use augmentation or not:
|
||||
% set doAugmentation accordingly
|
||||
|
||||
|
||||
close all;
|
||||
clear;
|
||||
|
||||
doTraining = false;
|
||||
doTraining = true;
|
||||
|
||||
% first we need the data...
|
||||
dataDir = 'Picturedata'; % Destination-Folder for provided (img) Data
|
||||
@ -103,17 +102,6 @@ inputSize = [224 224 3];
|
||||
preprocessedTrainingData = transform(trainingData, @(data)preprocessData(data,inputSize));
|
||||
% Achtung: dieser DS wird nur zur Ermittlung der BoundingBoxes verwendet
|
||||
|
||||
% display one of the training images and box labels.
|
||||
while 1==0 %hasdata(preprocessedTrainingData)
|
||||
data = read(preprocessedTrainingData);
|
||||
I = data{1};
|
||||
bbox = data{2};
|
||||
annotatedImage = insertShape(I,'Rectangle',bbox);
|
||||
annotatedImage = imresize(annotatedImage,4); % nur fuer Darstellung
|
||||
figure(1)
|
||||
imshow(annotatedImage)
|
||||
pause(0.100)
|
||||
end
|
||||
|
||||
% Auswahl der anchor boxes
|
||||
% Infos dazu: https://de.mathworks.com/help/vision/ug/estimate-anchor-boxes-from-training-data.html
|
||||
@ -164,7 +152,7 @@ I = imresize(I,inputSize(1:2));
|
||||
[bboxes,scores] = detect(detector,I);
|
||||
% Display the results.
|
||||
|
||||
sfigTitle = ""
|
||||
sfigTitle = "";
|
||||
if height(bboxes) > 0
|
||||
I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
|
||||
sfigTitle = "Detected";
|
||||
@ -198,31 +186,4 @@ grid on
|
||||
title(sprintf('Average Precision = %.2f', ap))
|
||||
|
||||
|
||||
% ----- Helper functions
|
||||
|
||||
% function data = augmentData(data)
|
||||
% % Randomly flip images and bounding boxes horizontally.
|
||||
% tform = randomAffine2d('XReflection',true);
|
||||
% sz = size(data{1});
|
||||
% rout = affineOutputView(sz,tform);
|
||||
% data{1} = imwarp(data{1},tform,'OutputView',rout);
|
||||
%
|
||||
% % Sanitize box data, if needed.
|
||||
% data{2} = helperSanitizeBoxes(data{2}, sz);
|
||||
%
|
||||
% % Warp boxes.
|
||||
% data{2} = bboxwarp(data{2},tform,rout);
|
||||
% end
|
||||
%
|
||||
% function data = preprocessData(data,targetSize)
|
||||
% % Resize image and bounding boxes to targetSize.
|
||||
% sz = size(data{1},[1 2]);
|
||||
% scale = targetSize(1:2)./sz;
|
||||
% data{1} = imresize(data{1},targetSize(1:2));
|
||||
%
|
||||
% % Sanitize box data, if needed.
|
||||
% data{2} = helperSanitizeBoxes(data{2}, sz);
|
||||
%
|
||||
% % Resize boxes.
|
||||
% data{2} = bboxresize(data{2},scale);
|
||||
% end
|
||||
|
@ -1,8 +1,4 @@
|
||||
function data = augmentData_stepthree(data)
|
||||
% Randomly flip images and bounding boxes horizontally.
|
||||
tform = randomAffine2d('XReflection',true);
|
||||
sz = size(data{1});
|
||||
rout = affineOutputView(sz,tform);
|
||||
|
||||
% jitter
|
||||
data{1} = jitterColorHSV(data{1},...
|
||||
@ -11,11 +7,4 @@ data{1} = jitterColorHSV(data{1},...
|
||||
Saturation=0.1,...
|
||||
Brightness=0.2);
|
||||
|
||||
data{1} = imwarp(data{1},tform,'OutputView',rout);
|
||||
|
||||
% Sanitize box data, if needed.
|
||||
data{2} = helperSanitizeBoxes(data{2}, sz);
|
||||
|
||||
% Warp boxes.
|
||||
data{2} = bboxwarp(data{2},tform,rout);
|
||||
end
|
||||
end
|
||||
|
66
test_stepthree_for.m
Normal file
66
test_stepthree_for.m
Normal file
@ -0,0 +1,66 @@
|
||||
% Testscript um ein Bild aus den Daten durch das RCCN_NET mit direkter
|
||||
% klassifizierung laufen zu lassen
|
||||
|
||||
close all;
|
||||
clear;
|
||||
|
||||
%die netze mit besserer Erkennung _2
|
||||
RCCN_NET = 'netDetectorResNet50_stepthree.mat';
|
||||
inputSize = [224 224 3];
|
||||
|
||||
% first we need the data...
|
||||
dataDir = 'Picturedata'; % Destination-Folder for provided (img) Data
|
||||
zippedDataFile = 'PicturesResizedLabelsResizedSignsCutted.zip'; %Data provided by TA
|
||||
grDataFile = 'signDatasetGroundTruth.mat';
|
||||
func_setupData(dataDir, zippedDataFile, grDataFile);
|
||||
|
||||
%load data
|
||||
grdata = load(grDataFile);
|
||||
traficSignDataset = grdata.DataSet;
|
||||
|
||||
%Random Index
|
||||
%shuffledIndices = randperm(height(traficSignDataset));
|
||||
%testindx = shuffledIndices(1)
|
||||
for testindx = 126:200
|
||||
%testindx = 125;
|
||||
|
||||
% Bild einlesen
|
||||
imgname = traficSignDataset.imageFilename{testindx}
|
||||
I = imresize(imread(imgname),inputSize(1:2));
|
||||
|
||||
%RCCN-Detector laden
|
||||
pretrained = load(RCCN_NET);
|
||||
detector = pretrained.detector;
|
||||
|
||||
[bbox, score, label] = detect(detector, I);
|
||||
|
||||
|
||||
sfigTitle = "";
|
||||
bdetected = height(bbox) > 0;
|
||||
if bdetected
|
||||
I = insertObjectAnnotation(I,'rectangle',bbox,score);
|
||||
sfigTitle = "Detected" + string(label);
|
||||
return;
|
||||
else
|
||||
sfigTitle = "Not Detected";
|
||||
end
|
||||
|
||||
end %end forschleife testindex
|
||||
|
||||
figure;
|
||||
imshow(I);
|
||||
annotation('textbox', [0.5, 0.2, 0.1, 0.1], 'String', sfigTitle)
|
||||
|
||||
%ggf. bild zuschneiden
|
||||
if bdetected
|
||||
icrop = imcrop(I , bbox);
|
||||
figure;
|
||||
imshow(icrop);
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user