How to know the data set after augment?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
mohd akmal masud
il 25 Feb 2023
Risposto: Walter Roberson
il 26 Feb 2023
Hello everyone,
I was developed the coding for augmented my data for trainning process using 3D U-Net network. But I dont know how to find the addition data after augment? Because I checked in workspace but not found. Below is my coding, the function @augment3dPatch is for augment data
Also I attached the function for running my coding.
The data for image training (ImagesTr), groundtruthlabeling training (LabelsTr), image validation (imagesVal ), groundtruth validation (labelsVal) can download thru this link https://drive.google.com/drive/folders/176Ffn3d-61HFYiK7ywFFD9rRuzmXnN26?usp=share_link
clc
clear all
close all
%testDataimages
DATASetDir = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET');
IMAGEDir = fullfile(DATASetDir,'ImagesTr');
volReader = @(x) matRead(x);
volds = imageDatastore(IMAGEDir, ...
'FileExtensions','.mat','ReadFcn', volReader);
% labelReader = @(x) matread(x);
matFileDir = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET\LabelsTr');
classNames = ["background", "tumor"];
pixelLabelID = [0 1];
% pxds = (LabelDirr,classNames,pixelLabelID, ...
% 'FileExtensions','.mat','ReadFcn',labelReader);
pxds = pixelLabelDatastore(matFileDir,classNames,pixelLabelID, ...
'FileExtensions','.mat','ReadFcn',@matRead);
volume = preview(volds);
label = preview(pxds);
up1 = uipanel;
h = labelvolshow(label, volume, 'Parent', up1);
h.CameraPosition = [4 2 -3.5];
h.LabelVisibility(1) = 0;
h.VolumeThreshold = 0.5;
volumeViewer(volume, label)
patchSize = [128 128 64];
patchPerImage = 16;
miniBatchSize = 8;
patchds = randomPatchExtractionDatastore(volds,pxds,patchSize, ...
'PatchesPerImage',patchPerImage);
patchds.MiniBatchSize = miniBatchSize;
%% AUGMENT DATA FOR TRAINING
dsTrain = transform(patchds,@augment3dPatch);
volLocVal = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET\imagesVal');
voldsVal = imageDatastore(volLocVal, ...
'FileExtensions','.mat','ReadFcn',volReader);
lblLocVal = fullfile('C:\Users\Akmal\Desktop\NEW 3D U NET\labelsVal');
pxdsVal = pixelLabelDatastore(lblLocVal,classNames,pixelLabelID, ...
'FileExtensions','.mat','ReadFcn',volReader);
dsVal = randomPatchExtractionDatastore(voldsVal,pxdsVal,patchSize, ...
'PatchesPerImage',patchPerImage);
dsVal.MiniBatchSize = miniBatchSize;
%% AUGMENT DATA FOR VALIDATION
dsVal = transform(patchds,@augment3dPatch);
inputSize = [128 128 64];
numClasses = 2;
encoderDepth = 2;
lgraph = unet3dLayers(inputSize,numClasses,'EncoderDepth',encoderDepth,'NumFirstEncoderFilters',16)
figure,plot(lgraph);
0 Commenti
Risposta accettata
Walter Roberson
il 26 Feb 2023
But I dont know how to find the addition data after augment? Because I checked in workspace but not found.
Augmented data is generated internally and is not stored after it is used.If you need it then you can use readall()
0 Commenti
Più risposte (1)
Askic V
il 25 Feb 2023
Modificato: Askic V
il 25 Feb 2023
This is an extract from the documentation:
% transform Create a new datastore that applies a function to the
% data read from all input datastores.
%
% DSNEW = transform(DS, transformFcn) transforms an input
% Datastore, DS, given an input function, transformFcn. The
% transform function has the syntax:
%
% dataOut = FCN(dataIn);
%
% where FCN is a function that takes the dataIn returned by
% read of DS and returns a modified form of that data,
% dataOut.
In your case the new datastorage after augmenting will be dsTrain
How you can inspect the newdata depends on what transform function do.
For example, this is a simple case of image resizing as transformFcn
imds = imageDatastore('peppers.png');
img1 = read(imds); % reads theimage
subplot(211)
imshow(img1)
newDS = transform(imds,@(x) imresize(x, [120, 120]));
imgOut = read(newDS);
subplot(212)
imshow(imgOut);
whos
As you can see, I need to know how to read the data behind, because datastore is just a pointer to location where the data is.
I hope this example will help you figuring out how exactly to inspect your data.
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!