-1

I coded a simple image classifier using CNN to classify input images to labels: Dog or Cat. When images other than Cats/Dogs are shown the CNN classifies it into any one of the label(Dog or Cat), which is incorrect. I wanted my CNN to classify/label all other random images(House, People, Birds, etc.) as Invalid input. How can this be done?

  • One of the possible approach is setting confidence score. e.g, if you give house/bird/people, then you will get lower confidence score (probabilities) for Dog/Cat. So then you can set a rule for that confidence. if confidence lower than 50% then invalid input – yakhyo Mar 09 '21 at 08:31
  • Hi @Sartaj Bhuvaji: I have a similar question so I took the liberty to ask your question at the following link: https://ai.stackexchange.com/questions/26729/should-one-use-a-trash-category-in-image-classification . – Ruthger Righart Mar 09 '21 at 10:15
  • @yakhyo that does not really work, since neural networks make overconfident incorrect predictions. – Dr. Snoopy Mar 09 '21 at 10:22

1 Answers1

1

There are two ways you can do it..

1 . Include a 3rd class in your training data having any random images like House, People, Birds, etc. so that while inferencing you will get this prediction for random data (if you include all possible max amount of images).

2 . Use of threshold after your softmax classifir like any thing below a thresold of 0.7 ( change according to your wish after doing some trials) would be unknown class ( This trick i use very often)

Prajot Kuvalekar
  • 5,128
  • 3
  • 21
  • 32