I found some code to create a Machine Learning Model with Keras, but i don't really know how i can put my own images in there. The model is created like that:
model = Model(inputs=base_model.input, outputs=predictions)
model.compile(optimizer=SGD(lr=0.0001, momentum=0.9), loss='categorical_crossentropy', metrics = ['accuracy'])
And the training_set is created like that:
train_datagen = ImageDataGenerator(rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True)
training_set = train_datagen.flow_from_directory('/content/drive/My Drive/multiclass/train',
target_size = (224, 224),
batch_size = 32,
class_mode = 'categorical')
Here you can see a path to a google-drive location which the author connects like this at the beginning from google.colab import drive; drive.mount('/content/drive/')
But i can't see how the data looks like in this google drive.
With this data the Training starts like that:
# Training the model for 5 epochs
model.fit_generator(training_set,
steps_per_epoch = 8000,
epochs = 5,
validation_data = test_set,
validation_steps = 200)
How can i put my own images in there? How does the Model know which image belongs to which class? Do i have to just put them in different folders and name them after my classes?
Another thing i wonder is, do the images have to be a certain size, like 224*224 pixels as the target_size is in the flow_from_directory method or are they transformed automatically in this model?
I am thankful for every answer!
Best regards Alex