I'm attempting to build an image classifier to identify between 2 types of images on property sites. I've split my dataset into 2 categories: [Property, Room]. I'm hoping to be able to differentiate between whether the image is of the outside of some property or a room inside the property.

Below are 2 examples of the types of image I am using. My dataset consists of 800 images for each category, and then a training set of an additional 160 images for each category (not present in the training set).

I always seem to be get reasonable results in training, but then when I test against some real samples it usually ends up classifying all of the images into a single category.

Below you can see the model I am using:

model = tf.keras.models.Sequential([
    tf.keras.layers.Conv2D(32, (11,11), activation='relu', input_shape=(IMG_HEIGHT, IMG_WIDTH, 3), padding='same'),
    tf.keras.layers.MaxPooling2D(11, 11),
    # tf.keras.layers.Dropout(0.5),
    # Second convolutional layer
    tf.keras.layers.Conv2D(64, (11, 11), padding='same', activation='relu'),
    tf.keras.layers.MaxPooling2D(11, 11),
    # tf.keras.layers.Dropout(0.5),
    # Flattening
    # Full connection
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid')

from tensorflow.keras.optimizers import RMSprop


# now train the model
history = model.fit_generator(
    steps_per_epoch=75, #100
    epochs=5, # 15, or 20, and 100 steps per epoch

Can anyone suggest the possible reasons for this? I've tried using different epochs and batch sizes, augmenting the images further, changing the Conv2D and Pooling layer size but nothing seems to help.

Do I perhaps not have enough data, or are they bad images to begin with? This is my first foray into ML so apologies if any of questions seem obvious.

enter image description here

enter image description here

enter image description here

enter image description here

  • $\begingroup$ What are those "real samples" you test your data on? Do they come from the same source as your train and valid data? And what do these images look like? $\endgroup$ – Sammy Feb 23 at 12:24
  • $\begingroup$ The real sampels were similar images, just unseen. I found the error: stackoverflow.com/questions/60357990/… It was my mistake, not interpreting the prediction output value correctly. $\endgroup$ – Adam Feb 23 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.