A frame extraction pedestrian retrieval method based on YOLOv5s and stage-by-stage regularization for joint person re-identification
Through the pedestrian re-identification method based on YOLOv5s and staged regularization, combined with Euclidean distance and adaptive representation joint attention module, the problem of low accuracy of pedestrian re-identification technology in monitoring non-motor vehicle traffic violations is solved and achieved It achieves efficient recognition and collaborative retrieval in a multi-camera environment, and improves recognition accuracy and generalization capabilities.
Patent Information
- Application Number
- CN202410985478.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-07-23
Smart Images

Figure CN118522039B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a frame extraction pedestrian retrieval method based on YOLOv5s and stage-by-stage regularization combined pedestrian re-identification. Background Art
[0002] With the rise of smart cities, the use of shared bicycles and shared trams has increased, leading to a surge in the number of non-motor vehicles on the road. However, this has also brought challenges such as forced lane changes, mixed traffic of vehicles and non-motor vehicles, and illegal parking; traditional manual supervision methods are imperfect, and the monitoring of non-motor vehicle traffic violations is inefficient and inaccurate. Pedestrian re-identification technology can establish a connection between the motion trajectories of target entities in different monitoring areas, and realize pedestrian tracking across time, location, and device. However, due to interference from reasons such as changes in perspective, changes in illumination, and occlusion, the camera cannot capture a complete pedestrian image. Existing pedestrian re-identification technologies are difficult to balance global features with local features, resulting in limited recognition accuracy. Videos have more information than images, and video-based research is more in line with the reality of video surveillance environments. However, at this stage, video-based pedestrian re-identification not only faces the same challenges as image-based pedestrian re-identification, such as object occlusion, posture changes, and illumination changes, but also has problems unique to video data, such as large data volume, large computational complexity, and redundancy. Summary of the invention
[0003] Purpose of the invention: The purpose of the present invention is to provide a frame extraction pedestrian retrieval method based on YOLOv5s and staged regularized joint pedestrian re-identification to solve the problem of low efficiency and inaccuracy in manual supervision of non-motor vehicle traffic violations.
[0004] Technical solution: The present invention discloses a frame extraction pedestrian retrieval method based on YOLOv5s and staged regularization combined pedestrian re-identification, comprising the following steps:
[0005] (1) Obtain the extended image-video pedestrian EIVP dataset and perform preprocessing;
[0006] (2) Construct a YOLOv5s-Re-ID model based on YOLOv5s and staged regularized joint pedestrian re-identification model, and train the model. The YOLOv5s-Re-ID model includes: a YOLOv5s module and an improved Re-ID module; the YOLOv5s module passes the processed image to the improved Re-ID module through list tiling.
[0007] (3) Use Euclidean distance to calculate the similarity between the image output by the YOLOv5s module and the image output by the improved Re-ID module.
[0008] Furthermore, step (1) is as follows: first, the video is processed by setting different frame extraction frequencies to obtain 1540 basic images, and 240 labeled images of 11 IDs are finally obtained by manually annotating the boxes to construct the image set of the EIVP dataset; second, the image set in the EIVP dataset is randomly divided into a training set and a test set in a 1:1 ratio; it contains 14 query images and 106 gallery images; for each ID, one image is randomly selected from the 240 images to form a query set for evaluating the performance of the model; the videos in the video set of the EIVP dataset are preprocessed, including resizing, renaming, and normalization to adapt to the input requirements of the YOLOv5s model.
[0009] Furthermore, in step (2), the processing process of the YOLOv5s module is as follows: first, the pre-processed video to be detected is input into the YOLOv5 model, and the pedestrian category image is detected according to the set frame extraction frequency; second, manual labeling is performed, and the selected pedestrian image is stored in the query set; and for the previously labeled images, they are directly placed in the query set; the pedestrian category image processed by YOLOv5s and the query set are input into the improved Re-ID model for feature extraction, and the features are passed to the detection head for target prediction.
[0010] Furthermore, in step (2), the improved Re-ID module is specifically as follows: the improved Re-ID module is used to extract pedestrian image features and retrieve specific pedestrian IDs, and the backbone network is ResNet50; wherein the basic function is replaced by a staged learning rate scheduler, and by combining with a warm-up function, polynomial decay is used for learning rate decay during training, and in the subsequent stage, cosine annealing is switched to smoothly adjust the learning rate; an adaptive representation joint attention module is added after the third layer of the ResNet50 module, including: a spatial transformer attention block STAB and a squeeze and excitation attention block SEAB; the loss function part is called after ResNet50, and a regularized center loss is added.
[0011] Furthermore, the formula for the staged learning rate scheduler is as follows:
[0012] ;
[0013] in, t Indicates the current training round, W Indicates the round at which the warm-up phase ends. Indicates the round at which the learning rate maintenance phase ends, D represents the round at which the polynomial decay phase ends, T represents the total number of training rounds, S represents the attenuation step length, min_ lrrepresents the minimum learning rate, max_lr represents the maximum learning rate, represents the annealing step length.
[0014] Furthermore, the adaptive representation joint attention module is used to perform spatial transformation on the input feature map and set weight excitation for each feature channel; among them, STAB is used to perform spatial transformation on the input feature map so that the network can focus on important areas in the image; SEAB is used to set weight excitation for each feature channel to suppress features that are useless for the current task and remove redundant information.
[0015] Furthermore, the loss function formula is as follows:
[0016] ;
[0017] Among them, L represents the total loss value, represents the ID loss value, represents the triple loss value, represents the regularized center loss value, β represents the balance weight of the regularized center loss;
[0018] ;
[0019] in, N represents the given number of samples, Indicates the real ID tag, Expressed as i The logical number of predicted IDs for each sample, α is a small constant that encourages the model to have less confidence in the training set; Represents the true probability distribution after adding label smoothing;
[0020] ;
[0021] in, B is the batch size, It is i The characteristics of the samples, It is i The samples correspond to the true labels The center point of express The square of the norm, l is the weight of the regularization term;
[0022] ;
[0023] in, , , It means that three images are taken from the training data each time, the first two are of the same category, and the third one is of a different category. m is the deviation, Indicates that the distance value is always non-negative; Represents the feature expression corresponding to the feature map.
[0024] Furthermore, step (3) is specifically as follows: based on the prediction results of the improved Re-ID model and the set threshold, a bounding box of the candidate target is generated; based on the set confidence threshold and distance threshold, the generated bounding box is screened, and the final target bounding box related information is output, including the position coordinates and category information of the bounding box; finally, the video frame after drawing the bounding box is input into the YOLOv5 model again, and after traversing each detected pedestrian, the frame is reassembled to generate a detected video.
[0025] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: it can process videos and images simultaneously, perform unsupervised detection of non-motor vehicle traffic violators on the road, and can lock the ID features required for detection (i.e., the pedestrian features of traffic violators in the undetected data set) through the existing data set, thereby realizing the collaborative retrieval of specific pedestrians under multiple cameras; at the same time, the improved pedestrian re-identification model can effectively improve the generalization ability and classification performance, reduce the risk of overfitting, and reduce the impact of occlusion, thereby improving the recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a general schematic diagram of the present invention;
[0027] Figure 2 It is a schematic diagram of a model of the present invention;
[0028] Figure 3 The influence of different S, λ, β and γ values on the Market-1501 dataset of the present invention. DETAILED DESCRIPTION
[0029] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0030] A frame extraction pedestrian retrieval method based on YOLOv5s and stage-wise regularization combined pedestrian re-identification includes the following steps:
[0031] (1) The extended image-video pedestrian EIVP dataset was obtained and preprocessed as follows: First, the video was processed by setting different frame extraction frequencies to obtain 1540 basic images. By manually annotating the boxes, 240 labeled images of 11 IDs were finally obtained to construct the image set of the EIVP dataset; secondly, the image set in the EIVP dataset was randomly divided into a training set and a test set in a 1:1 ratio; it contains 14 query images and 106 gallery images; for each ID, one image was randomly selected from the 240 images to form a query set for evaluating the performance of the model; the videos in the video set of the EIVP dataset were preprocessed, including resizing, renaming, and normalization to adapt to the input requirements of the YOLOv5s model.
[0032] (2) Construct a YOLOv5s-Re-ID model based on YOLOv5s and staged regularization joint pedestrian re-identification model, and train the model. The YOLOv5s-Re-ID model includes: a YOLOv5s module and an improved Re-ID module; the YOLOv5s module passes the processed image to the improved Re-ID module through list tiling. The processing process of the YOLOv5s module is as follows: first, the pre-processed video to be detected is input into the YOLOv5 model, and the pedestrian category image is detected according to the set frame extraction frequency; secondly, manual annotation is performed, and the selected pedestrian image is stored in the query set; for the previously annotated images, they are directly put into the query set; the pedestrian category image processed by YOLOv5s and the query set are input into the improved Re-ID model for feature extraction, and the features are passed to the detection head for target prediction.
[0033] The improved Re-ID module is as follows: the improved Re-ID module is used to extract pedestrian image features and retrieve specific pedestrian IDs, and the backbone network is ResNet50; the basic function is replaced by a staged learning rate scheduler, and by combining it with a warm-up function, polynomial decay is used for learning rate decay during training, and in subsequent stages it is switched to cosine annealing to smoothly adjust the learning rate; an adaptive representation joint attention module is added after the third layer of the ResNet50 module, including: spatial transformer attention block STAB and squeeze and excitation attention block SEAB; the loss function part is called after ResNet50, and a regularized center loss is added.
[0034] The formula for the staged learning rate scheduler is as follows:
[0035] ;
[0036] in, t Indicates the current training round, W Indicates the round at which the warm-up phase ends. Indicates the round at which the learning rate maintenance phase ends, D represents the round at which the polynomial decay phase ends, T represents the total number of training rounds, S represents the attenuation step length, min_ lr represents the minimum learning rate, max_lr represents the maximum learning rate, represents the annealing step length.
[0037] The adaptive representation joint attention module is used to perform spatial transformation on the input feature map and set weight incentives for each feature channel; STAB is used to perform spatial transformation on the input feature map so that the network can focus on important areas in the image; SEAB is used to set weight incentives for each feature channel to suppress features that are useless for the current task and remove redundant information. The specific processing process is as follows:
[0038] Set up i The layer input feature map is ;in, C is the number of input channels, H is the height, W is the width; STAB contains two parts, encoding and decoding. i Layer input feature map When , the module first reduces its channel number through the convolution layer , followed by encoding processing to obtain the encoding feature map , and then through the decoding operation, the decoding feature map is obtained , and finally the final spatial feature map is obtained through the convolution layer .
[0039] SEAB will i Layer input feature map The global spatial information is compressed into , and then learn the feature importance weights through a fully connected layer consisting of two linear layers and an activation function, where the first linear layer converts the number of input channels by C Dimensionality reduction to , the second linear layer upscales it back to the original number of channels, thus obtaining the feature map channel importance representation , as shown below:
[0040]
[0041] in, , Represent the weights of the first and second linear layers, It is the ReLU activation function that constrains the output to the non-negative region. cRepresents the dimensionality reduction coefficient, which controls the degree of feature compression in the fully connected layer, and thus affects the number of parameters reduced by the model. The reduction in the number of parameters can enhance the computational efficiency and generalization ability of the model, but the increase in the compression ratio will also lead to an increase in information loss, so it needs to be set to an appropriate value.
[0042] After STAB and SEAB, the spatial feature maps are obtained respectively. And channel feature map ,Will and Add together to get the basic joint feature map , and the attention weight obtained after normalization by the sigmoid function is Multiply them together to get the weighted joint attention feature , then and Add together to get the final discriminant feature , the formula is as follows:
[0043]
[0044] in, represents the input feature map, represents the weighted joint attention feature, represents the basic joint feature, represents the sigmoid function, represents element-wise multiplication, Represents element-by-element addition.
[0045] The loss function formula is as follows:
[0046]
[0047] Among them, L represents the total loss value, represents the ID loss value, represents the triple loss value, represents the regularized center loss value, β represents the balancing weight of the regularized center loss.
[0048] ;
[0049] in, N represents the given number of samples, Indicates the real ID tag, Expressed as i The logical number of predicted IDs for each sample, α is a small constant that encourages the model to have less confidence in the training set; Represents the true probability distribution after adding label smoothing;
[0050] ;
[0051] in, B is the batch size, It is i The characteristics of the samples, It is i The samples correspond to the true labels The center point of express The square of the norm, l is the weight of the regularization term.
[0052] ;
[0053] in, , , It means that three images are taken from the training data each time, the first two are of the same category, and the third one is of a different category. m is the deviation, Indicates that the distance value is always non-negative; Represents the feature expression corresponding to the feature map.
[0054] The Euclidean distance is used to calculate the similarity between the image output by the YOLOv5s module and the image output by the improved Re-ID module. The details are as follows: based on the prediction results of the improved Re-ID model and the set threshold, the bounding box of the candidate target is generated; based on the set confidence threshold and distance threshold, the generated bounding box is screened, and the final target bounding box related information is output, including the location coordinates and category information of the bounding box; finally, the video frame after drawing the bounding box is input into the YOLOv5 model again, and after traversing each detected pedestrian, the frame is reassembled to generate the detected video.
[0055] Ablation Experiment Results and Analysis
[0056] We add warmup strategies, staged learning rate schedulers, regularized center losses, and adaptive representation attention modules to the model training process one by one and evaluate the impact on performance.
[0057] Table 1 Performance of different models evaluated on Market-1501 and DukeMTMC-ReID datasets
[0058] .
[0059] As shown in Table 1, although the warm-up strategy slightly improves the performance of the baseline, the results are not satisfactory. The addition of the staged learning rate scheduler reduces the learning rate faster in the early stage of training to improve stability, and better adjusts the learning rate in the later stage of training to escape the local optimum and improve the generalization ability of the model. After being constrained by the proposed regularized center loss to handle intra-class differences and inter-class distances and reduce the risk of overfitting, the model can optimize the performance of the model well. In addition, the proposed adaptive representation attention module performs spatial transformation and channel squeezing and activation processing on the feature map, effectively enhancing the robustness and accuracy of feature representation. Although the first hit rate decreases by 0.2%, the average accuracy increases by 0.6%. Finally, these techniques enable the baseline to obtain a first hit rate of 94.6% and an average accuracy of 86.2% on Market-1501, and a first hit rate of 87.3% and an average accuracy of 76.5% on DukeMTMC-ReID. After re-ranking the Re-ID results using the k-reciprocal encoding method, the first-place hit rates reach 96.1% and 90.8% on Market-1501 and DukeMTMC-ReID, respectively.
[0060] Table 2 Comparison of the effects of different attention on Market-1501 and EIVP datasets
[0061] .
[0062] Table 3 Comparison of the impact of adding adaptive representation attention modules to different layers of ResNet50
[0063] .
[0064] The adaptive representation attention module consists of two parts: STAB and SEAB. As shown in Table 2, when only STAB is used, the network will overly rely on the spatial transformation range in the dataset, resulting in limited capabilities; when only SEAB is used, the network only operates at the channel level and may not be able to capture low-level pixel-level details, thus failing to achieve optimal network performance. Finally, when the adaptive representation attention module is used, the best results can be achieved on both Market-1501 and EIVP.
[0065] The proposed adaptive representation attention module can be inserted after any stage of the backbone network. We insert the adaptive representation attention module after different layers of ResNet50 to study how it will affect the performance of the stage-wise regularized joint person re-identification model. As shown in Table 3, when the adaptive representation attention module is inserted after layers 1 to 3, the performance gradually improves, indicating that the relevant features are more focused and the adaptive representation attention module is able to improve the feature representation accuracy of the input image in deeper layers of the network.
[0066] like Figure 3 As shown, when the attenuation step length S Set to 21, the weight of the regularization term l and the balance weight of the regularized center loss β are set to 0.011 and 0.0005 respectively, and the dimension reduction coefficient c Equal to the number of channels C The model achieved the best performance when the size was 16 times larger than that of
Claims
1. A frame extraction pedestrian retrieval method based on YOLOv5s and stage-by-stage regularization combined pedestrian re-identification, characterized in that: The following steps are involved: (1) Obtain the extended image-video pedestrian EIVP dataset and perform preprocessing; (2) Construct a YOLOv5s-Re-ID model based on YOLOv5s and staged regularized joint pedestrian re-identification model, and train the model. The YOLOv5s-Re-ID model includes: a YOLOv5s module and an improved Re-ID module; the YOLOv5s module passes the processed image to the improved Re-ID module through list tiling; the processing process of the YOLOv5s module is as follows: first, the pre-processed video to be detected is input into the YOLOv5s model, and the pedestrian category image is detected according to the set frame extraction frequency; secondly, manual annotation is performed, and the selected pedestrian image is stored in the query set; for the previously annotated images, they are directly put into the query set; the pedestrian category image processed by YOLOv5s and the query set are input into the improved Re-ID model for feature extraction, and the features are passed to the detection head for target prediction; The improved Re-ID module is as follows: the improved Re-ID module is used to extract pedestrian image features and retrieve specific pedestrian IDs, and the backbone network is ResNet50; the basic learning rate function is replaced by a staged learning rate scheduler, which is combined with a warm-up function to use polynomial decay for learning rate decay during training, and switch to cosine annealing in the subsequent stage to smoothly adjust the learning rate; an adaptive representation joint attention module is added after the third layer of the ResNet50 module, including: spatial transformer attention block STAB and squeeze and excitation attention block SEAB; the loss function part is called after ResNet50, and regularized center loss is added; The loss function formula is as follows: ; Among them, L represents the total loss value, represents the ID loss value, represents the triple loss value, represents the regularized center loss value, β represents the balance weight of the regularized center loss; ; in, N represents the given number of samples, Indicates the real ID tag, Expressed as i The predicted ID logical number of samples, α is a small constant that encourages the model to have less confidence in the training set; Represents the true probability distribution after adding label smoothing; ; in, B is the batch size, It is i The characteristics of the samples, It is i The samples correspond to the true labels The center point of express The square of the norm, λ is the weight of the regularization term; ; in, , , It means that three images are taken from the training data each time, the first two are of the same category, and the third one is of a different category. m is the deviation, Indicates that the distance value is always non-negative; Indicates the feature expression corresponding to the feature map; The adaptive representation joint attention module is used to perform spatial transformation on the input feature map and set weight excitation for each feature channel; STAB is used to perform spatial transformation on the input feature map so that the network can focus on the important areas in the image; SEAB is used to set weight excitation for each feature channel to suppress features that are useless for the current task and remove redundant information; (3) Use the Euclidean distance to calculate the similarity between the image output by the YOLOv5s module and the image output by the improved Re-ID module; specifically, generate the bounding box of the candidate target based on the prediction results of the improved Re-ID model and the set threshold; filter the generated bounding box based on the set confidence threshold and distance threshold, and output the final target bounding box related information, including the location coordinates and category information of the bounding box; finally, input the video frame after drawing the bounding box into the YOLOv5s model again, traverse each detected pedestrian, and reassemble the frame to generate the detected video.
2. According to claim 1, a frame extraction pedestrian retrieval method based on YOLOv5s and staged regularized joint pedestrian re-identification is characterized in that: Step (1) is as follows: First, the video is processed by setting different frame extraction frequencies to obtain 1540 basic images. By manually annotating the boxes, 240 labeled images of 11 IDs are finally obtained to construct the image set of the EIVP dataset; secondly, the image set in the EIVP dataset is randomly divided into a training set and a test set in a 1:1 ratio; it contains 14 query images and 106 gallery images; for each ID, one image is randomly selected from the 240 images to form a query set for evaluating the performance of the model; the videos in the EIVP dataset video set are preprocessed, including resizing, renaming, and normalization to adapt to the input requirements of the YOLOv5s model.
3. According to claim 1, a frame extraction pedestrian retrieval method based on YOLOv5s and staged regularized joint pedestrian re-identification is characterized in that: The formula for the staged learning rate scheduler is as follows: ; in, t Indicates the current training round, W Indicates the round at which the warm-up phase ends. Indicates the round at which the learning rate maintenance phase ends, D represents the round at which the polynomial decay phase ends, T represents the total number of training rounds, S represents the attenuation step length, min_lr represents the minimum learning rate, max_lr represents the maximum learning rate, represents the annealing step length.
Citation Information
Patent Citations
Pedestrian re-identification method based on multi-attribute and multi-strategy fusion learning
CN107330396A
Single-target person tracking method integrating pedestrian re-identification and face detection
CN112668483A
Road vehicle tracking method and system based on attention mechanism and multi-target tracking
CN114627447A
Non-motor vehicle pedestrian re-identification method and system
CN115205890A
Small model traffic flow detection method, device and system based on improved YOLOv5 and DeepSORT
CN116797979A
