0
$\begingroup$

I'm trying to perform image classification with a CNN. In my case, the inputs are the covers of 9 books, so there are 9 labels. I am using TensorFlow's Keras.

If I pass a new input (that has a label different than one of the 9 labels the CNN was trained with), it will be classified as one of the 9 books, even though it's not a book (but it's e.g. a wall, sofa, house, etc.). I want to avoid this. I want the model to first classify whether there is a book in the image and then classify the book in 9 classes. How could I achieve this?

$\endgroup$
0
3
$\begingroup$

You can introduce another class to your network - "not a book". After that, you will need to add new data to your dataset, random images that do not contain books to classify and train your network on that data. So when your network won't see a book it will output high probability for "not a book" class, if an image with a book will be shown to the network probability of the "not a book" class should be low.

$\endgroup$
2
  • $\begingroup$ I'm wondering which would work better: adding a new class of "not a book" or first of all classifying between "book" and "not a book" and then only passing the image to the book classifier if it first of all classifies as "book"? $\endgroup$
    – Peter K.
    Dec 12 '18 at 19:48
  • $\begingroup$ Well, with this approach, you already classify an image as "book" or "not a book". I think having one ML model to do this is better since if you will introduce another model the number of correctly predicted classes will depend on two models and you will need to fine tune them both. For example, your first model may fail to categorize an image as a book when there is a book and it will not be passed to the 2nd model. So with this approach, you will need to worry only about one model, not two. $\endgroup$
    – Andrew
    Dec 12 '18 at 20:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.