I'm trying to apply the Alexnet transfer learning example but it's not working with my dataset

조회 수: 3 (최근 30일)
I'm trying to follow the steps in this example Transfer learning using AlexNet using my set of images but it's giving me this error
Error using trainNetwork (line 154)
augmentedImageSource cannot form MiniBatches of data because input image sizes differ in 3rd dimension. Consider
using 'ColorPreprocessing' option to ensure all augmented images have same number of channels.
Error in TrainAlexnet (line 42)
netTransfer = trainNetwork(augimdsTrain,layers,options);
Caused by:
Error using augmentedImageDatastore/applyAugmentationPipeline (line 335)
augmentedImageSource cannot form MiniBatches of data because input image sizes differ in 3rd dimension.
Consider using 'ColorPreprocessing' option to ensure all augmented images have same number of channels.
I even resized all images to [227 227 3], same error. I also had the same problem with GoogLeNet

채택된 답변

Walter Roberson
Walter Roberson 2018년 9월 4일
imresize does not accept [227 227 3] as a parameter. You would have used imresize with [227 227] as a parameter. However, imresize does not change the number of color channels.
In short: some of your files are not RGB images. They are one of:
  • binary images (PNG) (TIFF)
  • grayscale images (GIF) (PNG) (TIFF) (JPG but quite rare)
  • pseudocolor images (GIF) (PNG) (TIFF)
  • CMYK images (TIFF)
  • RGBA images (TIFF) (possible with PNG even if not officially supported; PNG prefers RGB+A)
JPEG 2000 should also be in that table somewhere, but I do not remember exactly what it supports.
Possibly you have some JPEG that you are thinking are grayscale. Grayscale JPEG are very very uncommon: I have only encountered one in about 20 years that was not a test image to prove that it could be done. Nearly all JPEG images that appear to be grayscale are instead RGB images.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by