Training face detection models from object detection repositories - machine-learning

For training a model for face detection, is it possible to take a model for object detection and train it on a face detection data set (with only one class)? Are there any issues with having only 1 class for the object detection model?
The repository I am planning on using is: https://github.com/qfgaohao/pytorch-ssd

What you are talking about is transfer learning. Without any further information about your problem, I think it's best to train both from scratch and using that pre-trained model to see which one performs better.
Are there any issues with having only 1 class for the object detection model?
I am working on a medical project that focuses on detecting one class (lesion), so it's not something unusual in the field.

Related

How to perform pruning on trained object detection model?

Hi I have trained object detection model using tensorflow 1.14 object detection API, my model is performing well. However, I want to reduce/optimize parameters of model to make it lighter. How can I use pruning on trained model?
Did you check the Pruning guide on the Tensorflow website ?
It has concrete examples on how to prune a model and benchmark the size and performance improvements.

Real Time Detection of Multiple Objects with Various Classes with YOLO

I am currently working on detecting whether motorbike drivers are wearing a helmet or not using YoloV3. Firstly I am using the coco model to detect motorbike and then sending the detected motorbike image to the helmet detection Yolo model.
Currently, Yolov3 is taking lots of time in loading weights and performing the detection for each frame.
Is there any way to reduce this time taken as I need to perform the detections in real time.
Also, should I go for multiple Yolo models or should I train a single model containing both the motorbike and helmet class?
I see that you have two different questions:
Is there any way to reduce this time taken as I need to perform the
detections in real time?
Should I go for multiple Yolo models or should I train a single
model containing both the motorbike and helmet class?
Q1: YOLO should work in real-time with GPU unless the image resolution is enormous or your hardware does not meet the requirements. If you can not change the two things above,
Try the smaller model, yolov3_tiny for example. From PyTorch Hub;
model = torch.hub.load('ultralytics/yolov3', 'yolov3_tiny')
Q2: Single model, since YOLO is capable of object detection with multiple classes without sacrificing much speed and accuracy.

Can I add new training pictures to my object detection model without re-running the whole training again?

I used yolov5 to train an object detection model. is it possible to add more annotated images after i have already trained the original model or must i restart the whole training with the new set of images?
You are asking about continual learning - this is a very active field of research, and there is no single solution/method to tackle it. You'll have to do more research to find the right approach for your specific settings.

"Incremental" face training in OpenCV

I've been working with some face detection in OpenCV. I have a couple projects I've done - one does face detection which uses a pre-built model. Some others do different things where I collect my own images and train my own models. When I do the latter, it's generally with much smaller datasets that what you'd use for face training.
On my face recognizer - many of the common faces I work with do not get detected properly (due to odd properties like masks, hats, goggles, glasses, etc). So I want to re-train my own model - but grabbing the gigantic "stock" datasets, adding my images to it may take a VERY long time.
So the question is: is there a way to start with an existing model (XML file) and run the trainer in a way that would just add my images to it?
This is called "Transfer Learning". Tenserflow (Keras) has a lot of support for this. It basically consists of taking a pre-existing model with pre-existing weights, "freezing" weights on certain layers, adding new layers in or below existing ones, and then retraining only the un-frozen layers.
it can't be used to readily just "continue" learning, but can be used to add additional things into the training - for newer aspects (like potentially, adding masked people to an already trained model of unmasked people, as in my original question)

It's possible to do object detection (one-class) in images retraining Inception model?

There is a way to do object detection, retraining Inception model provided by Google in Tensorflow? The goal is to predict wheter an image contains a defined category of objects (e.g. balls) or not. I can think about it as a one-class classification or multi-class with only two categories (ball and not-ball images). However, in the latter I think that it's very difficult to create a good training set (how many and which kind of not-ball images I need?).
Yes, there is a way to tell if something is a ball. However, it is better to use Google's Tensorflow Object Detection API for Tensorflow. Instead of saying "ball/no ball," it will tell you it thinks something is a ball with XX% accuracy.
To answer your other questions: with object detection, you don't need non-ball images for training. You should gather about 400-500 ball images (more is almost always better), split them into a training and an eval group, and label them with this. Then you should convert your labels and images into a .record file according to this. After that, you should set up Tensorflow and train.
This entire process is not easy. It took me a good couple of weeks with an iOS background to successfully train a single object detector. But it is worth it in the end, because now I can rapidly switch out images to train a different object detector whenever an app needs it.
Bonus: use this to convert your new TF model into a .mlmodel usable by iOS/Android.

Resources