Vehicle re-identification method and device

The feature vector of the vehicle image is extracted through the convolutional neural network to determine whether the vehicle in the video stream is the same vehicle. This solves the problem of trajectory interruption caused by vehicle occlusion or missed detection in the smart parking system, and achieves continuity and accuracy of vehicle tracking. sex.

CN113052008BActive Publication Date: 2024-10-25SHENZHEN JIESHUN SCI & TECH IND
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110228249.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-01
Publication Date
2024-10-25
Estimated Expiration
2041-03-01

AI Technical Summary

Technical Problem

When the existing smart parking system is tracking a vehicle, it cannot perform data correlation when it is blocked or missed by the detection algorithm, causing the vehicle trajectory to be interrupted and affecting the judgment of subsequent events.

Method used

A convolutional neural network is used to extract fine-grained feature vectors of vehicle images, and the feature vector differences are used to determine whether they are the same vehicle, maintaining the continuity of vehicle tracking trajectories.

Benefits of technology

Effectively identify the same vehicle in different video streams, ensure the continuity of vehicle tracking trajectories, and improve the system's accuracy in identifying vehicles entering and exiting parking spaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113052008B_ABST
    Figure CN113052008B_ABST
Patent Text Reader

Abstract

The present application discloses a vehicle re-identification method and device, wherein the method comprises: obtaining a first target vehicle image from a first video stream; inputting the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image; obtaining a second target vehicle image from a second video stream; inputting the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle; determining whether the difference between the second feature vector and the first feature vector is within a preset interval, wherein the smaller the difference, the higher the similarity between the first target vehicle and the second target vehicle; and if so, determining that the second target vehicle and the first target vehicle are the same vehicle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a vehicle re-identification method and device. Background Art

[0002] With the improvement of people's living standards, cars have increasingly entered people's lives.

[0003] In the existing smart parking system, video surveillance cameras are mainly used to monitor vehicles. Through artificial intelligence algorithms, vehicle status, parking space conditions and license plate information can be accurately identified, parking spaces can be efficiently managed, and real-time updating, query, reservation and navigation services of parking space resources can be realized, thereby improving the efficiency of parking space utilization.

[0004] When tracking a vehicle in real time, it is necessary to obtain the vehicle's position relationship in real time and associate the video frames through the IOU matching algorithm to achieve vehicle tracking. However, when the vehicle is blocked or the detection algorithm misses a detection, the IOU matching algorithm will not be able to associate the data, resulting in an interruption in the vehicle's trajectory. This will affect the vehicle's subsequent event judgment and make the system unable to determine whether the vehicle enters or exits the parking space. Summary of the invention

[0005] The present application provides a vehicle re-identification method and device, which can identify the same vehicle in different video streams and maintain the continuity of the vehicle tracking trajectory.

[0006] The first aspect of the present application provides a vehicle re-identification method, comprising:

[0007] Acquire a first target vehicle image from a first video stream;

[0008] Inputting the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image;

[0009] Acquire a second target vehicle image from a second video stream;

[0010] Inputting the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle;

[0011] Determine whether the difference between the second feature vector and the first feature vector is within a preset interval, the smaller the difference is, the higher the similarity between the first target vehicle and the second target vehicle is;

[0012] If so, it is determined that the second target vehicle and the first target vehicle are the same vehicle.

[0013] Optionally, the convolutional neural network includes a first convolutional layer, a pooling layer, a fully connected layer, a softmax layer and four residual blocks, and the residual block includes two second convolutional layers having the same number of output channels as the first convolutional layer.

[0014] Optionally, inputting the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle includes:

[0015] Input the first target vehicle image into a preset model to extract a first feature map of the first target vehicle image, where the size of the first feature map is H×W×C, where H is the height of the first feature map, W is the width of the first feature map, and C is the number of channels of the first feature map;

[0016] Divide the first feature map into P blocks in the dimension of H to obtain a first block feature map, where P is a first preset value;

[0017] The P first block feature maps are sequentially connected to the average pooling layer and the 1×1 convolution layer in the preset model to obtain P second block feature maps with reduced dimensions;

[0018] Input the P second block feature maps into the fully connected layer and the softmax layer in the preset model to obtain P block results;

[0019] The P block results are concatenated to obtain the first feature vector.

[0020] Optionally, before acquiring the first target video, the method further includes:

[0021] The original model is trained to obtain a preset model so that the total loss value of the preset model reaches a threshold value.

[0022] Optionally, the training of the original model to obtain a preset model so that the total loss value of the preset model reaches a threshold value includes:

[0023] Set the initial learning rate;

[0024] Obtaining a secondary sample data group from the primary sample data set, and marking the number of times the secondary sample data group is obtained, wherein the secondary sample data group is an untrained secondary sample data group, and the primary sample data set includes several groups of secondary sample data groups, and the secondary sample data group includes several pictures of the same vehicle ID;

[0025] Obtaining a first image from the secondary sample data group and inputting it into the original model to obtain a third feature vector of the first image, and marking the number of times the image is input, wherein the first image is an untrained vehicle picture;

[0026] Calculating a first total loss value of the original model by a total loss function and back-propagating and updating the original model according to the first total loss value to obtain a secondary model;

[0027] Determining whether all images in the secondary sample data group have been traversed;

[0028] If not, input the second image into the secondary model and mark the number of times the image is input, to obtain a fourth feature vector of the second image, and the vehicle in the second image is consistent with the vehicle in the first image;

[0029] Calculate a second total loss value of the updated original model by a total loss function and update the secondary model by back-propagation according to the second total loss value;

[0030] Determining whether the second total loss value is less than the first total loss value;

[0031] If not, determining whether the second total loss value is less than or equal to a threshold;

[0032] If so, it is determined that the updated secondary model is the default model.

[0033] Optionally, the determining whether the second total loss value is less than or equal to the threshold value, the method further includes:

[0034] If so, update the learning rate.

[0035] Optionally, the total loss function is the sum of a first loss function multiplied by a first weight and a second loss function multiplied by a second weight, the first loss function is a sphere loss function, the second loss function is a triplet loss function, and the first weight and the second weight are respectively a second preset value and a third preset value.

[0036] Optionally, acquiring a first target vehicle image from a first target video includes:

[0037] Detecting a first target vehicle in the first video stream using a preset target detection algorithm;

[0038] An image of the first target vehicle is generated.

[0039] A second aspect of an embodiment of the present application provides a vehicle re-identification device, including:

[0040] A first acquisition unit, used to acquire a first target vehicle image from a first video stream;

[0041] A first input unit is used to input the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image;

[0042] A second acquisition unit, used for acquiring a second target vehicle image from a second video stream;

[0043] A second input unit, used for inputting the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle;

[0044] A first judging unit, configured to judge whether a difference between the second feature vector and the first feature vector is within a preset interval, wherein a smaller difference indicates a higher similarity between the first target vehicle and the second target vehicle;

[0045] A determination unit is used to determine that the second target vehicle and the first target vehicle are the same vehicle when the first judgment unit determines that the second feature vector and the first feature vector are within a preset interval.

[0046] Optionally, the first input unit includes:

[0047] A first extraction module is used to input the first target vehicle image into a preset model to extract a first feature map of the first target vehicle image, where the size of the first feature map is H×W×C, where H is the height of the first feature map, W is the width of the first feature map, and C is the number of channels of the first feature map;

[0048] A first cutting module, used for dividing the first feature map into P blocks in a dimension of H to obtain a first block feature map, where P is a first preset value;

[0049] A first access module is used to sequentially access the P first block feature maps to the average pooling layer and the 1×1 convolution layer in the preset model to obtain P second block feature maps with reduced dimensions;

[0050] A second access module is used to input the P second block feature maps into the fully connected layer and the softmax layer in the preset model to obtain P block results;

[0051] A splicing module is used to splice the P block results to obtain the first feature vector.

[0052] Optionally, the device further comprises:

[0053] The training unit is used to train the original model to obtain a preset model so that the total loss value of the preset model reaches a threshold value.

[0054] Optionally, the training unit includes:

[0055] Initialization module, used to set the initial learning rate;

[0056] A first acquisition module is used to acquire a secondary sample data group from the primary sample data set, and mark the number of times the secondary sample data group is acquired, wherein the secondary sample data group is an untrained secondary sample data group, and the primary sample data set includes several groups of secondary sample data groups, and the secondary sample data group includes several pictures of the same vehicle ID;

[0057] A first execution module is used to obtain a first image from the secondary sample data group and input the first image into the original model to obtain a third feature vector of the first image, and mark the number of times the image is input, wherein the first image is an untrained vehicle picture;

[0058] A first calculation module, used for calculating a first total loss value of the original model through a total loss function and updating the original model by back-propagation according to the first total loss value to obtain a secondary model;

[0059] A first judgment module, used to judge whether all images in the secondary sample data group have been traversed;

[0060] a second execution module, configured to input the second image into the secondary model and mark the number of times the image is input, to obtain a fourth feature vector of the second image, when the first judgment module determines that the images in the second sample data group have not been traversed completely, and the vehicle in the second image is consistent with the vehicle in the first image;

[0061] A second calculation module, used for calculating a second total loss value of the updated original model through a total loss function and updating the secondary model by back-propagation according to the second total loss value;

[0062] A second judging module, configured to judge whether the second total loss value is less than the first total loss value;

