1
$\begingroup$

Im using tensorflow.keras

I made a model that can predict cat and a dog but when I try to predict image without dog or a cat I still get an answer of a cat/dog.

I tried find the % value of the prediction to know how low/high the prediction was. But I couldn't find much updated answers.

So how can I basically detect that thats not a cat or a dog?

$\endgroup$
4
  • 1
    $\begingroup$ How the output probability vector looks like if you give a no cat/dog image? Perhaps both should be low, but one is slightly higher and label one of them. Maybe you should have a threshold like at least 50% for identifying them, if lower label them None rather cat/dog. $\endgroup$ Commented Nov 13, 2018 at 6:31
  • $\begingroup$ You can include a 'negative' label for non cats and dogs and train your model with cats, dogs and non cats and dogs... Other thing you can do is having two binary models, the first one will detect if the image is a cat/dog and if positive, the second model will classify the image in cat or dog $\endgroup$
    – ignatius
    Commented Nov 13, 2018 at 8:58
  • $\begingroup$ First of all what will be a None-cat or None-dog its all the picture without cats/dogs and how can I find the probability values? I'm using keras and all I get is the catetory number (Cat = 1, Dog = 0). $\endgroup$
    – Wailu
    Commented Nov 13, 2018 at 9:11
  • $\begingroup$ @TwinPenguins In a binary problem, one of the probability scores will be at least $0.5$. Perhaps a reasonable way to use the probability output, however, is to require $0.8$ probability of a class to call it a particular class; otherwise, the model is undecided. This relates to what Stephan Kolassa writes about more decisions than categories in spam email detection. $\endgroup$
    – Dave
    Commented Jun 16, 2021 at 15:18

1 Answer 1

1
$\begingroup$

There are two common options:

  1. Use Bayesian methods to set a confidence threshold for predicting cat or dog.

  2. Retrain your model to be multinomial. It will learn to predict one of three outcomes - cat, dog, no cat or dog.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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