0
$\begingroup$

I am new to the world of AI and wanted to ask your guidance on how to design a ML model to classify genders based on images.

  • There will be only one person in the image.
  • The person could be kids, young or old.
  • The person could be standing (full body), sitting, or only have his/her upper or lower body in the image.

Based on this I would like to classify the image as male or female.

I currently use Tensorflow and Keras with the below model:

gender_model = tf.keras.Sequential(
        [
            data_augmentation,
            layers.Conv2D(128, (3, 3), activation="relu", input_shape=INPUT_SHAPE),
            layers.BatchNormalization(),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Conv2D(256, (3, 3), activation="relu"),
            layers.BatchNormalization(),
            layers.Dropout(0.5),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Conv2D(256, (3, 3), activation="relu"),
            layers.BatchNormalization(),
            layers.Dropout(0.5),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Conv2D(512, (3, 3), activation="relu"),
            layers.BatchNormalization(),
            layers.Dropout(0.5),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Conv2D(512, (3, 3), activation="relu"),
            layers.BatchNormalization(),
            layers.Dropout(0.5),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Conv2D(256, (3, 3), activation="relu"),
            layers.BatchNormalization(),
            layers.Dropout(0.5),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Conv2D(256, (3, 3), activation="relu"),
            layers.BatchNormalization(),
            layers.Dropout(0.5),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Flatten(),
            layers.Dense(128, activation="relu"),
            layers.BatchNormalization(),
            layers.Dropout(0.5),
            layers.Dense(num_gender_classes),
        ]
    )

gender_model.compile(
    optimizer="adam",
    loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
    metrics=[tf.keras.metrics.BinaryAccuracy(name="acc")],
)

I put man and woman images into two separate folders and created the data structures to feed my model. The model prediction has been somewhat disappointing. I am still dealing with overfitting and trying to improve the loss for validation part. However, given the diverse possibilities of input images, I wonder if such an approach is the right one?

For example, should I detect kids vs adults using another model and then feed it to a second classification model? Similarly, classify full body images vs sitting people or upper body vs lower body in separate models, and then use a second model to classify the gender?

I would be grateful if you could provide pointers if you have worked on similar classification problems before.

Thanks,

Doug

$\endgroup$

0

You must log in to answer this question.