Keras: 2.3.0 ImageDataGenerator : unexpected keyword argument 'interpolation_order'

Created on 19 Sep 2019  路  12Comments  路  Source: keras-team/keras

Just upgraded to 2.3.0

This used to work (in 2.2.4):

from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(
rescale=1./255,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
horizontal_flip=True,
fill_mode='nearest')

or just train_datagen = ImageDataGenerator()

but now I get:
...
TypeError: __init__() got an unexpected keyword argument 'interpolation_order'

Thanks

support

Most helpful comment

you can also try the new version of keras, which is syncronized with tf. It might not solve all keras compatibility problems, but it worked for my case, allowing me to keep working with the more recent version of Keras

from tensorflow.keras.preprocessing.image import ImageDataGenerator

More info here: keras vs tf.keras

All 12 comments

same problem

TypeError                                 Traceback (most recent call last)
<ipython-input-14-90f82dba206d> in <module>()
     52 # this is the augmentation configuration we will use for training
     53 train_datagen = ImageDataGenerator(
---> 54     rescale=1. / 255)
     55 
     56 # this is the augmentation configuration we will use for testing:

/home/app/anaconda3/lib/python3.6/site-packages/keras/preprocessing/image.py in __init__(self, featurewise_center, samplewise_center, featurewise_std_normalization, samplewise_std_normalization, zca_whitening, zca_epsilon, rotation_range, width_shift_range, height_shift_range, brightness_range, shear_range, zoom_range, channel_shift_range, fill_mode, cval, horizontal_flip, vertical_flip, rescale, preprocessing_function, data_format, validation_split, interpolation_order, dtype)
    290             validation_split=validation_split,
    291             interpolation_order=interpolation_order,
--> 292             dtype=dtype)
    293 
    294     def flow(self,

TypeError: __init__() got an unexpected keyword argument 'interpolation_order'


Same
File "train_triplet_deepfashion.py", line 118, in main horizontal_flip=True, fill_mode="nearest") File "/usr/local/lib/python2.7/dist-packages/keras/preprocessing/image.py", line 292, in __init__ dtype=dtype) TypeError: __init__() got an unexpected keyword argument 'interpolation_order'

same problem.
TypeError: __init__() got an unexpected keyword argument 'interpolation_order' from ImageDataGenerator.
Everything works on 2.2.4

same error

generator.flow_from_directory(
path,
target_size=target_size,
batch_size=batch_size,
color_mode=color_mode,
class_mode=class_mode,
subset=subset)

got

__init__() got an unexpected keyword argument 'interpolation_order'

Everything works on 2.2.5

same problem.
how to solve it?

Downgrade to keras 2.2.4

you can also try the new version of keras, which is syncronized with tf. It might not solve all keras compatibility problems, but it worked for my case, allowing me to keep working with the more recent version of Keras

from tensorflow.keras.preprocessing.image import ImageDataGenerator

More info here: keras vs tf.keras

Same problem. and I tried

from tensorflow.keras.preprocessing.image import ImageDataGenerator

it is working now.

Thanks JavierClearImageAI

The same error can anyone help me out?
TypeError Traceback (most recent call last)
in
207 X,label=shuffle(X,label,random_state=2)
208 model=get_model()
--> 209 fit_model(model,X,label)

in fit_model(model, X, label)
189
190 datagen.fit(X_train)
--> 191 model.fit_generator(datagen.flow(X_train, y_train, batch_size=32, class_mode="categorical",target_size=(64, 64),color_mode="rgb",save_to_dir=r'/Users/Sanjeeth/Python work space/project1/testing/resnet/', save_prefix='fudus', save_format='jpeg'), steps_per_epoch=len(X_train) / 32, epochs=4)
192
193

TypeError: flow() got an unexpected keyword argument 'class_mode'

you can also try the new version of keras, which is syncronized with tf. It might not solve all keras compatibility problems, but it worked for my case, allowing me to keep working with the more recent version of Keras

from tensorflow.keras.preprocessing.image import ImageDataGenerator

More info here: keras vs tf.keras

Thank you. It really works. But I am wondering why Keras version does not work.

thanks this:
from tensorflow.keras.preprocessing.image import ImageDataGenerator
worked for me as well....

If you don't want to mix tf.keras and keras in your code base (as I did), the alternative is:
pip3 install --ugprade keras-preprocessing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KeironO picture KeironO  路  3Comments

braingineer picture braingineer  路  3Comments

amityaffliction picture amityaffliction  路  3Comments

vinayakumarr picture vinayakumarr  路  3Comments

nryant picture nryant  路  3Comments