0
$\begingroup$

I am classifying about 9 books from the image of their cover pages. I am using a TensorFlow Keras CNN model for this. But, the model predicts a book even when a picture of a book is not taken, like 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$
  • $\begingroup$ That's a very general question. However, as far as I know there are pre-trained models in Keras which can perform object classification. You could pre-compute the probability of the image showing a book and only then feed it to the network you trained. If you want to train your own network you might want to take a look at the attention mechanism (skymind.ai/wiki/attention-mechanism-memory-network) for that. $\endgroup$ – displayname Dec 12 '18 at 15:12
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$
  • $\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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