[0063] A third judgment module, used for judging whether the second total loss value is less than or equal to a threshold value when the result of the second judgment module is no;

[0064] A determination module is used to determine that the updated secondary model is a preset model when the third judgment module determines that the second total loss value is less than or equal to a threshold value.

[0065] Optionally, the training unit further includes:

[0066] An updating module is used to update the learning rate when the third judgment module determines that the second total loss value is less than or equal to a threshold.

[0067] Optionally, the first acquiring unit includes:

[0068] An identification and detection module, configured to detect a first target vehicle in the first video stream using a preset target detection algorithm;

[0069] A generating module is used to generate an image of the first target vehicle.

[0070] A third aspect of the present application provides a vehicle re-identification device, comprising:

[0071] Processor, memory, input and output unit, bus;

[0072] The processor is connected to the memory, the input and output unit, and the bus;

[0073] The processor specifically performs the following operations:

[0074] Acquire a first target vehicle image from a first video stream;

[0075] Inputting the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image;

[0076] Acquire a second target vehicle image from a second video stream;

[0077] Inputting the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle;

[0078] Determine whether the difference between the second feature vector and the first feature vector is within a preset interval, the smaller the difference is, the higher the similarity between the first target vehicle and the second target vehicle is;

[0079] If so, it is determined that the second target vehicle and the first target vehicle are the same vehicle.

[0080] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the method for tracking the business link described above is performed.

[0081] It can be seen from the above technical scheme that the present application inputs the first target vehicle image extracted from the first video stream into the preset model to obtain the first feature vector of the first target vehicle. When tracking the vehicle, the second target vehicle image extracted from the second video stream is input into the preset model to obtain the second feature vector of the second target vehicle. Since the feature vector involves the fine granularity of the vehicle, the features of the vehicle can be accurately found. If the difference between the two feature vectors is within the preset interval, it is determined that the second target vehicle is the same vehicle as the first target vehicle, thereby maintaining the continuity of tracking the vehicle. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] Figure 1 A schematic diagram of an embodiment of a vehicle re-identification method in this application;

[0083] Figure 2-1 and Figure 2-2 This is a flow chart of another embodiment of the vehicle re-identification method in the present application;

[0084] Figure 3 A schematic diagram of an embodiment of a flow chart of training an original model in a vehicle re-identification method in this application;

[0085] Figure 4-1 and Figure 4-2 This is a schematic diagram of the structure of an embodiment of a vehicle re-identification device in this application;

[0086] Figure 5 FIG. 4 is a schematic diagram of the structure of another embodiment of the vehicle re-identification device in the present application. DETAILED DESCRIPTION

[0087] The embodiment of the present application provides a vehicle re-identification method, which can identify the same vehicle in different video streams and maintain the continuity of the vehicle tracking trajectory.

[0088] The following will provide a clear and complete description of the technical solutions in the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are merely preferred examples of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application should be included in the scope of protection of the present application.

[0089] The method of the present application can be applied to a server, a terminal or other devices with logical processing capabilities, without specific limitation. For the convenience of description, the following description is based on the terminal as the execution subject.

[0090] See also Figure 1 , an embodiment of the vehicle re-identification method in the present application includes:

[0091] 101. The terminal obtains a first target vehicle image from a first video stream;

[0092] In some cases, a vehicle needs to be tracked. In an embodiment of the present application, the terminal needs to first determine the image of the first target vehicle. The first target vehicle image can be obtained from a video stream. The image only contains a complete vehicle image. Of course, the first target vehicle image can also be provided by other devices, which is not limited here.

[0093] 102. The terminal inputs the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image;

[0094] In the embodiment of the present application, the preset model is already stable and can process the input image and output the feature vector of the image, that is, the fine-grained features of the image. Because different vehicles have unique characteristics, the terminal inputs the first target vehicle image into the preset model to obtain the first feature vector.

[0095] 103. The terminal obtains a second target vehicle image from the second video stream;

[0096] When the first target vehicle being tracked disappears from the current video or the current video is interrupted, in order to continue tracking the first target vehicle, the terminal obtains the second target vehicle image from the second video stream. The second target vehicle image contains at least a complete vehicle image, and it is not certain whether the second target vehicle is the first target vehicle. It should be noted that in the present application, the second video stream and the first video stream can come from the same continuous video data or from different video data, which is not limited here.

[0097] 104. The terminal inputs the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle;

[0098] After completing step 103, the terminal inputs the second target vehicle image into the stable preset model to extract the second feature vector of the second target vehicle image.

[0099] 105. The terminal determines whether the difference between the second feature vector and the first feature vector is within a preset interval. The smaller the difference, the higher the similarity between the first target vehicle and the second target vehicle. If so, execute step 106.

[0100] Since different vehicles have different characteristics, based on this embodiment of the present application, the first feature vector is compared with the second feature vector to determine whether the difference between the two feature vectors is within a preset interval. Even for the same vehicle, the feature vectors extracted from photos of different brightness or angles may not be completely equal. Therefore, a difference interval is set to distinguish whether the second target vehicle is the same vehicle as the first target vehicle.

[0101] 106. The terminal determines that the second target vehicle and the first target vehicle are the same vehicle.

[0102] If the difference between the two feature vectors is within this interval, the terminal determines that the second target vehicle is the first target vehicle to be tracked.

[0103] In an embodiment of the present application, the terminal can extract the image of the first target vehicle (the vehicle to be tracked) from the video data, and obtain the first feature vector of the first target vehicle image through a preset model. The terminal then extracts the second target vehicle image from the video data containing the second target vehicle (the suspicious vehicle), and obtains the second feature vector of the second target vehicle image through a preset model. If the difference between the two feature vectors is within a preset interval, it is determined that the second target vehicle is the first target vehicle. In this way, even if the monitoring video is interrupted, the continuity of vehicle tracking can be maintained.

[0104] See also Figure 2-1 and Figure 2-2 Another embodiment of the vehicle re-identification method in the present application includes:

[0105] 201. The terminal trains the original model to obtain a preset model, so that the total loss value of the preset model reaches a threshold value;

[0106] The backbone network of the original model is a convolutional neural network, which includes a first convolutional layer, a pooling layer, a fully connected layer, a softmax layer and four residual blocks. The residual block includes two second convolutional layers with the same number of output channels as the first convolutional layer. Since the untrained original model is unstable and the output result has a large error, the original model needs to be trained, including forward propagation and backward propagation, so that the total loss value of the trained model reaches a threshold, then it is determined that the model can be used as a stable model. In the embodiment of the present application, the training process of the original model refers to steps 301 to 311, which will not be repeated here.

[0107] 202. The terminal detects a first target vehicle in the first video stream using a preset target detection algorithm;

[0108] The preset target detection algorithm is used to detect and extract a complete image of a vehicle contained in the video from the video stream. In an embodiment of the present application, the terminal first determines the vehicle to be tracked (the first target vehicle) from the first video stream through the preset target detection algorithm.

[0109] 203. The terminal generates an image of the first target vehicle;

[0110] The terminal transcodes the first target vehicle identified from the video in step 202 to generate an image of the first target vehicle.

[0111] 204. The terminal inputs the first target vehicle image into a preset model to extract a first feature map of the first target vehicle image;

[0112] To track the first target vehicle, the embodiment of the present application inputs the image of the first target vehicle into a preset model, and the preset model first extracts the feature layer of the first target vehicle to obtain a first feature map. The size of the first feature map is H×W×C, where H is the height of the first feature map, W is the width of the first feature map, and C is the number of channels of the first feature map.

[0113] 205. The terminal divides the first feature map into P blocks in a dimension of H to obtain a first block feature map, where P is a first preset value;

[0114] The terminal divides the first feature map into blocks, the number of blocks is P, and obtains P first block feature maps. The sizes of these first block feature maps are (H / P)×W×C. In the embodiment of the present application, P is the first preset value, and the developer can set it according to the training situation. No specific limitation is made here.

[0115] 206. The terminal sequentially connects the P first block feature maps to the average pooling layer and the 1×1 convolution layer in the preset model to obtain P second block feature maps with reduced dimensions;

[0116] In the embodiment of the present application, it is necessary to further reduce the dimension of the first block feature map so that a finer-grained feature of the first target vehicle can be obtained. Therefore, the terminal connects the first block feature map obtained in step 205 to the average pooling layer and the 1×1 convolution layer in the preset model to obtain the second block feature map.

[0117] 207. The terminal inputs the P second block feature maps into the fully connected layer and the softmax layer in the preset model to obtain P block results;

[0118] The terminal connects the second block feature map obtained in step 206 to the fully connected layer and the softmax layer in sequence, obtains a four-dimensional vector through the fully connected layer, and connects the fully connected layer to the softmax layer, which outputs a hundred-dimensional vector, so each second block feature map will obtain a vector result.

[0119] 208. The terminal concatenates the P block results to obtain the first feature vector;

[0120] The terminal concatenates the vector results of all the second block feature maps output in step 207 to obtain the first feature vector of the first target vehicle.

[0121] 209. The terminal detects a second target vehicle in the second video stream using a preset target detection algorithm;

[0122] When tracking the first target vehicle, the embodiment of the present application finds the second target vehicle from the second video stream through a preset target detection algorithm. The second video stream can come from the same continuous video data as the first video stream, or can come from different video data.

[0123] 210. The terminal generates an image of the second target vehicle;

[0124] The terminal transcodes the video data of the second target vehicle identified in step 209 into image data to generate an image of the second target vehicle.

[0125] 211. The terminal inputs the second target vehicle image into a preset model to extract a second feature map of the second target vehicle image;

[0126] 212. The terminal divides the second feature map into P blocks in a dimension of H to obtain a second block feature map, where P is a first preset value;

[0127] 213. The terminal sequentially connects the P third block feature maps to the average pooling layer and the 1×1 convolution layer in the preset model to obtain P fourth block feature maps with reduced dimensions;

[0128] 214. The terminal inputs the P fourth block feature maps into the fully connected layer and the softmax layer in the preset model to obtain P block results;

[0129] 215. The terminal concatenates the P block results to obtain the second feature vector;

[0130] In the embodiment of the present application, the process (steps 211 to 215) in which the terminal inputs the second image into the preset model to extract the second feature vector is similar in principle to the process (steps 204 to 208) of extracting the first feature vector, and will not be repeated here.

[0131] 216. The terminal determines whether the difference between the second feature vector and the first feature vector is within a preset interval. The smaller the difference, the higher the similarity between the first target vehicle and the second target vehicle. If yes, execute step 217; if no, execute step 218.

[0132] Due to factors such as lighting or the tilt angle of the vehicle in the picture, the feature vectors obtained for the same vehicle are inconsistent. These factors do not have a significant impact on the total value of the feature vector. Therefore, in the embodiment of the present application, the difference between the feature vectors is used to determine whether the second target vehicle is the first target vehicle. The smaller the difference between the two feature vectors, the higher the similarity between the two target vehicles. The range of the difference is a preset value, which can be set by the developer based on the actual model training results, and is not specifically limited here.

[0133] 217. The terminal determines that the second target vehicle and the first target vehicle are the same vehicle;

[0134] 218. The terminal determines that the second target vehicle and the first target vehicle are not the same vehicle.

[0135] The embodiment of the present application can extract a vehicle image from a video stream, and extract a feature vector of the vehicle image through a preset model. The terminal then obtains a second target vehicle image and a second feature vector of the second target vehicle image. If the difference between the second feature vector and the first feature vector is within a preset range, the second target vehicle is determined to be the first target vehicle to be tracked. The vehicle is tracked through the feature vector, and the first target vehicle can also be tracked when the surveillance video is interrupted or other conditions cause the tracking to be interrupted.

[0136] The process of the vehicle re-identification method is described in detail above. The following describes a method for training an original model in the vehicle re-identification method.

[0137] See also Figure 3 , an embodiment of training the original model in the vehicle re-identification method in the present application includes:

[0138] 301. The terminal sets an initialization learning rate;

[0139] Since the weights of the model are randomly initialized when the model is just started to be trained, if a larger learning rate is selected at this time, it may cause instability (oscillation) of the model. Therefore, the embodiment of the present application uses a warming-up learning rate strategy during the training process of the original model. Under a small learning rate, the model can slowly tend to stabilize. After the model is relatively stable, the learning rate is set (slowly increased) for training, so that the model converges faster and the model effect is better.

[0140] 302. The terminal obtains a secondary sample data group from the primary sample data group, and marks the number of times the secondary sample data group is obtained, wherein the secondary sample data group is an untrained secondary sample data group, and the primary sample data group includes several groups of secondary sample data groups, and the secondary sample data group includes several pictures of the same vehicle ID;

[0141] In the embodiment of the present application, the sample data to be trained needs to be classified in advance, and the primary sample data set includes several groups of secondary sample data groups. These secondary sample data groups are numbered, and vehicle pictures of different sizes or angles with the same license plate number are placed in the secondary sample data group, and these vehicle pictures are numbered in sequence. During the model training process, the same vehicle is identified, so the terminal needs to train the secondary sample data groups in sequence.

[0142] 303. The terminal obtains a first image from the secondary sample data group and inputs it into the original model to obtain a third feature vector of the first image, and marks the number of times the image is input, wherein the first image is an untrained vehicle image;

[0143] After determining the secondary sample data group, the terminal sequentially inputs the vehicle images into the original model to obtain the third eigenvector of the input image, and marks the number of times the image is input to indicate the number of training times.

[0144] 304. The terminal calculates a first total loss value of the original model through a total loss function and updates the original model by back-propagation according to the first total loss value to obtain a secondary model.

[0145] In the embodiment of the present application, the total loss function L is specifically calculated as shown in formula (1) and is defined as follows:

[0146] L=λ1L1+λ2L2 Formula (1)

[0147] L1 is the SpherefaceLoss loss function, which is specifically calculated in formula (2) and defined as follows:

[0148]

