Binary Image classification with CNN, but Precision-Recall-F1 Score is 0 for one class

110 Views Asked by At

I am trying to classify if a given image is a woodpile or not. So my classes are wood and none_wood. None_wood class contains different photos including documents, numbers, persons etc. My train set consist of 4655 wood and 4566 none_wood images(I used augmentor to increase the size of none_wood class) and test set includes 1139 images of each class.

My model is as following:

classifier = Sequential()
classifier.add(Convolution2D(32,(3,3),input_shape = (175,130,3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2,2)))
classifier.add(Convolution2D(64,(3,3),input_shape = (175,130,3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2,2)))
classifier.add(Flatten())
classifier.add(Dense(128, activation = 'relu'))
classifier.add(Dense(1, activation = 'sigmoid'))
classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])

When I get the class report and the confusion matrix they are as following: Class_report and confusion matrix

And the plots of train-validation loss and train-validation accuracy ( with earlystopping): Plots

I tried different epochs up to 10, I added callback to prevent overfit, I did data augmentation with ImageDataGenerator, there is no imbalance in the dataset, I tried different optimizers, I tried different loss functions but there is no change.

What do you suggest? I could not understand what is the exact problem and why the FP and TN values are 0 in confusion matrix? What do I need to increase the accuracy?It is 0.5 :(

Update: My test set directory has two sub-directory called wood none_wood. I turned it into a single testSet directory and put all the test images in it. This time precision-recall-f1 score- accuracy everything is 1.00. Guys what do I missing?????

0

There are 0 best solutions below