3
$\begingroup$

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?

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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). $\endgroup$ Jul 9, 2019 at 10:26
  • $\begingroup$ @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 $\endgroup$ Jul 9, 2019 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .