## 4 Making the Data Set  
In order to study the monitoring of traffic flows in actual scenarios, the data source of this study uses the large-scale data set of DETection and tRACking (DETRAC) for vehicle detection and tracking. The data set is mainly derived from video images of road crossing bridges in Beijing and Tianjin, and manually labeled 8250 vehicles and 1.21 million target object frames. The shooting scenes include sunny, cloudy, rainy, and night, and the height and angle of each shot are different.  
The steps for making the experimental data set of this project are as follows:  
1. Collecting daytime, dusk, evening, and rainy pictures from the DETRAC data set, a total of 6203 pictures were collected;
2. Combining the 6203 pictures and the VOC_2007 data set to make a DL_CAR data set containing 26,820 pictures;
3. Randomly extracting 80% of the DL-CAR data set to make a training verification set;
4. Randomly extracting 80% from the training verification set to make the training set;
5. The remaining 20% of the DL-CAR data set is used as the verification set and test set in a 1:1 ratio;
6. Organizing your own data set according to the structure of the VOC data set. The folder structure of the VOC data set is shown in Figure 6;
7. Use OpenCV to read all the images in the folder, name them in the order of reading and unify the format to facilitate later statistics.  
In this paper, the LabellImg tool is used to uniformly label each target vehicle on the pictures of the training set, validation set, and test set, and an XML file corresponding to the pictures is generated to store the labeling information for subsequent network training. After that, the XML file corresponding to the picture is generated to store the label information for subsequent network training. The actual labeling steps are:  
1. Using the mouse to select and frame the target vehicle area;
2. Double-clicking to mark the corresponding target category;
3. Clicking \"Save\" after marking.  
Each image in the training verification set initializes a 3D label in the form of [7; 7; 25] with 0, column 0 represents the confidence, column 1-4 represents the central coordinates (\(x_{c}\), \(y_{c}\), \(w\), \(h\)), and column 5-24 represents the object class sequence number. Next, we parse the XML file and take out all target categories in the file and their coordinate values (\(x_{\text{min}}\), \(y_{\text{min}}\), \(x_{\text{max}}\), \(y_{\text{max}}\)) in the upper left and lower corners, these data were then multiplied while using ratio values according to the \(448\times 448\) image scaling factor to obtain (\(x1_{\text{min}}\), \(y1_{\text{min}}\), \(x2_{\text{max}}\), \(y2_{\text{max}}\)). Subsequently, Equation (6) is used to convert the coordinates into the form of center point coordinates, and Equation (7) is used to calculate which grid the target center falls into. In the image label, the grid confidence degree is set to 1, the coordinate of the center point is set to the calculation results of Equations (6)-(7), and the corresponding target category index is set to 1.  
\[\begin{split} x_{c}&=(x1_{\text{min}}+x2_{\text{ max}})/2,w=x2_{\text{max}}-x1_{\text{min}}\\ y_{c}&=(y1_{\text{min}}+y2_{\text{max}})/2,h=y2_{ \text{max}}-y1_{\text{min}}\\ \end{split} \tag{6}\]  
\[x\_ind=[7x_{c}/448],y\_ind=[7y_{c}/448] \tag{7}\]  
In order to enhance the robustness of the network, we use random horizontal flip, random cropping, random color distortion, etc. for data enhancement. We create a dictionary for each picture to store its path and label, and add all dictionaries to the list and save the list in a pkl file.