# Training Object Detection model on just 10 images

I am trying to train an object detection model using Mask-RCNN with Resnet50 as backbone. I am using the pre-trained models from PyTorch's Torchvision library. I have only 10 images that I can use to train. Of the same 10 images, I am using 3 images for validation. For the evaluation, I am using the evaluation method used in COCO dataset which is also provided as .py scripts in the TorchVision's github repository.

To have enough samples for training, I am oversampling the same 10 images by a factor of 100 i.e. I end up with 1000 images that I can use to train my model. Similarly, I end up having 300 images that I can use for validation.

Now, the problem is that I am getting 0% mAP after train and 0% recall. I have two questions:

Q1. Why would it return 0% mAP?

If it has something to do with the fact that I am oversampling to a large extent, then my next question is

Q2. Shouldn't the oversampling just cause the model to Overfit and instead provide a higher training as well as validation accuracy for my case (since I have picked the validation data from the training data itself?

• I'm not an expert in ML with images, but don't expect miracles with oversampling: giving the same image 100 times doesn't provide the model with more information than giving it once, since the features are all the same. I don't know how many features and parameters are involved, but I'm pretty sure that 7 training instances doesn't even start to cover a representative sample. Oct 24 '20 at 23:42
• @Erwan I understand that with only 10 images (oversampled to 1000), I cannot get a generalized model and I am not even trying to get a generalized. Infact, I am trying to get an overfitted model that will work perfectly fine on the images on which it has been trained. FYI..I am not using just 7 images to train the model. I am using all the 10 images to train and of the same 10, I am using 3 to validate the model. What I am trying to understand is that since the validation images are also part of the training images, how can the mAP come out to be 0%? Oct 26 '20 at 17:51

Consider using data Augmentation first, you'll have a couple of hundred new images for you to work with, then add some noisy images since to avoid over-fitting. This way you'll have better results.

• I don't want a generalized model therefore don't really need the augmentation. I am trying to find the boxes in the same image on which I have trained the model. Oct 26 '20 at 17:52
• You have too few images, so you can't do that.
– MXK
Oct 27 '20 at 7:45
• But can you explain why is that? It's not like the number of samples are low. Just that the features in the samples are nearly the same. Wouldn't that simply help in increasing the confidence of prediction if the same image is used for prediction? Oct 27 '20 at 11:33
• no, it not enough for the model to learn anything, simply imagine you're studying for an exam that have 100 courses, but you only revised 1, in your case you have learned almost nothing, and the same goes for ANN's. In technical terms you have activation functions that needs to process valid data to be activated in order to give results as output for the other layers, otherwise the informations will get lost in the blackbox of your model.
– MXK
Oct 27 '20 at 13:12
• To your exam analogy, if after revising I get faced with the same exam that I had revised, I should be able answer that correctly atleast. I understand that if anything else comes up, I would not do well there. And I don't have a problem with that (that's why I said I don't need a generalized model). I just need the model to predict the images on which it has been trained correctly. Oct 27 '20 at 13:20

From the comments, it sounds like all you want to do is detect the images you have. That makes this an easy problem.

If a given image is the same as an image you have, return the information (such as a category) for that image. If the given image does not match an image you have, do not return such information.

In Python, that would be something like this.

if image in list_of_images:
return(label)
else:
return