I have already trained a model to recognise animal and it is working, deployed into android application. I'm finding for a solution to make the image classifier to only classify the trained categories. I'm not sure whether to do this through the model training or any code to be added to solve this.

Example, if a picture of a cup is sent for classification, the result shows as Dog or some other animal name. How to make only classify the given category, anything else than that show it as "not a animal".

Im using Tensorflow 1.12, MobileNet Model

Answer

The simple straightforward solution is to create additional binary classifier that would classify animals vs everything else. So the first step would be to classify whether a given picture is an animal. If the first steps succeeds, the second step is to classify what animal it is.

One of the limitation of current ML framework you're working in is inability to reason about uncertainty over the features. The features extracted from a dataset are often given as point estimates and they do not capture how much the model is confident in its estimation. To quantify the uncertainty you need probabilistic Bayesian model (e.g. Gaussian process). Such models are more complicated because model's weights are assumed to be drawn from some probability distribution. The output y* for input x* would be a probability distribution with some mean and variance. High variance would indicate that the model is not certain in its prediction.

There are some great literature where you can read about it in great detail:

  1. Uncertainty in Deep Learning by Yarin Gal
  2. Gaussian Processes for Machine Learning by Carl Edward Rasmussen and Christopher K. I. Williams
  • 1
Reply Report

what about checking probability score? Eventhough a cup is classifed as Dog , it will have less score. so you can set your threshold. If the probability score > threshold value, then it will be displayed as animal otherwise not.

  • 0
Reply Report
      • 1
    • For now, the model is retrained with 2 categories, which is dog and hamster. Right now the probability for a cup is 0.95... Hamster. Is it possible for this situation?

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions