Answers.Body: <blockquote>
    <p>Is this a good approach? Will I have a lot of trouble with different backgrounds?</p>
  </blockquote>
  
  <p>A lot will depend on the nature of the backgrounds you have, and how well they encode/decode by themselves without the object in frame. My gut feeling is that your system will have poor performance compared to a properly trained classifier, as the autoencoder will naturally have to get good at constructing background elements in order to score well, so unless your object is very consistently always in a similar place with radically different appearance to the background then the autoencoder will get good reconstructions of background-only frames, and your anomaly detection would need to be set too sensitive. That would cause the detector to fail to spot the object when in frame.</p>
  
  <p>There is a catch-all answer to "how well will my idea work" with ML projects. You should try it and see. Data science is essentially an empirical approach, and building practical models is an engineering discipline where testing is a core part of the process.</p>
  
  <p>In order to test your model, you are going to need a lot of images of just background, including all the kinds of background that you expect the system to be used. Which begs the question, why not collect a range of suitable images without your target object, and use them as the second class?</p>
  
  <blockquote>
    <p>This doesn't solve the problem, because I don't know what else could not be an object. It would be impossible to train for 2 classes: object / not object.</p>
  </blockquote>
  
  <p>Actually, it is easy. Just collect suitable images from locations where you expect your system to be used, without the object in frame. These are your "Not Object" class. A "Not Object" does not have to include some substitute foreground object. Although I recommend that you do have some images like this to prevent accidentally creating an "object is in the foreground" detector*. The primary goal should be to be collect data that matches how the model will be used once deployed. That will depend a lot on how much control and consistency you get over the production cameras where the trained detector will be put to use.</p>
  
  <p>I would do this, then train a standard binary classifier.</p>
  
  <p>If you are still interested in how well your auto-encoder idea could work, you then have plenty of test data to evaluate it.</p>
  
  <hr>
  
  <p>*  This is one area where your auto-encoder idea <em>might</em> do better than a classifier - reconstructing unfamiliar foreground objects should be hard for it leading to high error.</p>
  
  <p>It is too difficult to tell in advance whether this effect is strong enough to make your auto-encoder approach better than a classifier.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T10:26:18.667Z
Answers.Text: thank you. Yes I will test it out, but before I start collecting data, I would like to bounce my ideas with someone :D After your post, it get me thinking regarding the background. My object would naturally occupy most of the image (60% or more). I could have train data with white background. In this case only object would be reconstructed good, and the background not. Then I can distinguish, if outoencoder reconstruct half of he image or completely fail (only background).
Answers.UserDisplayName: Marko Zadravec
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T10:57:26.497Z
Answers.Text: @MarkoZadravec: With the object takingu p such a large part of the image, your autoencoder idea seems more possible. I would not train with white background though. You need to train with real data. The more your training data and production data are different, the more problems you will have with accuracy when deploying your model
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T10:09:12.773Z
Answers.LastActivityDate: 2019-07-09T10:51:56.947Z
Answers.LastEditDate: 2019-07-09T10:51:56.947Z
Answers.UserDisplayName: Neil Slater
Body: <p>I would like to create a model, that will tell me if one type of object is in an image or not. </p>
  
  <p>So, for example, I have a camera and I would like to see when one object gets into the shot.</p>
  
  <ul>
  <li><p>Object detection: This could be an overkill, because I don't need to know the bounding box around. Also, this means that I would need to label a lot of images, and draw the bounding box to have train data (a lot of time)</p></li>
  <li><p>Image classification: This doesn't solve the problem, because I don't know what else could not be an object. It would be impossible to train for 2 classes: object / not object. </p></li>
  </ul>
  
  <p><strong>My idea</strong> is to have Autoencoder. Train it only on data with the object. Then, if Autoencoder produces a result with a high difference with the original, I detect it as an anomaly - no object. </p>
  
  <p>Is this a good approach? Will I have a lot of trouble with different backgrounds?</p>
  
Tags: <deep-learning><ai-design><autoencoders><object-detection>
Title: How should I detect an object in a camera image?
UserDisplayName: Marko Zadravec
ThreadText: # How should I detect an object in a camera image?
  
  (Asked by: username_0 on 2019-07-09)
  
  I would like to create a model, that will tell me if one type of object is in an image or not.
  
  So, for example, I have a camera and I would like to see when one object gets into the shot.
  
  * Object detection: This could be an overkill, because I don't need to know the bounding box around. Also, this means that I would need to label a lot of images, and draw the bounding box to have train data (a lot of time)
  * Image classification: This doesn't solve the problem, because I don't know what else could not be an object. It would be impossible to train for 2 classes: object / not object.
  
  **My idea** is to have Autoencoder. Train it only on data with the object. Then, if Autoencoder produces a result with a high difference with the original, I detect it as an anomaly - no object.
  
  Is this a good approach? Will I have a lot of trouble with different backgrounds?
  
  **Tags:** deep-learning, ai-design, autoencoders, object-detection
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-07-09. Score: 2 | Accepted answer
  
  > Is this a good approach? Will I have a lot of trouble with different backgrounds?
  
  A lot will depend on the nature of the backgrounds you have, and how well they encode/decode by themselves without the object in frame. My gut feeling is that your system will have poor performance compared to a properly trained classifier, as the autoencoder will naturally have to get good at constructing background elements in order to score well, so unless your object is very consistently always in a similar place with radically different appearance to the background then the autoencoder will get good reconstructions of background-only frames, and your anomaly detection would need to be set too sensitive. That would cause the detector to fail to spot the object when in frame.
  
  There is a catch-all answer to "how well will my idea work" with ML projects. You should try it and see. Data science is essentially an empirical approach, and building practical models is an engineering discipline where testing is a core part of the process.
  
  In order to test your model, you are going to need a lot of images of just background, including all the kinds of background that you expect the system to be used. Which begs the question, why not collect a range of suitable images without your target object, and use them as the second class?
  
  > This doesn't solve the problem, because I don't know what else could not be an object. It would be impossible to train for 2 classes: object / not object.
  
  Actually, it is easy. Just collect suitable images from locations where you expect your system to be used, without the object in frame. These are your "Not Object" class. A "Not Object" does not have to include some substitute foreground object. Although I recommend that you do have some images like this to prevent accidentally creating an "object is in the foreground" detector\*. The primary goal should be to be collect data that matches how the model will be used once deployed. That will depend a lot on how much control and consistency you get over the production cameras where the trained detector will be put to use.
  
  I would do this, then train a standard binary classifier.
  
  If you are still interested in how well your auto-encoder idea could work, you then have plenty of test data to evaluate it.
  
  ---
  
  \* This is one area where your auto-encoder idea *might* do better than a classifier - reconstructing unfamiliar foreground objects should be hard for it leading to high error.
  
  It is too difficult to tell in advance whether this effect is strong enough to make your auto-encoder approach better than a classifier.
  
  > **Comments:**
  > **username_0**: thank you. Yes I will test it out, but before I start collecting data, I would like to bounce my ideas with someone :D After your post, it get me thinking regarding the background. My object would naturally occupy most of the image (60% or more). I could have train data with white background. In this case only object would be reconstructed good, and the background not. Then I can distinguish, if outoencoder reconstruct half of he image or completely fail (only background).  
  > **username_1**: @MarkoZadravec: With the object takingu p such a large part of the image, your autoencoder idea seems more possible. I would not train with white background though. You need to train with real data. The more your training data and production data are different, the more problems you will have with accuracy when deploying your model  
  
  ---
  
  