Issue
I preprocess my data with image data generator, and when apply model.compile and model.fit it shows me this message
"/usr/local/lib/python3.10/dist-packages/keras/src/preprocessing/image.py:1862: UserWarning: This ImageDataGenerator specifies
featurewise_center
, but it hasn't been fit on any training data. Fit it first by calling.fit(numpy_data)
. warnings.warn("
and then the model begin training what is it meaning the warning? and when try to add featurewise_center in image_data_gen, it gives me error
train_datagen = ImageDataGenerator(
main_dir,
rescale=1. / 255,
shear_range=0.2,
zoom_range=0.2,
width_shift_range=0.1,
height_shift_range=0.1,
brightness_range=[0.2,1.0],
horizontal_flip=True,
validation_split=0.2)
test_datagen = ImageDataGenerator(rescale=1. / 255)
val_datagen = ImageDataGenerator(rescale=1. / 255)
and apply image _data_flow
train_generator = train_datagen.flow_from_directory(directory = main_dir,subset="training",target_size=(img_w,img_h),
batch_size = batch_size,class_mode="categorical")
validation_generator = train_datagen.flow_from_directory(
directory = main_dir,
target_size=(img_w,img_h),
batch_size=batch_size,
class_mode="categorical",subset="validation")
Solution
You have to remove main_dir
in ImageDataGenerator
. The first positional argument of ImageDataGenerator
is featurewise_center
:
train_datagen = ImageDataGenerator(
rescale=1. / 255,
shear_range=0.2,
zoom_range=0.2,
width_shift_range=0.1,
height_shift_range=0.1,
brightness_range=[0.2,1.0],
horizontal_flip=True,
validation_split=0.2)
test_datagen = ImageDataGenerator(rescale=1. / 255)
val_datagen = ImageDataGenerator(rescale=1. / 255)
Answered By - Corralien
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.