Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageDataGenerator is not defined

I am new to Keras and DL. I got this code from a keras document. wanted to run it on my system.

train_datagen = ImageDataGenerator(
    rescale=1./255,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True)

test_datagen = ImageDataGenerator(rescale=1./255)

 train_generator = train_datagen.flow_from_directory('C:\\Users\\kashy\\Desktop\\Data\\train',target_size=(200,200),batch_size=batch_size,class_mode='binary')

 validation_generator = test_datagen.flow_from_directory('C:\\Users\\kashy\\Desktop\\Data\\validation',target_size=(200,200),batch_size=batch_size,class_mode='binary')

this is snippet of the code i was working on..

when i tried to run this on my system... i got the following error

Traceback (most recent call last):
 File "C:\Users\kashy\Desktop\trial1.py", line 29, in <module>
train_datagen = ImageDataGenerator(
NameError: name 'ImageDataGenerator' is not defined

can somebody help me ??

thanks !!!

like image 852
Kashyap Ravichandran Avatar asked Dec 30 '17 17:12

Kashyap Ravichandran


1 Answers

ImageDataGenerator is a utility function defined within Keras. If you haven't imported it import it using

from keras.preprocessing.image import ImageDataGenerator
like image 59
Abhai Kollara Avatar answered Sep 20 '22 18:09

Abhai Kollara