Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

machine learning - Color mode in Image Data Generator method flow_from_directory

I have a question concerning the flow_from_directory method of ImageDataGenerator . My Images are in RGB form , I am using transfer learning and I want to train the model on grayscale images but pre trained model expects 3 channels . There is a method in flow_from_directory color-mode which takes grayscale or RBG . My question is that if I write grayscale here , does Keras automatically converts the RGB images to grayscale or it is something else ?

IMAGE_SIZE=[224,224]
resnet = InceptionResNetV2(input_shape=IMAGE_SIZE + [3] , weights='imagenet', include_top=False)

Flow_from_dir method :

test_set = test_datagen.flow_from_directory(valid_path,
                                            target_size = (224, 224),
                                            batch_size = 32,
                                            class_mode = 'categorical',color_mode='grayscale')
question from:https://stackoverflow.com/questions/65896217/color-mode-in-image-data-generator-method-flow-from-directory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you see the document ,it sey:

color_mode: One of "grayscale", "rgb", "rgba". Default: "rgb". Whether the images will be converted to have 1, 3, or 4 channels.

So, yes it turns out to be a gray scale.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...