Augmented image datastore for color images and pixelLabel images
4 次查看(过去 30 天)
显示 更早的评论
Good morning,d
I am trying to train a U-net network with an augmented image datastore. I have my two Datastores: the first one with RGB images corresponding to the original images (imds), and the second one with the pixelLabel images (pxds). When I try to use augmentedImageDatastore, I recieve an error for the type of input that gives pxds. I imagine that it is caused because they are images and the entrance must be a vector, but I do not know how to solve it. Could you help me?
imagesize = [2000 2000 3];
imageAugmenter = imageDataAugmenter( ...
'RandXReflection', true, ...
'RandXScale',[1,2], ...
'RandYReflection', true, ...
'RandYScale',[1,2]);
augimds = augmentedImageDatastore(imageSize,imds,pxds,'DataAugmentation',imageAugmenter);
Error using augmentedImageDatastore/parseInputs (line 503)
Responses cannot be specified when second input argument is a matlab.io.datastore.ImageDatastore.
Error in augmentedImageDatastore (line 251)
inputs = self.parseInputs(varargin{:});
Appart, I have a problem when using spliteach label. I try to do it for my variable ds (which is the datastore for both imgds and pxds) and it also gives me an error:
ds = pixelLabelImageDatastore(imds,pxds);
[trainX, trainY] = splitEachLabel(ds, 0.7, 'randomized');
Check for missing argument or incorrect argument data type in call to function 'splitEachLabel'.
0 个评论
回答(1 个)
Divya Gaddipati
2021-3-8
When you are using datastore inputs for augmentedImageDatastore, imds and pxds cannot be provided as separate inputs to the function. There are two ways to specify the image augmentation methods:
1) You can create a pixelLabelImageDatastore object and provide that as an input.
ds = pixelLabelImageDatastore(imds,pxds);
augimds = augmentedImageDatastore(imageSize,imds,pxds,'DataAugmentation',imageAugmenter);
Please refer to the documentation page of augmentedImageDatastore where it explains the valid syntaxes.
augpxds = pixelLabelImageDatastore(imds,pxds,'DataAugmentation',imageAugmenter);
To answer your second question, splitEachLabel works only on imageDatastore as it is described in the documentation page.
Alternatively, you can use the partitionByIndex method provided by the pixelLabelImageDatastore object to split your data.
totalImages = numel(ds.Images);
% Split 80% of the data into training and rest into validation
idx = floor(0.8 * totalImages);
% Partition the datastore according to the specified indices
pximds_train = partitionByIndex(ds, 1:idx);
pximds_val = partitionByIndex(ds, (idx + 1):totalImages);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!