I am trying to do data augmentation on 2018 Data Science Bowl previous competition on Kaggle. I am trying this code:
## Data augmentation
# Creating the training Image and Mask generator
image_datagen = image.ImageDataGenerator(shear_range=0.5, rotation_range=50, zoom_range=0.2, width_shift_range=0.2, height_shift_range=0.2, fill_mode='reflect')
mask_datagen = image.ImageDataGenerator(shear_range=0.5, rotation_range=50, zoom_range=0.2, width_shift_range=0.2, height_shift_range=0.2, fill_mode='reflect')
# Keep the same seed for image and mask generators so they fit together
image_datagen.fit(X_train[:int(X_train.shape[0]*0.9)], augment=True, seed=42)
mask_datagen.fit(Y_train[:int(Y_train.shape[0]*0.9)], augment=True, seed=42)
x=image_datagen.flow(X_train[:int(X_train.shape[0]*0.9)],batch_size=BATCH_SIZE,shuffle=True, seed=42)
y=mask_datagen.flow(Y_train[:int(Y_train.shape[0]*0.9)],batch_size=BATCH_SIZE,shuffle=True, seed=seed)
# Creating the validation Image and Mask generator
image_datagen_val = image.ImageDataGenerator()
mask_datagen_val = image.ImageDataGenerator()
image_datagen_val.fit(X_train[int(X_train.shape[0]*0.9):], augment=True, seed=seed)
mask_datagen_val.fit(Y_train[int(Y_train.shape[0]*0.9):], augment=True, seed=seed)
x_val=image_datagen_val.flow(X_train[int(X_train.shape[0]*0.9):],batch_size=BATCH_SIZE,shuffle=True, seed=seed)
y_val=mask_datagen_val.flow(Y_train[int(Y_train.shape[0]*0.9):],batch_size=BATCH_SIZE,shuffle=True, seed=seed)
This is the error message:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-126-6b608552652e> in <module>
5
6 # Keep the same seed for image and mask generators so they fit together
----> 7 image_datagen.fit(X_train[:int(X_train.shape[0]*0.9)], augment=True, seed=42)
8 mask_datagen.fit(Y_train[:int(Y_train.shape[0]*0.9)], augment=True, seed=42)
9
~\Anaconda3\lib\site-packages\keras_preprocessing\image\image_data_generator.py in fit(self, x, augment, rounds, seed)
941
942 if seed is not None:
--> 943 np.random.seed(seed)
944
945 x = np.copy(x)
TypeError: 'int' object is not callable
The error as I understood is in the seed parameter in image_datagen.fit. The error message shows some internal problem in the fit code, as far as I'm concerned. I don't understand why.
I have explored other similar questions but I found none of them is suitable for my issue.
These are the solutions that I've read:
Getting TypeError: 'int' object is not callable
Python "int object is not callable"
class method TypeError "Int object not callable"
Aucun commentaire:
Enregistrer un commentaire