Answers.Body: <p>From what I understood, you want to be able to determine whether the input to your classifier is a valid picture or not. Where:</p>
  <ul>
  <li>Valid picture: image of a person wearing or not wearing a seatbelt</li>
  <li>Not valid picture: unrelated images (say a kitchen picture) or noise, or a black image (no input at all)</li>
  </ul>
  <p>For that you could build a Bayesian model from your current deep-learning model. Check out Pyro (from pytorch). The main idea behind it, is that the model will always predict a class: person wearing or not wearing a seatbelt. But since it is a Bayesian model it will also tell you the confidence of the prediction in terms of the similarity of the input with the input distribution for which the model was trained. In other words, it will also tell you &quot;how valid&quot; is that prediction, or &quot;how valid&quot; is the input for that prediction.</p>
  <p>Check out <a href="https://towardsdatascience.com/making-your-neural-network-say-i-dont-know-bayesian-nns-using-pyro-and-pytorch-b1c24e6ab8cd" rel="nofollow noreferrer">this post</a> where it is very well explained. Hope it helps!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-02T15:56:59.237Z
Answers.Text: This may be a good suggestion, but, in practice, it isn't guaranteed that the Bayesian model will provide well-calibrated uncertainty estimates.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-02T18:06:54.403Z
Answers.Text: Thanks so much! If you can reference a way to do so using a CNN and/or Tensorflow, I would appreciate it as it would save time learning a new library. Thanks again.
Answers.UserDisplayName: Samay Lakhani
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-02T11:01:17.997Z
Answers.LastActivityDate: 2020-08-02T11:01:17.997Z
Answers.UserDisplayName: JVGD
Answers.Body: <p>Yes, a category &quot;no person&quot; or &quot;random image&quot; would make sense. Binary classification is only helpful if you know that your input always belongs to one or the other category, for example by pre-filtering the inputs.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-02T22:28:25.883Z
Answers.Text: I've heard using Bayesian Neural Networks are good for this sort of problem. BNNs print out a probability that doesn't add up to only one, and there is a threshold then for the confidence score for the model to be able to say "I don't know." Which approach would be more effective, do you think?
Answers.UserDisplayName: Samay Lakhani
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-03T05:18:23.137Z
Answers.Text: I can't say. In general, you need experience with several methods to judge which is best for a given case, or you need to ask an expert, which I am not in the image classification field.
Answers.UserDisplayName: Hans-Martin Mosner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-01T08:25:39.863Z
Answers.LastActivityDate: 2020-08-01T08:25:39.863Z
Answers.UserDisplayName: Hans-Martin Mosner
Body: <p>I am trying to create a CNN model that classifies if a person is wearing a seatbelt or not to verify they drive safely. I know to get images of people wearing seatbelts and people not wearing seatbelts, but I have a problem.</p>
  <p>What if the person doesn’t submit a picture of them in a car at all? How do I construct the rest of the dataset to determine if that picture is an actual picture of a person wearing a seatbelt?</p>
  <p>Do I insert completely random pictures in a different category? Do I classify images that don’t have a high confidence score as &quot;wrong&quot; images? Or leave it?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-02T21:47:43.527Z
Comments.Text: Yes, thanks! If you can reference a Bayesian NN with CNNs in Tensorflow that would be a great help!
Comments.UserDisplayName: Samay Lakhani
Tags: <deep-learning><convolutional-neural-networks><training>
Title: How to handle images that don’t pertain to image classifier at all?
UserDisplayName: Samay Lakhani
ThreadText: # How to handle images that don’t pertain to image classifier at all?
  
  (Asked by: username_0 on 2020-08-01)
  
  I am trying to create a CNN model that classifies if a person is wearing a seatbelt or not to verify they drive safely. I know to get images of people wearing seatbelts and people not wearing seatbelts, but I have a problem.
  
  What if the person doesn’t submit a picture of them in a car at all? How do I construct the rest of the dataset to determine if that picture is an actual picture of a person wearing a seatbelt?
  
  Do I insert completely random pictures in a different category? Do I classify images that don’t have a high confidence score as "wrong" images? Or leave it?
  
  **Tags:** deep-learning, convolutional-neural-networks, training
  
  > **Comments:**
  > **username_0**: Yes, thanks! If you can reference a Bayesian NN with CNNs in Tensorflow that would be a great help!  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-08-02. Score: 1 | Accepted answer
  
  From what I understood, you want to be able to determine whether the input to your classifier is a valid picture or not. Where:
  
  * Valid picture: image of a person wearing or not wearing a seatbelt
  * Not valid picture: unrelated images (say a kitchen picture) or noise, or a black image (no input at all)
  
  For that you could build a Bayesian model from your current deep-learning model. Check out Pyro (from pytorch). The main idea behind it, is that the model will always predict a class: person wearing or not wearing a seatbelt. But since it is a Bayesian model it will also tell you the confidence of the prediction in terms of the similarity of the input with the input distribution for which the model was trained. In other words, it will also tell you "how valid" is that prediction, or "how valid" is the input for that prediction.
  
  Check out [this post](https://towardsdatascience.com/making-your-neural-network-say-i-dont-know-bayesian-nns-using-pyro-and-pytorch-b1c24e6ab8cd) where it is very well explained. Hope it helps!
  
  > **Comments:**
  > **username_2**: This may be a good suggestion, but, in practice, it isn't guaranteed that the Bayesian model will provide well-calibrated uncertainty estimates.  
  > **username_0**: Thanks so much! If you can reference a way to do so using a CNN and/or Tensorflow, I would appreciate it as it would save time learning a new library. Thanks again.  
  
  ---
  
  ### Answer by username_3 on 2020-08-01. Score: 1
  
  Yes, a category "no person" or "random image" would make sense. Binary classification is only helpful if you know that your input always belongs to one or the other category, for example by pre-filtering the inputs.
  
  > **Comments:**
  > **username_0**: I've heard using Bayesian Neural Networks are good for this sort of problem. BNNs print out a probability that doesn't add up to only one, and there is a threshold then for the confidence score for the model to be able to say "I don't know." Which approach would be more effective, do you think?  
  > **username_3**: I can't say. In general, you need experience with several methods to judge which is best for a given case, or you need to ask an expert, which I am not in the image classification field.  
  
  ---
  
  