Vehicle re-identification data set making and model training method based on video grouping
By collecting videos in groups under multiple lighting conditions and combining YOLO11-L detection with ResNet50-IBN network training model, the problems of constructing vehicle re-identification dataset and fusing multi-source data were solved, improving recognition accuracy and generalization ability, and realizing the efficient application of vehicle re-identification model in real-world scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INTELLIGENT INTER CONNECTION TECH CO LTD
- Filing Date
- 2025-12-16
- Publication Date
- 2026-04-10
AI Technical Summary
Existing technologies struggle to efficiently construct high-quality vehicle re-identification datasets that fit real-world scenarios. During multi-source data fusion training, the generalization ability is weak and the recognition accuracy is insufficient, resulting in low recognition accuracy of the model in real-world complex scenarios.
Videos were collected in groups under multiple lighting conditions. Target detection and tracking were performed using the YOLO11-L detection model. Adaptive sampling was used to generate a private dataset. After merging the public dataset, random sampling was performed. The ResNet50-IBN backbone network and loss function were used to train the model, adjusting for the imbalance in the distribution of multi-source data and domain differences.
This has improved the accuracy and generalization ability of the vehicle re-identification model in real-world application scenarios, ensuring accurate recognition results across time and cameras.
Smart Images

Figure CN121837718A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of vehicle re-identification, and in particular to a vehicle re-identification dataset production and model training method based on video grouping. BACKGROUND
[0002] Vehicle re-identification technology is a key support in the field of intelligent transportation and public security, and the core goal is to accurately identify the same vehicle across time and cameras, and to realize target tracking. Existing technologies mostly rely on public datasets or simply merge private datasets to train models, and adopt traditional random sampling strategies. However, public datasets have problems such as single scene, insufficient intra-class difference, poor cross-domain generalization, etc., and the production of private datasets requires a large amount of manual work and time; simple merging of multi-source data can easily lead to distribution imbalance and significant domain difference, and the model trained in this way has low recognition accuracy in real complex scenes, and is difficult to meet the actual needs of accurate control and tracking. SUMMARY
[0003] The present application solves the technical problems that the prior art cannot efficiently construct a high-quality dataset that adapts to actual scenes, and that the generalization ability is weak and the recognition accuracy is insufficient when training multi-source data.
[0004] To solve the above technical problems, the present application provides a vehicle re-identification dataset production and model training method based on video grouping, which comprises the following steps: using a plurality of high-resolution monitoring camera acquisition devices to continuously shoot under multiple lighting conditions and group in actual application scenes to obtain a plurality of numbered video sets; using YOLO11-L as a detection model to perform target detection and tracking on the plurality of numbered video sets, and outputting a plurality of video target continuous trajectory sets; performing adaptive sampling, dataset generation, manual screening and dataset division on each vehicle trajectory in the plurality of video target continuous trajectory sets to obtain a private video training set; collecting a public dataset, performing data set merging on the public dataset and the private video training set to obtain a video merged training set; performing random sampling according to the video merged training set to construct a dynamic sub-dataset, using ResNet50-IBN as a backbone network to perform model training on the dynamic sub-dataset, and constructing a vehicle re-identification model.
[0005] The present application provides one or more technical solutions, which have at least the following technical effects:
[0006] This application acquires high-quality private datasets by grouping videos under real-world multi-scene and multi-light conditions, followed by target detection and tracking, adaptive sampling, manual screening, and structuring of the dataset. After merging the public datasets, dynamic sub-datasets are constructed using grouped probability sampling. Model training is then performed using a specific backbone network and loss function to address the imbalance in the distribution of multi-source data and domain differences. This enables accurate vehicle re-identification across time and cameras, resulting in better recognition accuracy and generalization ability of the vehicle re-identification model in real-world business scenarios. The application achieves the technical effect of efficiently constructing high-quality adaptive data and improving the recognition accuracy and generalization ability of the vehicle re-identification model in practical application scenarios. Attached Figure Description
[0007] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0008] Figure 1 This is a flowchart illustrating a method for creating a vehicle re-identification dataset and training a model based on video grouping, as provided in an embodiment of this application.
[0009] Figure 2 This is a schematic diagram illustrating the process of obtaining a private video training set in a method for creating a vehicle re-identification dataset and training a model based on video grouping, as provided in an embodiment of this application. Detailed Implementation
[0010] This application provides a method for creating a vehicle re-identification dataset and training a model based on video grouping, which solves the technical problems of existing technologies that make it difficult to efficiently construct high-quality data that adapts to real-world scenarios, and that have weak generalization ability and insufficient recognition accuracy when training with multi-source data fusion.
[0011] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0012] It should be noted that any variation of the terms "comprising" and "having" is intended to cover non-exclusive inclusion, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to such processes, methods, products, or devices.
[0013] like Figure 1 As shown, a method for creating a vehicle re-identification dataset and training a model based on video grouping is provided, wherein the method includes:
[0014] Multiple high-resolution surveillance cameras were used to continuously capture images under various lighting conditions in real-world application scenarios, and the images were grouped to obtain multiple sets of numbered videos.
[0015] Specifically, firstly, high-resolution, high-definition network surveillance cameras are used as acquisition devices. Typical scenarios in the field of intelligent transportation are selected, such as urban intersections, public parking lots, park roads, parking spaces, crossroads, and normal roads. The continuous recording function of the cameras is then activated to capture video. This method is a conventional continuous acquisition method in the existing video surveillance field.
[0016] Subsequently, the shooting time was adjusted to cover different lighting conditions: daytime scenes were shot from 8:00 to 18:00 each day, nighttime scenes were shot from 20:00 to 5:00 the next day, dawn scenes were shot within 1 hour after sunrise, dusk scenes were shot within 1 hour before sunset, and shooting was carried out simultaneously when there were weather conditions such as rain, snow, and fog. At the same time, the camera's automatic exposure adjustment function was enabled to adapt to different light intensities to ensure clear images.
[0017] Next, the unique serial number information of the video capture device is extracted. Combined with the time period information of the video recording, complete video segments recorded continuously by the same device within the same time period are grouped together. Then, a globally unique identifier is generated by combining the device number with the recording start time and the group number. For example, the device number, the recording start time and the group number are combined in sequence to obtain the GroupID of the corresponding group of videos.
[0018] By using high-resolution surveillance cameras to continuously capture images under various lighting conditions in typical scenarios, and combining this with equipment and time period information to group and number the images, the goal of obtaining a diverse collection of numbered videos was achieved.
[0019] YOLO11-L is used as the detection model to perform target detection and tracking on the multiple sets of numbered videos, and outputs multiple sets of continuous target trajectories.
[0020] In this embodiment, YOLO11-L is one of the latest real-time object detector model variants in the Ultralytics YOLO series. It has enhanced feature extraction capabilities, optimized efficiency and speed, supports multiple tasks such as object detection and instance segmentation, and can be deployed in various environments such as edge devices and cloud platforms. It is suitable for real-world scenarios such as surveillance and intelligent transportation.
[0021] Optionally, the acquired multiple sets of numbered videos are processed frame by frame. First, the vehicle targets in each frame are identified and their location range is marked. Then, targets belonging to the same vehicle in consecutive video frames are matched and associated through cross-frame association to clarify the continuous motion trajectory of the same vehicle in the video sequence. At the same time, the composition conditions of the trajectory and the relevant standards of the target location range are defined to finally form a complete set of continuous vehicle trajectories.
[0022] For each vehicle trajectory in the set of multiple sets of continuous video target trajectories, adaptive sampling, dataset generation, manual screening, and dataset partitioning are performed to obtain a private video training set.
[0023] In one embodiment of this application, adaptive sampling is performed on multiple sets of continuous vehicle trajectories, a dataset storage structure containing a three-level directory is built, the sampled images are saved according to the structure to generate an initial dataset, the initial dataset is filtered by the set image filtering rules to obtain a usable dataset, and then the usable dataset is reasonably divided to finally form a private video training set.
[0024] Collect a public dataset, and merge the public dataset and the private video training set to obtain a merged video training set.
[0025] Specifically, the public dataset is first mapped according to the dataset directory. A certain number of IDs are selected from the mapped public dataset to form a part of the public dataset. Then, the private video training set is merged with this part of the public dataset to obtain the merged video training set.
[0026] Random sampling is performed on the video merged training set to construct a dynamic sub-dataset. ResNet50-IBN is used as the backbone network to train the model on the dynamic sub-dataset and construct a vehicle re-identification model.
[0027] Optionally, the video training set is first split into two parts: a public dataset and a private dataset, based on the data source. After initializing the sampling probability of each group, a group is randomly sampled. If the sampled group belongs to the public dataset, a new group is selected from the private dataset with equal probability, and together with the public dataset part, they form a dynamic subset. If the sampled group belongs to the private dataset, it is directly added to the public dataset part, thereby completing the construction of the dynamic subset.
[0028] Then, a specified backbone network is used, combined with the corresponding loss function, and the model is trained using a dynamic subset dataset. During the training process, an adapted optimizer and learning rate update method are used, and relevant performance indicators are evaluated on the target scene validation set at regular training epochs, thereby completing the construction of the vehicle re-identification model.
[0029] Furthermore, the method provided in this application embodiment includes:
[0030] YOLO11-L is used as the detection model to perform bounding box detection and confidence filtering on each frame of the multiple sets of numbered videos, resulting in multiple sets of video image bounding boxes. The ByteTrack algorithm is then used to perform cross-frame association on these sets of video image bounding boxes. Kalman filtering is used to predict the target motion state, and multiple score thresholds are set for matching and tracking, outputting multiple sets of continuous video target trajectories. A single trajectory is... , This refers to the information of the m-th detection box for the i-th trajectory, i.e., the i-th vehicle. The detection box contains coordinate information and a score, representing the trajectory length. , The coordinates of the center point, The width and height of the frame.
[0031] Specifically, the acquired sets of numbered videos are split frame by frame, and the images are input into the YOLO11-L detection model frame by frame. The model performs target recognition on each frame, identifying and filtering out three types of targets: cars, trucks, and buses. At the same time, it judges the confidence level of each target output by the YOLO11-L detection model, retaining only the target boxes that meet the confidence requirements, thus obtaining the set of image target boxes corresponding to each set of videos.
[0032] Next, a cross-frame association algorithm is used to process the image target bounding boxes of each video group. First, the motion state of the target is predicted using the Kalman filter method, that is, based on the target's position information in the previous frame, the expected position and motion trend of the target in the current frame are calculated. Then, multiple score thresholds are set, and the target bounding boxes detected in the current frame are matched with the predicted target states. The score thresholds are used to determine whether the target bounding box and the predicted state correspond to the same target, thereby completing cross-frame target association tracking.
[0033] Subsequently, the trajectories of the associated targets are organized to form a single trajectory representation. .in, This represents the i-th trajectory, corresponding to the i-th vehicle; This represents the information of the m-th detection box in the i-th trajectory. This is the length of the trajectory. Each detection box contains the following information: , It is the x-coordinate of the center point of the detection box. It is the ordinate of the center point of the detection box. It is the width of the detection frame. It is the height of the detection frame. It is the confidence score corresponding to the detection box.
[0034] By employing a detection model to filter target boxes, combining Kalman filtering with a scoring threshold to perform cross-frame correlation and organize trajectories, the effect of obtaining a continuous and complete set of vehicle trajectories in each video group was achieved.
[0035] Furthermore, such as Figure 2 As shown, the method provided in this application embodiment includes:
[0036] Adaptive sampling is performed on each vehicle trajectory in the set of multiple sets of continuous video target trajectories to construct a video sampling set; a dataset directory is established, which contains three levels of directories, where the first level folder is the video name, the second level folder is the vehicle ID name, and the third level directory is the vehicle frame ID name; the video sampling set is saved according to the dataset directory to generate an initial video dataset; image filtering rules are constructed, and the initial video dataset is filtered using the image filtering rules to obtain a usable video dataset; the usable video dataset is partitioned to obtain a private video training set.
[0037] Optionally, an initial frame is first collected for each vehicle trajectory and stored in the sampling set. For subsequent frames, the most recently sampled frame is found, and the center offset of the detection boxes of the two frames and the dynamic judgment threshold are calculated. Whether to sample is determined based on whether the offset meets the threshold or whether the number of unsampled frames reaches the set condition. Finally, a video sampling set is formed. This step will be explained in detail in the following content.
[0038] Next, based on the video names obtained from the aforementioned video grouping steps, a first-level folder is created using these names as identifiers to clearly distinguish the file resources corresponding to different videos. Within each first-level folder, a corresponding second-level folder is created for each vehicle ID based on the vehicle ID determined in the target tracking phase. By matching vehicle IDs with folder names, independent categorization of different vehicle files within the same video is achieved. Subsequently, for each second-level folder, combining the vehicle frames obtained from the adaptive sampling phase, the standard file naming rules are adopted, using the frame ID corresponding to each frame as the image file name. Simultaneously, these sampled image files are directly saved within the second-level folder corresponding to the vehicle ID. At this point, the image files corresponding to the frame ID names constitute a three-level directory hierarchy, completing the construction of a three-level directory structure from video to vehicle to single-frame image, achieving a precise correspondence between each sampled image and the three-level directory.
[0039] Then, based on the established dataset directory, each image in the video sampling set is first matched to the first-level folder containing the corresponding video name, then to the second-level folder containing the corresponding vehicle ID, and finally saved to the second-level folder named after the image's frame ID. After all sampled images are stored in this hierarchical manner, a well-structured and clearly hierarchical initial video dataset is formed.
[0040] Then, image filtering rules are constructed, with the following specific steps:
[0041] Step a: For each frame of the initial video dataset, identify the vehicle area and the visible area of the whole vehicle from the current viewpoint, and count the percentage of the area where the vehicle is truncated or occluded. If the percentage exceeds 50% of the visible area of the whole vehicle from the current viewpoint, remove the vehicle immediately.
[0042] Step b: Continue to use the image pixel ratio statistics method to calculate the pixel ratio of the vehicle area in each frame of the image. If it is less than 50%, the vehicle in the frame is determined to be a background element and the frame is removed from the dataset.
[0043] Step c: For each vehicle ID, use a file counting method to count the number of images corresponding to different vehicles in the folder, keep only the images corresponding to the vehicle with the most frames, and delete the images of the other vehicles from the folder.
[0044] Step d: Using the conventional method of counting the number of files in a folder, count the number of remaining images in each vehicle ID folder. If the number does not reach the set value of 4 images, remove the entire folder from the dataset.
[0045] Step e: Use the target category recognition and verification method to check the vehicle type corresponding to each vehicle ID folder. If the recognition result is a non-target type such as a motorcycle or tricycle, then remove the corresponding entire folder from the dataset.
[0046] Step f: Under the directory level corresponding to the video group, use the image feature comparison method to perform feature matching on the images in different vehicle ID folders. If they are determined to be the same vehicle, merge these images, keep only the folder corresponding to one vehicle ID, and remove the rest of the folders.
[0047] Step g: Use the directory validity check method to count the number of remaining valid vehicle ID folders in each video group directory. If the number is zero, remove the entire video group directory from the dataset.
[0048] The initial video dataset is filtered according to the image filtering rules constructed above, and finally a usable video dataset is obtained.
[0049] Finally, the available video dataset is divided to clarify the composition and division rules of datasets for different purposes, and to determine the acquisition methods of each part of the dataset, thereby obtaining a private video training set adapted for model training. At the same time, the corresponding dataset parts used for model validation and performance testing are distinguished. This step will be explained in detail in the following content.
[0050] Furthermore, the method provided in this application embodiment includes:
[0051] The first frame is sampled for each vehicle trajectory in the set of multiple sets of continuous video target trajectories. And exist in the sample set For the next frame In the sampling set Find the most recently sampled frame And calculate the center offset of the detection box in the next frame and the most recently sampled frame. ; Calculate dynamic motion pixel threshold ,in, This is the motion coefficient, typically taken as 0.1; if Sample immediately and save in the sample set. In the middle, if When the number of unsampled frames exceeds We also sample at certain times, but do not sample at other times, thus constructing a video sampling set.
[0052] Specifically, for each continuous vehicle trajectory, the first frame corresponding to the trajectory is selected first. Save the vehicle status information corresponding to the frame to the corresponding sampling set. In this process, the initial frame of the trajectory is extracted directly to preserve the initial state during data sampling.
[0053] Then, for the next frame in the trajectory In the constructed sampling set Retrieve and determine the frame corresponding to the most recent sample. The Euclidean distance calculation method is used to obtain the center offset of the detection box between the current frame and the most recently sampled frame. The corresponding calculation formula is: ,in Represents the x-coordinate of the center of the detection box in the current frame. This represents the x-coordinate of the center of the detection box in the most recently sampled frame. This represents the center y-coordinate of the detection box in the current frame. This represents the center coordinate of the detection box in the most recently sampled frame.
[0054] The dynamic motion pixel threshold is then calculated using a weighted calculation method that incorporates the detection box size. The corresponding formula is: Where α is the motion coefficient, This represents the width of the detection box in the most recently sampled frame. This represents the height of the detection box in the most recently sampled frame. This represents the width of the detection box in the current frame. This represents the height of the detection box in the current frame.
[0055] Then, the calculated center offset is compared with the dynamic motion pixel threshold. If the center offset is greater than or equal to the threshold, that is... If the center offset is less than the threshold, then the current frame is sampled and saved to the sample set; if the center offset is less than the threshold, then... Then, count the number of unsampled frames from the most recent sampling to the current frame. When the number of unsampled frames exceeds one-tenth of the total trajectory length, that is, when it exceeds... In the first case, the current frame is sampled and saved; in the other cases, no sampling is performed. After sampling all frames that meet the conditions, an image cropping method is used to extract the detection box corresponding to each sample from the original video image to obtain the corresponding image segment, which is used to generate the initial dataset.
[0056] By sequentially sampling the vehicle trajectory in the first frame, calculating the center offset and dynamic threshold, performing conditional sampling judgment, and cropping the image, the effect of constructing a video sampling set containing key vehicle state information was achieved.
[0057] Furthermore, the method provided in this application embodiment includes:
[0058] The available video dataset is , This represents all the data generated from a video, where N represents the number of videos. , This represents all data for the i-th video with the j-th ID. This represents the total number of IDs in the i-th video, where , This represents the k-th image with the j-th ID in the i-th video. This represents the total number of images with the j-th ID in the i-th video, where the total number of IDs is 1. The total number of images is According to the total number of IDs For the available video dataset The data is divided to obtain the validation set. The number of IDs in the validation set is ,in, The proportion of the validation set; the available video dataset Randomly rearrange the video titles to get , in turn In Store the validation set Count the number of IDs in the current validation set until it exceeds [a certain threshold]. Similarly, the test set is obtained by partitioning the dataset. According to the verification set and the test set The remaining portion is used as a private video training set. .
[0059] Specifically, we first define the structure and representation of the available video dataset, denoted as D. Each element All data generated for a single video, where N is the total number of videos; each Contains multiple , All data corresponding to the j-th ID in the i-th video. This is the total number of IDs for the video; each It also includes multiple , It is the k-th image corresponding to the ID. This represents the total number of images with that ID. The total number of IDs is obtained by summing the results. For all videos The sum of Total number of images For each ID in all videos The sum of Complete the summary of the dataset statistics.
[0060] The validation set was then divided using a proportional allocation method. First, determine the number of IDs in the validation set. The calculation method is the total number of IDs. Multiply by the proportion of the validation set ,Right now Next, a random shuffle algorithm is used to randomly rearrange the available video dataset D according to the video name, resulting in the rearranged dataset. This is a preprocessing operation used to avoid regular deviations in data distribution before data set partitioning.
[0061] Then, sequentially process the data in the rearranged dataset D' Store the validation set Simultaneously, a real-time statistical method is used to record the current number of IDs in the validation set until that number exceeds [a certain threshold]. When the data storage stops, the validation set partitioning is complete. Then, the same algorithm steps are repeated to rearrange the data, batch store the data, and count the number of IDs to obtain the test set. .
[0062] Finally, from the available video dataset D, remove the already partitioned validation set. and test set The remaining portion was directly designated as the private video training set. This serves as the remaining allocation in the dataset partitioning.
[0063] By statistically analyzing the IDs and total number of images in the data set, dividing the validation and test sets proportionally and randomly, and retaining the remaining portion as the training set, a private video training set suitable for model training was obtained.
[0064] Furthermore, the method provided in this application embodiment includes:
[0065] Perform a structure mapping on the public dataset according to the dataset catalog, and randomly select from the structure-mapped public dataset. Get a public dataset from a given ID. Where n is the number of publicly available datasets used; the private video training set and the publicly available dataset The datasets were merged to obtain the video merged training set. .
[0066] Specifically, we first collect commonly used public datasets in the field of vehicle re-identification, including but not limited to public datasets such as VehicleID, VeRi-776, VERI-Wild, CityFlow, and CompCars. These public resources can supplement the training of this model with diverse vehicle samples and expand the data sources in the model training.
[0067] Subsequently, the structure of each public dataset was adapted according to the three-level directory specification of the dataset directory. A first-level directory was created by adding a uniform prefix to the dataset name to distinguish public data from different sources; under each first-level directory, a second-level directory was created according to the vehicle identity ID in the original dataset, retaining the original ID number to ensure data traceability; each second-level directory contained the corresponding vehicle's sub-graph, completing the alignment of the public dataset with the target storage structure, thereby unifying the storage format.
[0068] Next, vehicle IDs were selected from each public dataset using random sampling, with a selection quantity of [number missing]. One, of which is the total number of IDs of the available video datasets in the preceding steps, and n is the number of public datasets used in this operation. This sampling method controls the size of the IDs for each public dataset, preventing an imbalance in the distribution of training data due to an excessive amount of public data.
[0069] Finally, using common methods for merging datasets, the private video training set was merged. Compared with the public dataset after structure mapping and sampling By integrating the data, a new training set is obtained. .
[0070] By collecting public datasets, standardizing their directory structure, sampling and controlling the size of public data, and merging them with private training sets, the goal of obtaining a video merged training set with appropriate size and standardized structure was achieved.
[0071] Furthermore, the method provided in this application embodiment includes:
[0072] Merge the videos into the training set Based on data source, it is divided into public datasets. and private datasets Initialize the probability of each group being sampled. Randomly sample a group according to probability. Constructing dynamic subsets Specifically: if Equal probability from the private dataset A new group was sampled from the middle. , constitute a subset of datasets If the sampling group , .
[0073] In one embodiment, the videos are first merged into the training set. The datasets are divided according to their source to obtain public datasets. With private datasets The dataset consists of two parts, with the public dataset denoted as G. p The dataset contains multiple groups; the private dataset is denoted as Gᵥ, which also contains multiple groups. Distinguishing samples according to their source facilitates subsequent sampling for data from different sources.
[0074] Next, the sampling probability of each group is initialized using a probability-weighted method, and the corresponding calculation formula is: ,in This represents the number of IDs contained in the i-th group. This represents the sum of the number of IDs in all groups. This represents the probability of the i-th group being sampled. The method described above, allocating sampling probabilities based on the sample size within each group, is used to balance the participation of groups of different sizes in weighted sampling. Subsequently, a weighted random sampling method is used, based on the calculated probabilities... Randomly select one group from all groups. It is used in random sampling to respect the sample distribution weights, allowing groups with larger sample sizes to have a higher sampling opportunity.
[0075] If the selected group Belongs to public dataset ,Right now Then, an equal-probability random sampling method is used to sample from the private dataset. Select a new group Then Add to public dataset In this way, a dynamic subset of data is constructed. This is used to balance the sampling ratio of public and private data.
[0076] If the selected group Belongs to private dataset Then directly Add to public dataset In, it constitutes a dynamic subset of data. To ensure that private data is effectively incorporated into dynamic subsets Under construction.
[0077] By dividing the data sources, initializing the sampling probability, weighted random sampling, and combining the source supplementary groups, the effect of constructing a dynamic subset that takes into account both public and private data distributions is achieved.
[0078] Furthermore, the method provided in this application embodiment includes:
[0079] Used in Internal sampling ID, in Medium sampling remaining For each ID, P images are sampled. If there are fewer than P images, the sampling is repeated. Here, N represents the number of different IDs, and P represents the number of randomly sampled images for each ID. Generally, P is set to 4, and N is adjusted according to the actual situation.
[0080] Optionally, during the training process of the vehicle re-identification model, the training batch size is first determined according to the conventional batch setting method for model training. Where N represents the number of different vehicle IDs and P represents the number of images that need to be randomly sampled for each ID, it is used to control the scale of each batch of input data during model training and can be adapted to the training resources and convergence requirements of the model.
[0081] Next, for the constructed dynamic subset dataset IDs are selected using a stratified sampling method. First, the IDs are selected from the previously randomly sampled groups. Within the subset, select N / 2 IDs, and then in the subset... Remove Within the selected portion, the remaining N / 2 IDs are chosen. By allocating the sampling quantity by region in this way, the ID coverage of the samples can be made more uniform.
[0082] After selecting the IDs, a fixed-quantity sampling method is used to sample P images for each selected ID. If the number of images corresponding to a certain ID is less than P, a resampling method is used to supplement the images to meet the sampling quantity requirement for each ID. This ensures that the sample structure of each batch of training data is consistent. In the above steps, P is generally set to 4, and N can be adjusted by those skilled in the art according to the actual situation.
[0083] By setting the training batch size, stratified sampling ID, a fixed number of sampled images, and supplementing insufficient samples, the effect of obtaining sample data that is evenly distributed and meets the requirements of the training batch was achieved.
[0084] Furthermore, the method provided in this application embodiment includes:
[0085] ResNet50-IBN was used as the backbone network, combined with CELows and AdaSPLoss loss functions. The model was trained on the dynamic subset dataset for 120 epochs. The learning rate was updated using the Adam optimizer and cosine annealing algorithm. Validation was performed on the target scene set every 10 epochs. The mAP and Rank-1 were evaluated to construct a vehicle re-identification model.
[0086] Optionally, ResNet50-IBN, commonly used in the field of vehicle re-identification, is adopted as the backbone network of the model. This network incorporates an instance normalization module on the basis of ResNet50, which can extract more robust vehicle visual features. It is the mainstream backbone structure for improving feature discrimination ability. This is used to build the feature extraction framework of the model and determine the basic structure of the model.
[0087] Next, combining the strategy of multi-loss function collaborative training, CELows and AdaSPLoss are used as the model's loss function. CELows is used to complete the vehicle ID classification task, helping the model learn the category differences between different vehicles; AdaSPLoss adapts to the feature matching requirements of vehicle re-identification, enhancing the discriminative power of features. The combination of the two can simultaneously ensure classification accuracy and feature discrimination, thus constructing the model's loss calculation module.
[0088] Subsequently, the vehicle images from the dynamic subset constructed in the preceding steps are used as model input. Images are fed into the pre-built network according to a set batch size, initiating the model training process. During training, the total number of training epochs is set to 120 epochs. This epoch setting aligns with the typical convergence period of vehicle re-identification models and is a common choice for balancing training efficiency and model performance.
[0089] During training, the Adam optimizer is used to update model parameters with a batch size of 128 and an initial learning rate of 0.00035. This optimizer can adaptively adjust the parameter update step size, improving training stability. Simultaneously, a cosine annealing algorithm is used to dynamically adjust the learning rate. The periodic fluctuations in the learning rate help the model escape local optima, further optimizing training performance. This combination of optimization strategies is a common method to improve model convergence quality. During training, at fixed intervals, the target scene validation set is processed every 10 epochs. The model takes vehicle images as input and outputs corresponding feature representations and classification results. Then, it calculates mAP and Rank-1 metrics. These two metrics are the core evaluation criteria for vehicle re-identification tasks. By regularly evaluating them, the model's performance changes in the target scene can be monitored in real time, and the training status can be adjusted in a timely manner.
[0090] After all training rounds are completed, the final model achieves a Rank-1 score of 97% on the test set. The resulting vehicle re-identification model takes the image of the vehicle to be identified as its input and outputs the feature vector corresponding to that vehicle. This vector can be used to match the vehicle features in the database to achieve the vehicle re-identification function.
[0091] By building an adapted backbone network, combining loss functions, training with dynamic subset datasets, and periodically evaluating key metrics, a model capable of efficiently completing vehicle re-identification tasks in the target scenario was successfully constructed.
[0092] In summary, the method for creating a vehicle re-identification dataset and training a model based on video grouping provided in this application has the following technical effects:
[0093] This application obtains video names through video grouping, acquires vehicle frames through adaptive sampling, and saves the initial dataset in a three-level directory structure of video-vehicle ID-frame ID. A private training set is then obtained through multiple rounds of filtering and partitioning. After merging the public dataset, a dynamic subset is constructed. The model is trained using a ResNet50-IBN backbone network combined with a dual loss function, and the model is periodically evaluated and adjusted. This achieves accurate vehicle feature extraction and matching, making vehicle re-identification results more reliable. The application achieves the technical effect of efficiently constructing high-quality adaptive data and improving the recognition accuracy and generalization ability of the vehicle re-identification model in practical application scenarios.
[0094] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0095] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of this application and its equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for creating a vehicle re-identification dataset and training a model based on video grouping, characterized in that, The method includes: Multiple high-resolution surveillance cameras were used to continuously capture images under various lighting conditions in real-world application scenarios and group them to obtain multiple sets of numbered videos. YOLO11-L is used as the detection model to perform target detection and tracking on the multiple sets of numbered videos, and outputs multiple sets of continuous trajectories of video targets. For each vehicle trajectory in the set of multiple sets of continuous video target trajectories, adaptive sampling, dataset generation, manual screening, and dataset partitioning are performed to obtain a private video training set. Collect a public dataset, and merge the public dataset and the private video training set to obtain a merged video training set; Random sampling is performed on the video merged training set to construct a dynamic sub-dataset. ResNet50-IBN is used as the backbone network to train the model on the dynamic sub-dataset and construct a vehicle re-identification model.
2. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 1, characterized in that, Output multiple sets of continuous video target trajectories, including: YOLO11-L was used as the detection model to perform bounding box detection and confidence filtering on each frame of the multiple sets of numbered video images, resulting in multiple sets of video image bounding boxes. The ByteTrack algorithm is used to perform cross-frame association on the multiple sets of video image target bounding boxes. Kalman filtering is used to predict the target motion state, and multiple score thresholds are set for matching and tracking. This outputs multiple sets of continuous video target trajectories, where a single trajectory is... , This refers to the information of the m-th detection box for the i-th trajectory, i.e., the i-th vehicle. The detection box contains coordinate information and a score, representing the trajectory length. , The coordinates of the center point, The width and height of the frame.
3. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 2, characterized in that, We obtained a private video training set, including: Adaptive sampling is performed on each vehicle trajectory in the multiple sets of continuous video target trajectories to construct a video sampling set; Establish a dataset directory containing three levels of directories. The first level of the three-level directory contains the video name, the second level contains the vehicle ID name, and the third level contains the vehicle frame ID name. The video sampling set is saved according to the dataset directory to generate an initial video dataset; Construct image filtering rules, and use the image filtering rules to filter the initial video dataset to obtain a usable video dataset; The available video dataset is partitioned to obtain a private video training set.
4. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 3, characterized in that, Construct a video sampling set, including: The first frame is sampled for each vehicle trajectory in the set of multiple sets of continuous video target trajectories. And exist in the sample set ; For the next frame In the sampling set Find the most recently sampled frame And calculate the center offset of the detection box in the next frame and the most recently sampled frame. ; Calculate dynamic motion pixel threshold ,in, This is the motion coefficient, typically taken as 0.1; if Sample immediately and save in the sample set. In the middle, if When the number of unsampled frames exceeds We also sample at certain times, but do not sample at other times, thus constructing a video sampling set.
5. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 3, characterized in that, The available video dataset is partitioned to obtain a private video training set, including: The available video dataset is , This represents all the data generated from a video, where N represents the number of videos. , This represents all data for the i-th video with the j-th ID. This represents the total number of IDs in the i-th video, where , This represents the k-th image with the j-th ID in the i-th video. This represents the total number of images with the j-th ID in the i-th video, where the total number of IDs is 1. The total number of images is ; According to the total number of IDs For the available video dataset The data is divided to obtain the validation set. The number of IDs in the validation set is ,in, The proportion of the validation set; The available video dataset Randomly rearrange the video titles to get , in turn In Store the validation set Count the number of IDs in the current validation set until it exceeds [a certain threshold]. Similarly, the test set is obtained by partitioning the dataset. ; According to the verification set and the test set The remaining portion is used as a private video training set. .
6. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 5, characterized in that, The video merged training set is obtained, including: Perform a structure mapping on the public dataset according to the dataset catalog, and randomly select from the structure-mapped public dataset. Get a public dataset from a given ID. , where n is the number of publicly available datasets used; The private video training set and the public dataset The datasets were merged to obtain the video merged training set. .
7. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 6, characterized in that, Constructing dynamic subsets of data, including: Merge the videos into the training set Based on data source, it is divided into public datasets. and private datasets ; Initialize the probability of each group being sampled. Randomly sample a group according to probability. Constructing dynamic subsets Specifically: if Equal probability from the private dataset A new group was sampled from the middle. , constitute a subset of datasets If the sampling group , .
8. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 7, characterized in that, The method further includes: Used in Internal sampling ID, in Medium sampling remaining For each ID, P images are sampled. If there are fewer than P images, the sampling is repeated. Here, N represents the number of different IDs, and P represents the number of images randomly sampled for each ID. Generally, P is set to 4, and N is adjusted according to the actual situation.
9. The method for creating a vehicle re-identification dataset and training a model based on video grouping as described in claim 8, characterized in that, Constructing a vehicle re-identification model includes: ResNet50-IBN was used as the backbone network, combined with CELows and AdaSPLoss loss functions. The model was trained on the dynamic subset dataset for 120 epochs. The learning rate was updated using the Adam optimizer and cosine annealing algorithm. Validation was performed on the target scene set every 10 epochs. The mAP and Rank-1 were evaluated to construct a vehicle re-identification model.