[0149] L2 is the TripletLoss loss function, which is calculated as shown in formula (3) and defined as follows:

[0150] L2=max(d(a,p)-d(a,n)+margin,0) Formula (3)

[0151] In formula (1), λ1 is the weight corresponding to L1, and λ2 is the weight corresponding to L2. The specific setting depends on the training effect and is not limited here. After obtaining the first total loss value, the current original model is back-propagated to reduce the learning error of the model.

[0152] Formula (2) is mainly used to learn discriminative features, where N is the number of training samples (the number of times the input image is labeled), C is the number of sample categories (the number of groups of secondary sample data groups obtained by labeling), and s is a hyperparameter (set to 10 in the embodiment of the present application);

[0153] The purpose of formula (3) is to make the distance between positive samples (the same license plate number) small and the distance between negative samples (different license plate numbers) large, where p is the positive sample, n is the negative sample, and margin is a hyperparameter, which is set according to the training effect and is not limited here.

[0154] 305. The terminal determines whether all images in the secondary sample data group have been traversed. If so, step 302 is executed; if not, step 306 is executed.

[0155] In an embodiment of the present application, the terminal determines whether the images in the current secondary sample data group have been traversed to the end of the queue through the labels of the images in the secondary sample data group. If so, it is determined that all the images in the current secondary sample data group have been trained, and the traversal of the next group of secondary sample data groups begins.

[0156] 306. The terminal inputs the second image into the secondary model and marks the number of times the image is input, to obtain a fourth feature vector of the second image, where the vehicle in the second image is consistent with the vehicle in the first image;

[0157] The terminal sequentially inputs a second image that follows the current image that has completed training into the currently updated secondary model, and the secondary model outputs a fourth eigenvector of the second image.

[0158] 307. The terminal calculates a second total loss value of the updated original model through a total loss function and updates the secondary model by back-propagation according to the second total loss value;

[0159] In the embodiment of the present application, the total loss value in the updated model (referred to as the second total loss value here to avoid confusion) is calculated according to the formula in the total loss function, and the current model is back-propagated according to the second loss value. Since step 307 is similar to the aforementioned step 304, the details are not repeated here.

[0160] 308. The terminal determines whether the second total loss value is less than the first total loss value. If so, execute step 309; if not, execute step 310.

[0161] As the training process continues at the current learning rate, the network loss becomes smaller and smaller. The terminal currently compares the second total loss value with the first total loss value. If the network loss no longer decreases, it means that the model at the current learning rate has stabilized.

[0162] 309. The terminal updates the learning rate;

[0163] The terminal updates the learning rate of the current model. Since the embodiment of the present application adopts a warming-up learning rate strategy, the learning rate is updated in a slowly increasing manner and can be increased according to a preset value, which is not specifically limited here, thereby avoiding the situation of gradient explosion during model training.

[0164] 310. The terminal determines whether the second total loss value is less than or equal to a threshold value. If so, execute step 311; if not, execute step 305;

[0165] There are many ways to determine model convergence. The embodiment of the present application determines whether the current loss value is less than a preset threshold. Of course, the convergence condition can also be set by the number of iterations, which is not limited here. If the current total loss value does not reach the threshold, the model continues to be trained.

[0166] 311. The terminal determines that the updated secondary model is a preset model.

[0167] The embodiment of the present application uses a warming-up learning rate strategy during the model training process. A smaller learning rate can be used to gradually initialize the original model, reducing the occurrence of gradient explosion. When the network training tends to be stable, a larger learning rate is used for training. This training strategy can make the model training process more stable without increasing the computational complexity of the model.

[0168] Please refer to FIG. 4 , an embodiment of a vehicle re-identification device in the present application includes:

[0169] A training unit 401 is used to train the original model to obtain a preset model so that the total loss value of the preset model reaches a threshold value;

[0170] A first acquisition unit 402 is used to acquire a first target vehicle image from a first video stream;

[0171] A first input unit 403 is used to input the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image;

[0172] A second acquisition unit 404 is used to acquire a second target vehicle image from a second video stream;

[0173] A second input unit 405 is used to input the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle;

[0174] A first judging unit 406 is used to judge whether the difference between the second feature vector and the first feature vector is within a preset interval, and the smaller the difference is, the higher the similarity between the first target vehicle and the second target vehicle is;

[0175] The determination unit 407 is configured to determine that the second target vehicle and the first target vehicle are the same vehicle when the first judgment unit determines that the second feature vector and the first feature vector are within a preset interval.

[0176] The training unit 401 described in the embodiment of the present application includes:

[0177] Initialization module 4011, used to set the initialization learning rate;

