Search code examples
imagevalidationkerastraining-dataone-class-classification

The train and validation accuracy of image classification with single class data are wrong and want to fix this


I have built an image classification program using 32 images for train and 16 images for validation with batch size of 16 and 10 epochs.

I have used ImageDataGenerator(rescale=1./255).flow_from_directory(image path and other parameters) for train and validation images.

I want to classify images on 1 category or on single class.

But as I compile the program with model.fit_generator(with hinge loss, and optimizer used- 'rmsprop' and 'Adam') for keras sequential() model, the output I get is is train and validation accuracy near 1 on 1st epoch, and for remaining epochs, the train and validation is same as exactly 1.

Please send answer, how I can fix the output of train accuracy and validation accuracy as start from .63 or similar and gradually increase at each epoch as 6 % to 10 % increase.

As a mention, I want to train and validate images of 1 or single class.

Please comment if you need more details on this program.


Solution

  • 32 images is very less number for any image classification given that you are using deep learning.
    So this behavior is expected, since you have very less images, it will fit all images in 1st epoch itself. So there won't be gradual increment in accuracy.
    Add more images if you could and try some augmentation techniques to increase your training set. Also since you are doing binary classification you'll have to include negative examples also (images not belonging to your class).