# Automobile Fine-Grained Detection Algorithm Based on Multi-Improved YOLOv3 in Smart Streetlights
## 3 Methodology
### Improvement of the Model's Generalization Ability
#### 3.3.1 Improvement Based on Label Smoothing  
The training dataset used in this paper is generally from dataset UA-DETRAC. Dataset UA-DETRAC was collected from real roads, while the vehicles on the roads are generally sedans and SUVs, and the number of trucks, pick-ups and commercial vehicles is significantly smaller than that of sedans. Although some of these vehicles, in small numbers, were also manually collected and labeled in this paper, which are also added to the training dataset, this still cannot balance the numbers of various classes of vehicles. For vehicle classes with small numbers in the dataset, the deep neutral network might not be able to learn features with strong generalization ability, and, as a result, the final model obtained by training has poor generalization ability. In this paper, the label smoothing technique is adopted to maximally prevent the problem of the weak generalization ability of the model.  
When the target detection algorithm proposed in this paper is finally used to predict the target class, the one-hot coding method is adopted. For example, if the sample is observed as belonging to a certain class, the position of the corresponding class of vector has the value of 1, or otherwise, it is 0. Such a coding method may cause over-fitting when the above samples have uneven distribution, because limited samples are used for training in general, which cannot cover all possible situations. In an extreme example, when the training data include 200,000 sedans but only 3000 pick-ups, the occurrence probability of a sedan is around 98.52%, while that of a pick-up is only about 1.48%. In this case, with continuous training, the neutral network tends to predict the class of sedan, and the probability of the predicted class being a sedan is 100% or very close to 100%, while the class of pick-ups is ignored. At this time, the model is \"overconfident\" in the prediction of sedans.  
The Label Smoothing Regularization (LSR) method aims to alleviate the over-fitting problem which tends to occur because the true-value label is not \"soft\" enough. It is a constraint method which adds some noise to the true value of the class to constrain the model and lower the over-fitting degree of the trained model.  
The LSR formula is as shown in Formula (8), in which \(q_{i}\) represents the one-hot coding after smoothing; \(\varepsilon\in[0,1]\), \(\varepsilon\) is a small hyper-parameter, which represents the smoothing degree or how much noise has been added to the real value, and bigger \(\varepsilon\) indicates more noise has been added to real value; K refers to the number of classes; the true value of the class is generally stored in the ID of the class before being transformed to the one-hot code, and in the formula, y is the ID of the classes true value.  
\[q_{i}=\left\{\begin{array}{ll}1-\varepsilon\;\mathrm{i}=y\\ \frac{\varepsilon}{\mathrm{K-1}}\;\mathrm{else}\end{array}\right. \tag{8}\]  
In essence, LSR takes the value of true-value class in the original one-hot code from \(\varepsilon\), and then evenly distributes it among other classes, so that the final distribution of true-value label is no longer distributed on its true-value position. As shown in Figure 5, \(\varepsilon=0\) on the left diagram, which means no LSR; the right diagram shows the case of \(\varepsilon=0.1\).  
In the above diagram, only five classes are chosen to present the change of label value before and after label smoothing. In the meantime, \(\varepsilon\) is set as 0.1 to make it easier to see the change. In practical training, \(\varepsilon\) is set as 0.01. It can be seen that the label value has a broader distribution after label smoothing. As a result, the model is finally not that \"confident\", and the model's generalization ability is improved.