[0178] The first acquisition module 4012 is used to acquire a secondary sample data group from the primary sample data group, and mark the number of times the secondary sample data group is acquired, wherein the secondary sample data group is an untrained secondary sample data group, and the primary sample data group includes a plurality of secondary sample data groups, and the secondary sample data group includes a plurality of pictures of the same vehicle ID;

[0179] A first execution module 4013 is used to obtain a first image from the secondary sample data group and input the first image into the original model to obtain a third feature vector of the first image, and mark the number of times the image is input, wherein the first image is an untrained vehicle image;

[0180] A first calculation module 4014, configured to calculate a first total loss value of the original model by using a total loss function and update the original model by back-propagation according to the first total loss value to obtain a secondary model;

[0181] A first judgment module 4015 is used to judge whether all images in the secondary sample data group have been traversed;

[0182] A second execution module 4016 is configured to input the second image into the secondary model and mark the number of times the image is input, to obtain a fourth feature vector of the second image, when the first judgment module determines that the images in the second sample data group have not been traversed completely, and the vehicle in the second image is consistent with the vehicle in the first image;

[0183] A second calculation module 4017, configured to calculate a second total loss value of the updated original model through a total loss function and update the secondary model by back-propagation according to the second total loss value;

[0184] A second judging module 4018, configured to judge whether the second total loss value is less than the first total loss value;

[0185] A third judgment module 4019 is used to judge whether the second total loss value is less than or equal to a threshold value when the result of the second judgment module is no;

[0186] The determination module 40110 is used to determine that the updated secondary model is a preset model when the third judgment module determines that the second total loss value is less than or equal to a threshold value.

[0187] The updating module 40111 is used to update the learning rate when the third judgment module determines that the second total loss value is less than or equal to a threshold.

[0188] In the embodiment of the present application, the first acquisition unit 402 includes:

[0189] The identification and detection module 4021 is used to detect a first target vehicle in the first video stream using a preset target detection algorithm;

[0190] The generating module 4022 is used to generate the image of the first target vehicle.

[0191] In the embodiment of the present application, the first input unit 403 includes:

[0192] A first extraction module 4031 is used to input the first target vehicle image into a preset model to extract a first feature map of the first target vehicle image, where the size of the first feature map is H×W×C, where H is the height of the first feature map, W is the width of the first feature map, and C is the number of channels of the first feature map;

[0193] A first cutting module 4032 is used to divide the first feature map into P blocks in the dimension of H to obtain a first block feature map, where P is a first preset value;

[0194] A first access module 4033 is used to sequentially access the P first block feature maps to the average pooling layer and the 1×1 convolution layer in the preset model to obtain P second block feature maps with reduced dimensions;

[0195] The second access module 4034 is used to input the P second block feature maps into the fully connected layer and the softmax layer in the preset model to obtain P block results;

[0196] The splicing module 4035 is used to splice the P block results to obtain the first feature vector.

[0197] See also Figure 5 Another embodiment of the vehicle re-identification device in the present application includes:

[0198] Processor 501, memory 502, input and output unit 503, bus 504;

[0199] The processor 501 is connected to the memory 502, the input and output unit 503 and the bus 504;

[0200] The processor 401 specifically performs the following operations:

[0201] Acquire a first target vehicle image from a first video stream;

[0202] Inputting the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image;

[0203] Acquire a second target vehicle image from a second video stream;

[0204] Inputting the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle;

[0205] Determine whether the difference between the second feature vector and the first feature vector is within a preset interval, the smaller the difference is, the higher the similarity between the first target vehicle and the second target vehicle is;

[0206] If so, it is determined that the second target vehicle and the first target vehicle are the same vehicle.

[0207] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0208] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0209] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0210] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0211] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.

Claims

1. A vehicle re-identification method, characterized in that: include: Train the original model to obtain a preset model so that the total loss value of the preset model reaches a threshold value; The training of the original model to obtain a preset model so that the total loss value of the preset model reaches a threshold value includes: Set the initial learning rate; Obtaining a secondary sample data group from the primary sample data set, and marking the number of times the secondary sample data group is obtained, wherein the secondary sample data group is an untrained secondary sample data group, and the primary sample data set includes several groups of secondary sample data groups, and the secondary sample data group includes several pictures of the same vehicle ID; Obtaining a first image from the secondary sample data group and inputting it into the original model to obtain a third feature vector of the first image, and marking the number of times the image is input, wherein the first image is an untrained vehicle picture; Calculating a first total loss value of the original model by a total loss function and back-propagating and updating the original model according to the first total loss value to obtain a secondary model; Determining whether all images in the secondary sample data group have been traversed; If not, input the second image into the secondary model and mark the number of times the image is input, to obtain a fourth feature vector of the second image, and the vehicle in the second image is consistent with the vehicle in the first image; Calculate a second total loss value of the updated original model by a total loss function and update the secondary model by back-propagation according to the second total loss value; Determining whether the second total loss value is less than the first total loss value; If not, determining whether the second total loss value is less than or equal to a threshold; If yes, determining that the updated secondary model is the preset model; Acquire a first target vehicle image from a first video stream; Inputting the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image; Acquire a second target vehicle image from a second video stream; Inputting the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle; Determine whether the difference between the second feature vector and the first feature vector is within a preset interval, the smaller the difference is, the higher the similarity between the first target vehicle and the second target vehicle is; If so, it is determined that the second target vehicle and the first target vehicle are the same vehicle.

