'ResNet50 Directory Issue
I am running a ResNet50 pre-trained model for classifying glaucoma and non-glaucoma images but getting an error of directory in the flow_from_directory command. I am pasting the code below. If someone can help me, it would be great.
IMAGE_SIZE = [224, 224]
train_path = '/content/GlaucomaDetectionSmall.zip/Train'
valid_path = '/content/GlaucomaDetectionSmall.zip/Test'
# add preprocessing layer to the front of VGG
resnet50 = ResNet50(input_shape=IMAGE_SIZE + [3], weights='imagenet', include_top=False)
# don't train existing weights
for layer in resnet50.layers:
layer.trainable = False
# useful for getting number of classes
folders = glob('/content/GlaucomaDetectionSmall.zip/Train/*')
# our layers - you can add more if you want
x = Flatten()(resnet50.output)
# x = Dense(1000, activation='relu')(x)
prediction = Dense(len(folders), activation='softmax')(x)
# create a model object
model = Model(inputs=resnet50.input, outputs=prediction)
# view the structure of the model
model.summary()
# tell the model what cost and optimization method to use
model.compile(
loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy']
)
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True)
test_datagen = ImageDataGenerator(rescale = 1./255)
training_set = train_datagen.flow_from_directory(**train_path**,
target_size = (224, 224),
batch_size = 32,
class_mode = 'categorical')
test_set = test_datagen.flow_from_directory(**valid_path**,
target_size = (224, 224),
batch_size = 32,
class_mode = 'categorical')
Error: [Errno 20] Not a directory: '/content/GlaucomaDetectionSmall.zip/Train'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
