ImageFolder Classifications

So basically, I am training humans and seperate them from animals(cats)

I have training data full of humans,cats and val data humans,cats. I use imagefolder btw.

However, I wanted to try sth new:

In train folder, I put “human” folder that has human pictures.
In val folder, I also put “human” folder that has cat pictures instead. So I expected that to have 0% accuracy, because of overfitting and not accurate image clusters.

If I had human folder with human pics in train AND human,cat in val the accuracy is 50% which is normal.

The rest of the classifications is fine as well. However, that thing really gave me weird feelings on my model.

Thanks!

I’m not sure if I understand the problem correctly.
As far as I’ve understood it, you have clean training data and mixed-up Val data. Now your validation accuracy does represent the Val data classes, i.e. 50% accuracy for 50% wrong images.

Could you explain your issue a bit more?

oh sorry I will try to be elaborate:

I had several test scenarios and I use imagefolder style and use resnet:

1st scenario:
train:
./human has human
./cat has cat
val
./human has human
./cat has cat
accu: 100%
I think thats alright.

2nd scenario:
train:
./human has human
val
./human has human
./cat has cat
accu: 50%
thats alright too, given that its trained on human

3nd scenario:
train:
./human has human
val
“./human has cat” OR(other scenario not together) “./cat has cat”
accu: 100%
I didnt get this part.

Thanks for the clarification.

I guess it might be just a mix-up with the class indices.

In your 2nd scenario, your model is only trained on one class, which means it will output only class0. Since your validation data contains human and cat classes, your accuracy will be 50% if you have a balanced dataset.

In your 3rd scenario, it looks like you only have one single class in your validation dataset, which corresponds to class0.

Since your training data only consists of one class, your model just outputs class0 for every sample it gets, which will yield an accuracy of 100% regardless of the actual class in your validation set.

oh makes sense! Thanks! I wish it worked like I thought haha!