2. The vehicle re-identification method according to claim 1, characterized in that: The convolutional neural network includes a first convolutional layer, a pooling layer, a fully connected layer, a softmax layer and four residual blocks, and the residual block includes two second convolutional layers having the same number of output channels as the first convolutional layer.

3. The vehicle re-identification method according to claim 2, characterized in that: Inputting the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle includes: Input the first target vehicle image into a preset model to extract a first feature map of the first target vehicle image, where the size of the first feature map is H×W×C, where H is the height of the first feature map, W is the width of the first feature map, and C is the number of channels of the first feature map; Divide the first feature map into P blocks in the dimension of H to obtain a first block feature map, where P is a first preset value; The P first block feature maps are sequentially connected to the average pooling layer and the 1×1 convolution layer in the preset model to obtain P second block feature maps with reduced dimensions; Input the P second block feature maps into the fully connected layer and the softmax layer in the preset model to obtain P block results; The P block results are concatenated to obtain the first feature vector.

4. The vehicle re-identification method according to claim 1, characterized in that: The determining whether the second total loss value is less than or equal to the threshold value, the method further includes: If not, update the learning rate.

5. The vehicle re-identification method according to claim 1, characterized in that: The total loss function is the sum of the first loss function multiplied by the first weight and the second loss function multiplied by the second weight, the first loss function is the SpherefaceLoss loss function, the second loss function is the Triplet Loss loss function, and the first weight and the second weight are the second preset value and the third preset value respectively.

6. The vehicle re-identification method according to any one of claims 1 to 5, characterized in that: Acquiring a first target vehicle image from a first target video, including: Detecting a first target vehicle in the first video stream using a preset target detection algorithm; An image of the first target vehicle is generated.

7. A vehicle re-identification device, characterized in that: include: A training unit, used for training the original model to obtain a preset model so that the total loss value of the preset model reaches a threshold value; The training unit is specifically used for: Set the initial learning rate; Obtaining a secondary sample data group from the primary sample data set, and marking the number of times the secondary sample data group is obtained, wherein the secondary sample data group is an untrained secondary sample data group, and the primary sample data set includes several groups of secondary sample data groups, and the secondary sample data group includes several pictures of the same vehicle ID; Obtaining a first image from the secondary sample data group and inputting it into the original model to obtain a third feature vector of the first image, and marking the number of times the image is input, wherein the first image is an untrained vehicle picture; Calculating a first total loss value of the original model by a total loss function and back-propagating and updating the original model according to the first total loss value to obtain a secondary model; Determining whether all images in the secondary sample data group have been traversed; If not, input the second image into the secondary model and mark the number of times the image is input, to obtain a fourth feature vector of the second image, and the vehicle in the second image is consistent with the vehicle in the first image; Calculate a second total loss value of the updated original model by a total loss function and update the secondary model by back-propagation according to the second total loss value; Determining whether the second total loss value is less than the first total loss value; If not, determining whether the second total loss value is less than or equal to a threshold; If yes, determining that the updated secondary model is the preset model; A first acquisition unit, used to acquire a first target vehicle image from a first video stream; A first input unit is used to input the first target vehicle image into a preset model to obtain a first feature vector of the first target vehicle, wherein the backbone network of the preset model is a convolutional neural network, and the convolutional neural network is used to extract a feature map of the input target vehicle image, and output a feature vector after cutting and matrix calculation of the feature map, wherein the feature vector is the sum of fine-grained features of the target vehicle image; A second acquisition unit, used for acquiring a second target vehicle image from a second video stream; A second input unit, used for inputting the second target vehicle image into the preset model to obtain a second feature vector of the second target vehicle; A first judging unit, configured to judge whether a difference between the second feature vector and the first feature vector is within a preset interval, wherein a smaller difference indicates a higher similarity between the first target vehicle and the second target vehicle; A determination unit is used to determine that the second target vehicle and the first target vehicle are the same vehicle when the first judgment unit determines that the second feature vector and the first feature vector are within a preset interval.

8. The vehicle re-identification device according to claim 7, characterized in that: The device also includes: The training unit is used to train the original model to obtain a preset model so that the total loss value of the preset model reaches a threshold value.