# Vehicle Detection with Self-Training for Adaptative Video Processing Embedded Platform
## 3 Methods
### Automatic Labelling and Fine-Tuning  
The goal of this stage is to collect a set of training images with corresponding labels that will be used later for automatic fine-tuning of the network with the expected effect of improvement of the detection accuracy of the model in the deployed environment. However, there is no point in collecting superfluous samples, namely those for which the neural network is already confident enough. Intuitively, the use of similar samples for fine-tuning would not bring many benefits to the accuracy of the classifier. Additionally, a considerable number of the detection results returned by the neural network are inaccurate. Consequently, the main challenge here is keeping the number of noisy labels as low as possible. Our algorithm for obtaining labels automatically is based on two observations (Figure 3):  
* some of the vehicles are tracked for dozens of frames, but still, the confidence of the object detector is very low. Long, high confidence tracks can be collected, and from those, it is possible to find vehicle detections predicted with low confidence. Those samples can be used then for the fine-tuning of the neural network, which should increase the accuracy of the classifier; and,
* some background static objects are detected as vehicles. Those objects can be filtered out using a background model. Because the traffic monitoring system works with a static camera, a reliable model of the background can be created to improve the detector accuracy. For this purpose, a popular background subtraction method created by [PERSON] et al. [42] is used. It is a Gaussian Mixture-based method, where each pixel is modelled by a mixture of K Gaussian distributions (K = 5 is used in our experiments). Figure 4 shows an example of the foreground/background separation. Pseudo-code of our algorithm for automatic labelling is presented in the Algorithm 1. First, tracks with high confidence are saved, i.e., those that were tracked for at least \(L_{min}\) consecutive frames or at least one of the detections had high confidence (lines 4-5). Such a definition can still entail some noisy labels; hence, the background subtraction algorithm to differentiate between the background and moving objects in the scene is used. From the detected objects, those that contain no more than \(T_{m}\)* 100% moving pixels are filtered-out (line 20). Because a one-stage detector is used in our work, it means that the whole scene is used for the training of our detector, which may still fail to detect some of the objects in the scene. To minimise the number of such examples, the background model is used again. Specifically, a candidate frame is accepted if at least \(T_{c}\)* 100 % of the foreground pixels are exploited with regard to detections (line 30). In our experiments, the following constants were used \(T_{m}=0.05\), \(T_{c}=0.8\), \(C_{min}=0.4\), \(C_{max}=0.65\), \(L_{min}=10\), and \(C_{t}=0.9\). Figure 4: Background/foreground separation using background subtraction algorithm [42]. Figure 3: Even though some vehicles are being tracked for many frames, they are detected by an object detector with low confidence (car on the left image with confidence = 0.55, truck on the right image with confidence = 0.44). Note that false positive detection (car detected in the upper part of the right image) can be removed using the background model.