Answers.Body: <p>I would do the following:</p>
  
  <ul>
  <li><p>Add some images without the item present to your training data. Ideally some other item taken against similar backgrounds, lighting etc. And maybe some of just the background.</p></li>
  <li><p>Obtain a pre-trained neural network CNN model, such as AlexNet, VGG-19 or Inception v5.</p></li>
  <li><p>Load the neural network model, remove the very last layer (typically a 1000-way softmax), and replace with a brand new layer for classifying whether your object is present or not. Maybe use a 2-way softmax for "my object" vs "unknown object".</p></li>
  <li><p>Freeze all the layers other than your own (most NN libraries will have a way to do this, or you could just run the old network truncated to extract a feature vector from penultimate layer.</p></li>
  <li><p>Train using your 5 images. This kind of limited training is often called "fine tuning". </p></li>
  <li><p>Find some way to test your classifier before relying on it. You may have to do a leave-one-out test where you train your network 5 times, each with 4 of the images, and see whether it correctly identifies the 5th one vs a few images without the item in it. Even with that approach, with such a small sample, you will have only the vaguest idea of how reliable your new classifier is.</p></li>
  </ul>
  
  <p>You'll do a lot better if you can obtain more images to train and test with. If you get enough images (both positive and negative), you can consider replacing more layers before fine tuning. Otherwise you are heavily relying on your object being similar enough to something from the ImageNet collection that a classifier trained on that will extract useful high-level features.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-06T08:19:55.203Z
Answers.LastActivityDate: 2017-12-06T15:03:29.097Z
Answers.LastEditDate: 2017-12-06T15:03:29.097Z
Answers.UserDisplayName: Neil Slater
Answers.Body: <p>In adittion to @Neil Slater’s answer, you can also “increase” your data set by using data augmentation techniques.</p>
  
  <p>What this basically means for images is to transform the ones you have into new ones without changing the result if the classification. For example, if you move everything 20 pixels to the right, it’s likely that your object will still be there, and from 5 examples now you’ve got 6.</p>
  
  <p>Note that this is usually done for regularizarion: it prevents the network from associating particular positions / sizes / colors to the end result. This is something that big pre-trained NNs already account for, but with your small data set, it’s very likely you’ll also benefit from it. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-08T17:17:56.303Z
Answers.LastActivityDate: 2017-12-08T17:17:56.303Z
Answers.UserDisplayName: Alpha
Body: <p>Let's suppose I have 5 images, all of which I assure you are of the same item, but from various angles and perhaps different lighting conditions. I now supply you with an additional image, and I want a score of how likely this image is to contain the item depicted in the first five pictures.</p>
  
  <p>Let us suppose that the item isn't too complex. It won't be a pile of fabric with a pattern on it, dropped several different ways, and won't be a keychain with keys in different conformations. It will also be more complex than just a blue ball shot from different angles. How might you approach the problem of scoring this image?</p>
  
Tags: <image-recognition><training>
Title: Identifying if an image contains an object with very small (five image) training data set
UserDisplayName: Evan
ThreadText: # Identifying if an image contains an object with very small (five image) training data set
  
  (Asked by: username_0 on 2017-12-06)
  
  Let's suppose I have 5 images, all of which I assure you are of the same item, but from various angles and perhaps different lighting conditions. I now supply you with an additional image, and I want a score of how likely this image is to contain the item depicted in the first five pictures.
  
  Let us suppose that the item isn't too complex. It won't be a pile of fabric with a pattern on it, dropped several different ways, and won't be a keychain with keys in different conformations. It will also be more complex than just a blue ball shot from different angles. How might you approach the problem of scoring this image?
  
  **Tags:** image-recognition, training
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-12-06. Score: 1
  
  I would do the following:
  
  * Add some images without the item present to your training data. Ideally some other item taken against similar backgrounds, lighting etc. And maybe some of just the background.
  * Obtain a pre-trained neural network CNN model, such as AlexNet, VGG-19 or Inception v5.
  * Load the neural network model, remove the very last layer (typically a 1000-way softmax), and replace with a brand new layer for classifying whether your object is present or not. Maybe use a 2-way softmax for "my object" vs "unknown object".
  * Freeze all the layers other than your own (most NN libraries will have a way to do this, or you could just run the old network truncated to extract a feature vector from penultimate layer.
  * Train using your 5 images. This kind of limited training is often called "fine tuning".
  * Find some way to test your classifier before relying on it. You may have to do a leave-one-out test where you train your network 5 times, each with 4 of the images, and see whether it correctly identifies the 5th one vs a few images without the item in it. Even with that approach, with such a small sample, you will have only the vaguest idea of how reliable your new classifier is.
  
  You'll do a lot better if you can obtain more images to train and test with. If you get enough images (both positive and negative), you can consider replacing more layers before fine tuning. Otherwise you are heavily relying on your object being similar enough to something from the ImageNet collection that a classifier trained on that will extract useful high-level features.
  
  
  ---
  
  ### Answer by username_2 on 2017-12-08. Score: 1
  
  In adittion to @username_1’s answer, you can also “increase” your data set by using data augmentation techniques.
  
  What this basically means for images is to transform the ones you have into new ones without changing the result if the classification. For example, if you move everything 20 pixels to the right, it’s likely that your object will still be there, and from 5 examples now you’ve got 6.
  
  Note that this is usually done for regularizarion: it prevents the network from associating particular positions / sizes / colors to the end result. This is something that big pre-trained NNs already account for, but with your small data set, it’s very likely you’ll also benefit from it.
  
  
  ---
  
  