identify a set of photos by resnet

enter code here:model = ResNet50(weights=None, include_top=True, classes=997)
                x_train = ImageDataGenerator(rescale=1. / 255, 
                shear_range=0.2, zoom_range=0.2, horizontal_flip=True,
                         vertical_flip=True)
                x_train = x_train.flow_from_directory('E:\\flower\\train', 
                batch_size=32)
                img_path = x_train
                img = image.load_img(img_path, target_size=(224, 
                224))
                x = image.img_to_array(img)
                x = np.expand_dims(x, axis=0)
                x = preprocess_input(x)
                preds = model.predict(x)
                p

Blockquote:Traceback (most recent call last): File "C:\Users\THINKPAD\AppData\Roaming\Python\Python36\site-packages\PIL\Image.py", line 2552, in open fp.seek(0) AttributeError: 'DirectoryIterator' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/THINKPAD/PycharmProjects/TensorBoard/resnet.py", line 15, in <module>
    img=image.load_img(img_path,target_size=(224,224))
  File "D:\softwares\anaconda\lib\site-packages\keras_preprocessing\image.py", line 473, in load_img
    img = pil_image.open(path)
  File "C:\Users\THINKPAD\AppData\Roaming\Python\Python36\site-packages\PIL\Image.py", line 2554, in open
    fp = io.BytesIO(fp.read())
AttributeError: 'DirectoryIterator' object has no attribute 'read'