Answers.Body: <p>From how you've phrased your question I'm going to assume you've jumped in without much structured training in data science, so I'll answer at a fairly high level.</p>
  
  <p>This is an inherent problem with image classification in that if your final layer only has food classes then whatever you feed in will always be classified as a type of food regardless of what is actually in the image.  </p>
  
  <p>There are a few techniques you could try.  The simplest and fastest being using a pre-built classifier to screen the input data for the presence of "food" and then only using your own classifier to determine what type of food it is.  Any of the open source imageNet networks would be a good step here - if that finds something with a food label then use your classifier to identify the category.  This means you won't need to retrain although you'll be at the mercy of any errors in the pre-trained category classifier, which is outside of your control.  Here's a good how to guide: <a href="https://www.learnopencv.com/keras-tutorial-using-pre-trained-imagenet-models/" rel="nofollow noreferrer">https://www.learnopencv.com/keras-tutorial-using-pre-trained-imagenet-models/</a> </p>
  
  <p>Another option is to add a negative class to your data set consisting of non-food items that you label "other".  This is probably trickier as you'd need to cover all the non-food categories that your network will see and ensure that it doesn't learn the background.</p>
  
  <p>Take a look at your final level and make a call about whether to accept the top result or not. You're forcing a choice and these values may give a clue as to the level of error in the prediction.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-31T14:03:18.117Z
Answers.Text: thanks for your reply. Could you please explain why should I ensure that "it doesn't learn the background" ?
Answers.UserDisplayName: TSR
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-31T16:10:42.713Z
Answers.Text: You want your network to learn about the objects and not the background.  If your "other" set has something common in the background then your may find that your other class picks up on that instead, even if there is food in the image.  For a very trivial example, lets say that all your food classes were on white plates, and all your "other" class had darker backgrounds, your network might learn that dark equalled "other" and white meant food so you would get food on dark plates falsely labelled as other and potentially images that had pale discs being classified as food.
Answers.UserDisplayName: Yssybyl
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-31T13:59:23.830Z
Answers.LastActivityDate: 2018-07-31T13:59:23.830Z
Answers.UserDisplayName: Yssybyl
Body: <p>I want to train a model to recognize different category of food (example: rice, burger, apple, pizza, orange,... )</p>
  
  <p>After the first training, I realized that the model is detecting other object as food. (example: hand -> fish, phone -> Chocolate, person -> candies... )</p>
  
  <p>I get a very low loss because the testing dataset and validation must have at least a pictures of food. But when it comes to picture of object other than food, the model fails. How do label the dataset in way that the model will not do any detection if there is no food on the picture?</p>
  
Tags: <machine-learning><computer-vision><models><object-recognition>
Title: How to label “other” while labeling image for object detection/classification?
UserDisplayName: TSR
ThreadText: # How to label “other” while labeling image for object detection/classification?
  
  (Asked by: username_0 on 2018-07-30)
  
  I want to train a model to recognize different category of food (example: rice, burger, apple, pizza, orange,... )
  
  After the first training, I realized that the model is detecting other object as food. (example: hand -> fish, phone -> Chocolate, person -> candies... )
  
  I get a very low loss because the testing dataset and validation must have at least a pictures of food. But when it comes to picture of object other than food, the model fails. How do label the dataset in way that the model will not do any detection if there is no food on the picture?
  
  **Tags:** machine-learning, computer-vision, models, object-recognition
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-07-31. Score: 1
  
  From how you've phrased your question I'm going to assume you've jumped in without much structured training in data science, so I'll answer at a fairly high level.
  
  This is an inherent problem with image classification in that if your final layer only has food classes then whatever you feed in will always be classified as a type of food regardless of what is actually in the image.
  
  There are a few techniques you could try. The simplest and fastest being using a pre-built classifier to screen the input data for the presence of "food" and then only using your own classifier to determine what type of food it is. Any of the open source imageNet networks would be a good step here - if that finds something with a food label then use your classifier to identify the category. This means you won't need to retrain although you'll be at the mercy of any errors in the pre-trained category classifier, which is outside of your control. Here's a good how to guide: <https://www.learnopencv.com/keras-tutorial-using-pre-trained-imagenet-models/>
  
  Another option is to add a negative class to your data set consisting of non-food items that you label "other". This is probably trickier as you'd need to cover all the non-food categories that your network will see and ensure that it doesn't learn the background.
  
  Take a look at your final level and make a call about whether to accept the top result or not. You're forcing a choice and these values may give a clue as to the level of error in the prediction.
  
  > **Comments:**
  > **username_0**: thanks for your reply. Could you please explain why should I ensure that "it doesn't learn the background" ?  
  > **username_1**: You want your network to learn about the objects and not the background.  If your "other" set has something common in the background then your may find that your other class picks up on that instead, even if there is food in the image.  For a very trivial example, lets say that all your food classes were on white plates, and all your "other" class had darker backgrounds, your network might learn that dark equalled "other" and white meant food so you would get food on dark plates falsely labelled as other and potentially images that had pale discs being classified as food.  
  
  ---
  
  