Answer the question
In order to leave comments, you need to log in
Why doesn't the keras learning process start?
Good day, there is a task to train a model that looks for faces in the image.
The data is as follows: 10000 training images 178x218x3 and 5000 test images, and the output should be 4 numbers: the coordinates of the extreme corners of the rectangle that bounds the face area
Here is my model:
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation="relu", input_shape=(200, 200, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(128, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(128, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Flatten())
model.add(layers.Dense(512, activation="relu"))
model.add(layers.Dense(4))
model.compile(optimizer="rmsprop", loss="mse", metrics=["mae"])
train_dir = "path/to/faces/1"
val_dir = "path/to/faces/2"
train_gen = ImageDataGenerator(rescale=1./255)
val_gen = ImageDataGenerator(rescale=1./255)
train_generator = train_gen.flow_from_directory(train_dir, target_size=(200, 200), batch_size=50, class_mode="categorical")
validation_generator = val_gen.flow_from_directory(val_dir, target_size=(200, 200), batch_size=50, class_mode="categorical")
model.fit_generator(train_generator, steps_per_epoch=200, epochs=3, validation_data=validation_generator, validation_steps=100)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question