Filter löschen
Filter löschen

Error thrown by 'trainNetwork' when input images are of different sizes

1 Ansicht (letzte 30 Tage)
Rene
Rene am 3 Apr. 2018
Hey team, I'm attempting to train a semantic segmentation network. The training images I'm using come in several different sizes, ranging from 1024x1024 to 4096x4096. Here's part of my script so far (the rest of the script is lifted straight from https://au.mathworks.com/help/vision/ug/semantic-segmentation-examples.html#mw_44be2a2e-ec6b-4a03-9470-ea945f74515e):
cellData = imageDatastore('training_images_colour/*.tif');
classNames = ["background" "cell"];
pixelLabelID = [1 2]; %as above
pxDir = fullfile('/home','rene','Documents','theus','PixelLabelData_1');
pxds = pixelLabelDatastore(pxDir,classNames,pixelLabelID);
trainingData = pixelLabelImageSource(cellData,pxds);
%%Define Network Architecture
layers = [
imageInputLayer([1024 1024 1])
Now if I specify the size to be 1024x1024 at the imageInputLayer line, the error I get is that the expected size was 1024x1024 but the size of the image was 2100x2100 (I know the first few images in the datastore are 2100x2100 so that sorta makes some sense). The reason I find this odd though is that the semantic segmentation example that I'm working from suggests that you should specify the -minimum- size of images being fed in and that most fully convolutional networks are capable of processing images larger than the specified size. Could this be happening because the larger images are not a nice integer multiple of 1024? I also tried setting the input size to 2100x2100 at the imageInputLayer line, but that threw an error "Undefined function 'throwVariableSizesException' for input arguments of type 'MException'." I suspect this is also related to the images being of different sizes. Would the solution to all this simply be to use an augmentedImageDatastore? If any light could be shed on this, it'd be much appreciated. Cheers.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by