# How to build classifier if only 1 image per class available

If I have only 1 image for each of 10 classes, what is the best way to build an image classifier? The images themselves are large (1200x1600) and of good quality. For example:

Or similar images from https://www.pexels.com/search/flowers/

From what I have read, neural networks need large amount of data for training. Which other machine learning methods can be used in such a situation? Basically, image similarity needs to be assessed. Can support vector machines be used here?

• Maybe try KNN but it’s hard to answer without more details about the data set and the objective of this classification. – Juju Oct 7 '18 at 3:47
• What more details do you need? – rnso Oct 7 '18 at 3:48
• The set of images and labels. And why only one image per class? It is a theoretical question? In this case it should be easy to get more images and use transfer learning from a pre-trained CNN for example. – Juju Oct 7 '18 at 3:58
• Welcome to stackoverflow. You should try to answer the question rather than questioning the question! For the given situation, do you know of any method that can be applied? If knn is the answer, you should give more details about it. Otherwise, your answer is more like a comment and is likely to be down voted. – rnso Oct 7 '18 at 4:07
• How will you test the model accuracy if you do not have the test data? – Bhakti Aug 27 '19 at 11:28

One image per class in way too less data for building any classifier. Rather than image classification, image similarity matching seems a better approach and so I would suggest you a Siamese network for one-shot learning.

A Siamese network is a class of neural network that contains two or more identical network and are used to differentiate between the input images by maximizing the minimum distance among the images. This technique is helpful for what we call as One-shot learning.

But if you only want to build a classifier, here are a few steps you can think about:

1. Try to increase your dataset size by adding a few more images to you training set.
2. Apply heavy Image-augmentation.
3. Use a Pre-trained model to try transfer learning.

I would try to use transfer learning. Download a pre-trained model, test it on your data, if the accuracy is insufficient, run a fine tuning by sampling a number of random crops from each image (data augmentation) and the test it again.

https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models

There are several tools in python which will help you prepare the dummy data based on your data. You can increase the amount of data first and then try classification.

• It will be better if you can list some of these tools and some details and/or links here. – rnso Aug 29 '19 at 7:27