Answers.Body: <p>This is a common problem with all ML models. At the end of the day, they are just math functions. They take the inputs and compute the outputs based on the weights they learned. You can upload random noise to a well trained model and it will give you confident predictions. Ultimately the model can only be relied on to perform well on inputs that fit on the training data manifold.</p>
  <p>You can try create a &quot;book/not-book&quot; binary classifier, but creating a good dataset for the &quot;not book&quot; class is much harder than it may seem. Should you include pictures of cars? Of sandwiches? Of random noise? Of TV screenshots?</p>
  <p>It's much easier to define the space of &quot;this specific class&quot; as opposed to &quot;all things that are not this specific class&quot;.</p>
  <p>One ML approach might be to train a book cover object detection model. This would both identify positive examples of book covers and give you a bounding box to crop the input image around just the book cover.</p>
  <p>Alternatively, you could look at cases where users are uploading non-book covers and try to change the UI/UX of the app to incentivize correct behavior.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-04T20:38:08.427Z
Answers.LastActivityDate: 2023-10-04T20:38:08.427Z
Answers.UserDisplayName: Karl
Answers.Body: <p>One approach would be to train a classifier that will take an image and return a binary prediction of whether it is a book cover or not. This can be done in a supervised fashion. You will use this classifier on every given image input and proceed to the next step of returning details of the cover if and only if the classifier predicted that the image is indeed a book with some probability <span class="math-container">$p&gt;threshold$</span>, which can be predefined.</p>
  <p>As this process is generally an overhead to the actual goal of your app, I would try using basic classifiers first, while also providing a low-dimensional input - I suppose that much can be learned from edges only</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-09T13:49:46.503Z
Answers.LastActivityDate: 2022-09-09T13:49:46.503Z
Answers.UserDisplayName: Hadar Sharvit
Body: <p>I have developed an python based ml web app. It gives details of the book from a image of book cover.</p>
  <p><strong>Problem:</strong> When I upload the book cover image then it works but when i click image of any random object, it still gives the result related to some book in the dataset. How can i detect or filter out such images and tell the user that the image doesn't contain book cover?</p>
  <p>Somewhere I read that we need to add some garbage classes (other classes I am expecting users will upload like person, objects etc.) in the training process. How can we do this?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-09T10:02:51.377Z
Comments.Text: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comments.UserDisplayName: Community
Tags: <machine-learning><computer-vision><python><mlops>
Title: How to filter out class for which the model has not been trained in ml web app?
UserDisplayName: Durgendra
ThreadText: # How to filter out class for which the model has not been trained in ml web app?
  
  (Asked by: username_0 on 2022-09-09)
  
  I have developed an python based ml web app. It gives details of the book from a image of book cover.
  
  **Problem:** When I upload the book cover image then it works but when i click image of any random object, it still gives the result related to some book in the dataset. How can i detect or filter out such images and tell the user that the image doesn't contain book cover?
  
  Somewhere I read that we need to add some garbage classes (other classes I am expecting users will upload like person, objects etc.) in the training process. How can we do this?
  
  **Tags:** machine-learning, computer-vision, python, mlops
  
  > **Comments:**
  > **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2023-10-04. Score: 1
  
  This is a common problem with all ML models. At the end of the day, they are just math functions. They take the inputs and compute the outputs based on the weights they learned. You can upload random noise to a well trained model and it will give you confident predictions. Ultimately the model can only be relied on to perform well on inputs that fit on the training data manifold.
  
  You can try create a "book/not-book" binary classifier, but creating a good dataset for the "not book" class is much harder than it may seem. Should you include pictures of cars? Of sandwiches? Of random noise? Of TV screenshots?
  
  It's much easier to define the space of "this specific class" as opposed to "all things that are not this specific class".
  
  One ML approach might be to train a book cover object detection model. This would both identify positive examples of book covers and give you a bounding box to crop the input image around just the book cover.
  
  Alternatively, you could look at cases where users are uploading non-book covers and try to change the UI/UX of the app to incentivize correct behavior.
  
  
  ---
  
  ### Answer by username_3 on 2022-09-09. Score: 0
  
  One approach would be to train a classifier that will take an image and return a binary prediction of whether it is a book cover or not. This can be done in a supervised fashion. You will use this classifier on every given image input and proceed to the next step of returning details of the cover if and only if the classifier predicted that the image is indeed a book with some probability $p>threshold$, which can be predefined.
  
  As this process is generally an overhead to the actual goal of your app, I would try using basic classifiers first, while also providing a low-dimensional input - I suppose that much can be learned from edges only
  
  
  ---
  
  