Bus stop scene vehicle and pedestrian detection method based on improved YOLOV5
By replacing the C3 module with C3-Faster in YOLOV5, introducing GSConv and ECA, and the TDIOU-NMS algorithm, the limitations of traditional detection methods in detection accuracy and speed in bus stop scenes are solved, and efficient, real-time vehicle and Pedestrian detection.
Patent Information
- Application Number
- CN202411056896.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-08-30
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional vehicle and pedestrian detection methods in bus stop scenes have limitations in detection accuracy and calculation speed. Especially in the case of complex illumination changes and background interference, it is difficult to meet the needs of real-time high-precision detection.
Based on the YOLOV5 framework, the C3 module in the backbone network is replaced by C3-Faster, the GSConv module and the effective channel attention mechanism ECA are introduced, and the improved distance intersection-union ratio non-maximum suppression algorithm TDIOU-NMS is used to optimize redundant candidate prediction box.
It improves the detection speed and accuracy, enhances the robustness to occluded vehicles and pedestrian targets, and achieves real-time accurate recognition. The model occupies small memory and is fast, meeting the needs of real-time detection.
Smart Images

Figure CN118570740A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a vehicle and pedestrian detection method in a bus stop scene based on improved YOLOV5. Background Art
[0002] In today's society, with the continuous acceleration of urbanization, the importance of public transportation systems has become increasingly prominent. As an important part of the urban public transportation network, buses carry a large number of passengers' travel needs. However, with the increase in urban traffic flow, traffic management and safety monitoring between vehicles and pedestrians in bus stop scenes face many challenges. Traditional bus stop scene vehicle and pedestrian detection methods are often based on traditional target detection algorithms, such as Haar cascade, HOG+SVM, etc. These methods have certain limitations in detection accuracy and calculation speed. In addition, due to the complex lighting changes, background interference and other factors in the bus stop scene, traditional methods often cannot meet the needs of real-time high-precision detection. Summary of the invention
[0003] Purpose of the invention: The purpose of the present invention is to provide a vehicle and pedestrian detection method in a bus stop scene based on an improved YOLOV5 to solve the problems raised in the background technology.
[0004] Technical solution: The present invention discloses a method for detecting vehicles and pedestrians in bus stop scenes based on improved YOLOV5, comprising the following steps: (1) Install cameras at bus stops, collect video data, and build a dataset.
[0005] (2) Based on the YOLOV5 framework, the network is reconstructed to obtain a lightweight network model. The cross-stage partial network bottleneck module C3 with three convolutional layers in the YOLOV5 backbone network is completely replaced with a fast cross-stage partial network bottleneck module C3-Faster with three convolutional layers; the group space convolution module GSConv is used to transform the original neck network Neck layer; and the effective channel attention mechanism ECA is added to the 10th layer of the backbone network; (3) The improved distance intersection-over-union non-maximum suppression algorithm TDIOU-NMS is used to optimize redundant candidate prediction boxes; (4) Train and construct an improved YOLOV5 bus stop scene vehicle and pedestrian detection model; (5) Use the trained improved YOLOV5 bus stop scene vehicle and pedestrian detection model to perform target recognition on the validation set and evaluate the detection effect of the model.
[0006] Furthermore, step (1) is specifically as follows: use LabelImg open source software to label vehicles and pedestrians in sequence, and the labeled content is the coordinates of the rectangular bounding boxes of vehicles and pedestrians, and store them for training and verification of the YOLOV5 model.
[0007] Furthermore, in step (2), all cross-stage partial network bottleneck modules C3 with three convolutional layers are replaced by fast cross-stage partial network bottleneck modules C3-Faster with three convolutional layers. Specifically, the fast cross-stage partial network bottleneck module C3-Faster with three convolutional layers is used to improve the computational efficiency and speed of the model. It is based on the fast network FasterNet, and the bottleneck Bottleneck in the original cross-stage partial network bottleneck module C3 with three convolutional layers is replaced by the fast network block FasterNetBlock. The fast network block FasterNetBlock includes 1 partial convolution and two 1×1 convolutions, forming an inverted residual architecture.
[0008] Furthermore, in step (2), the GSConv module is used to transform the original Neck layer as follows: the group space convolution module GSConv module is used to reduce the amount of calculation and the amount of parameters, making the training and reasoning process of the model faster; wherein, the group space convolution module GSConv is used to replace the convolution module of the neck network, and the cross-stage partial network module VoV GSCSP is constructed based on the group space convolution module GSConv, replacing the cross-stage partial network bottleneck module C3 with three convolution layers in the neck network layer.
[0009] Furthermore, in step (2), an effective channel attention mechanism (ECA) is added to the 10th layer of the backbone network as follows: the effective channel attention mechanism ECA is used to enhance the feature extraction capability; weights are assigned to each channel by introducing a one-dimensional convolution layer; the global information of each channel is aggregated by pooling the global average of the feature map; a fast one-dimensional convolution operation of size K is applied to each input channel; and the convolution result is converted into a weight value ranging from 0 to 1 by a sigmoid function.
[0010] Furthermore, the formula of step (3) is as follows: ; Among them, S i represents the confidence score of the candidate box; σ is the adjustment factor, M is the predicted box with the highest confidence, and b i is the prediction box, N t is the threshold set by NMS, and D is the set of optimal boxes; D iou The expression is: ; Among them, IOU is the intersection-over-union ratio of the predicted box and the real box, b gt and b represent the center points of the predicted box and the real box respectively, ρ represents the Euclidean distance between the two center points, and c represents the diagonal length of the minimum enclosing rectangle that contains both the predicted box and the real box.
[0011] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: the present invention replaces all C3 modules in the Backbone feature extraction network of YOLOV5 with C3-Faster modules, effectively reducing the complexity of the backbone network layer; introduces the GSConv module to reduce the computational complexity and complexity of the Neck layer; introduces the ECA attention mechanism to enhance the expressiveness of network learning features; TDIOU-NMS is used to optimize redundant candidate prediction boxes, which enhances the robustness against occluded vehicles and pedestrian targets. The optimized neural network model has higher confidence and detection speed, and can accurately identify vehicles and pedestrians captured by camera videos in real time. In addition, the model occupies less memory, has high accuracy and high speed, and meets the real-time detection requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is the overall flow chart of the present invention; Figure 2 This is a test comparison diagram of the present invention. DETAILED DESCRIPTION
[0013] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0014] like Figure 1 As shown, an embodiment of the present invention provides a bus stop scene vehicle pedestrian detection method based on improved YOLOV5, comprising the following steps: (1) Install cameras at bus stops, collect video data, and construct a data set. The details are as follows: Use LabelImg open source software to label vehicles and pedestrians in sequence. The labeled content is the coordinates of the rectangular bounding boxes of vehicles and pedestrians, and store them for training and verification of the YOLOV5 model.
[0015] (2) Based on the YOLOV5 framework, the network is reconstructed to obtain a lightweight network model, that is, the cross-stage partial network bottleneck module C3 with three convolutional layers in the YOLOV5 backbone network is completely replaced with a fast cross-stage partial network bottleneck module C3-Faster with three convolutional layers; the group space convolution module GSConv module is used to transform the original neck network Neck layer; the effective channel attention mechanism ECA is added to the 10th layer of the backbone network; among them, The cross-stage partial network bottleneck module C3 with three convolutional layers is completely replaced by the fast cross-stage partial network bottleneck module C3-Faster with three convolutional layers. The details are as follows: The fast cross-stage partial network bottleneck module C3-Faster with three convolutional layers is used to improve the computational efficiency and speed of the model; it is based on the fast network FasterNet, and the bottleneck Bottleneck in the original cross-stage partial network bottleneck module C3 with three convolutional layers is replaced by the fast network block FasterNetBlock; the fast network block FasterNetBlock includes 1 partial convolution and two 1×1 convolutions, forming an inverted residual architecture.
[0016] The specific steps of using the GSConv module to transform the original Neck layer are as follows: the group space convolution module GSConv is used to reduce the amount of calculation and parameters, making the training and reasoning processes of the model faster; among them, the group space convolution module GSConv is used to replace the convolution module of the neck network, and the cross-level partial network module VoV GSCSP is constructed based on the group space convolution module GSConv, replacing the cross-stage partial network bottleneck module C3 with three convolution layers in the neck network layer.
[0017] The effective channel attention mechanism (ECA) is added to the 10th layer of the backbone network as follows: the effective channel attention mechanism ECA is used to enhance the ability of feature extraction; weights are assigned to each channel by introducing a one-dimensional convolution layer; the global information of each channel is aggregated by pooling the global average of the feature map; a fast one-dimensional convolution operation of size K is applied to each input channel; the convolution result is converted into a weight value ranging from 0 to 1 through the sigmoid function.
[0018] (3) The improved distance intersection-over-union non-maximum suppression algorithm TDIOU-NMS is used to optimize the redundant candidate prediction boxes; the formula is as follows: ; Among them, S i represents the confidence score of the candidate box; σ is the adjustment factor, M is the predicted box with the highest confidence, and b i is the prediction box, N t is the threshold set by NMS, and D is the set of optimal boxes; D iou The expression is: ; Among them, IOU is the intersection-over-union ratio of the predicted box and the real box, b gtand b represent the center points of the predicted box and the real box respectively, ρ represents the Euclidean distance between the two center points, and c represents the diagonal length of the minimum enclosing rectangle that contains both the predicted box and the real box.
[0019] (4) Train the improved YOLOV5 bus stop scene vehicle and pedestrian detection model; the details are as follows: use the Pytorch deep learning framework for network deployment, based on the Linux operating system, written in Python, the CPU is an Intel Core i9-12900KF processor, the GPU is an NVIDIA GTX3090Ti, the memory size is 64G, use PyTorch1.10.0 version, and CUDA 11.1 for GPU acceleration. Training parameter settings: model training input image input image size is 640×640, batchsize is 16, training epoch is 300, IOU threshold is 0.5, and initial learning rate is 0.01.
[0020] (5) The trained improved YOLOV5 bus stop scene vehicle and pedestrian detection model is used to identify targets on the validation set, and the detection effect of the model is evaluated. Specifically: The average precision AP (Average precision) and the mean of the average precision mAP are used to evaluate the detection effect and performance of the model. Among them, AP is the area under the recall rate Recall and precision rate Precision curve Precision (Precision, P): It indicates the proportion of the number of correct targets detected by the model to the total number of targets, reflecting the accuracy of the model in target detection. The formula is as follows: ; Recall: The recall rate indicates the ratio of the number of targets detected by the model to the total number of targets, reflecting the completeness of the model recognition. The formula is as follows: ; ; ; Among them, TP is the number of correct detections; FP is the number of false detections; TP+FP represents the set of true boxes; FN means that the correct object is detected as a false object; TP+FN is all the labeled true samples; AP is the area under the recall and precision curves, K is the total number of categories, AP i is the AP value of the i-th class.
[0021] The training results are as follows Figure 2As shown, training / positioning loss: during training, the error between the predicted box and the standard box, the smaller the error, the more accurate the positioning. Training / confidence loss: during training, the average value of target detection loss, the smaller the ability to determine the target, the more accurate. Training / classification loss: during training, calculate whether the anchor box and the corresponding calibration classification are correct, the smaller the classification, the more accurate. Indicator / accuracy: indicates the proportion of samples that are truly positive in the samples identified as positive by the model. Indicator / recall: indicates the ratio of the number of samples correctly identified as positive by the model to the total number of positive samples. Verification / positioning loss: during verification, the error between the predicted box and the standard box, the smaller the error, the more accurate the positioning. Verification / confidence loss: during verification, the average value of target detection loss, the smaller the ability to determine the target, the more accurate. Verification / classification loss: during verification, calculate whether the anchor box and the corresponding calibration classification are correct, the smaller the classification, the more accurate. Indicator / 0.5 average precision: the average average precision when the threshold is greater than 0.5. Metrics / 0.5-0.95 Average Precision: The average precision at different thresholds (from 0.5 to 0.95, step size 0.05). The results show that the recognition accuracy of vehicles and pedestrians reaches 90.8%, which is 2.6% higher than the recognition accuracy of the original YOLOV5 model of 88.2%.
[0022] The collection and acquisition of various data in this invention complies with relevant laws and regulations and is authorized by the data provider. Any organization or individual that needs to obtain external data shall obtain authorization and ensure data security in accordance with the law, and shall not illegally collect, use, process, or transmit unauthorized or unprotected data, or illegally buy, sell, provide, or disclose unauthorized or unprotected data.
Claims
1. A vehicle and pedestrian detection method for bus stop scenes based on improved YOLOV5, characterized in that: The following steps are involved: S1 installs cameras at bus stops, collects video data, and builds a data set; S2 is based on the YOLOV5 framework and reconstructs the network to obtain a lightweight network model, that is, the cross-stage partial network bottleneck module C3 with three convolutional layers in the YOLOV5 backbone network is completely replaced with a fast cross-stage partial network bottleneck module C3-Faster with three convolutional layers; the group space convolution module GSConv module is used to transform the original neck network Neck layer; the effective channel attention mechanism ECA is added to the 10th layer of the backbone network; S3 uses the improved distance intersection-over-union non-maximum suppression algorithm TDIOU-NMS to optimize redundant candidate prediction boxes; The improved YOLOV5 bus stop scene vehicle and pedestrian detection model built by S4 training; S5 uses the trained improved YOLOV5 bus stop scene vehicle and pedestrian detection model to perform target recognition on the validation set and evaluate the detection effect of the model.
2. According to claim 1, a bus stop scene vehicle and pedestrian detection method based on improved YOLOV5 is characterized in that: Step S1 is as follows: Use LabelImg open source software to label vehicles and pedestrians in sequence. The labeled content is the coordinates of the rectangular bounding boxes of vehicles and pedestrians, and store them for training and verification of the YOLOV5 model.
3. According to claim 1, a bus stop scene vehicle and pedestrian detection method based on improved YOLOV5 is characterized in that: In step S2, all cross-stage partial network bottleneck modules C3 with three convolutional layers are replaced by fast cross-stage partial network bottleneck modules C3-Faster with three convolutional layers. Specifically, based on the fast network FasterNet, the bottleneck Bottleneck in the original cross-stage partial network bottleneck module C3 with three convolutional layers is replaced by the fast network block FasterNetBlock; the fast network block FasterNetBlock includes 1 partial convolution and two 1×1 convolutions, forming an inverted residual architecture.
4. According to claim 1, a bus stop scene vehicle and pedestrian detection method based on improved YOLOV5 is characterized in that: In step S2, the GSConv module is used to transform the original Neck layer as follows: the group space convolution module GSConv is used to replace the convolution module of the neck network, and a cross-stage partial network module VoVGSCSP is constructed based on the group space convolution module GSConv to replace the cross-stage partial network bottleneck module C3 with three convolution layers in the neck network layer.
5. According to claim 1, a bus stop scene vehicle and pedestrian detection method based on improved YOLOV5 is characterized in that: In step S2, an effective channel attention mechanism ECA is added to the 10th layer of the backbone network as follows: the effective channel attention mechanism ECA is used to enhance the ability of feature extraction; weights are assigned to each channel by introducing a one-dimensional convolution layer; the global information of each channel is aggregated by pooling the global average of the feature map; a fast one-dimensional convolution operation of size K is applied to each input channel; and the convolution result is converted into a weight value ranging from 0 to 1 through the sigmoid function.
6. According to claim 1, a bus stop scene vehicle and pedestrian detection method based on improved YOLOV5 is characterized in that: The formula for step S3 is as follows: ; Among them, S i represents the confidence score of the candidate box; σ is the adjustment factor, M is the predicted box with the highest confidence, and b i is the prediction box, N t is the threshold set by NMS, and D is the set of optimal boxes; D iou The expression is: ; Among them, IOU is the intersection-over-union ratio of the predicted box and the real box, b gt and b represent the center points of the predicted box and the real box respectively, ρ represents the Euclidean distance between the two center points, and c represents the diagonal length of the minimum enclosing rectangle that contains both the predicted box and the real box.
Citation Information
Patent Citations
Improved lane line type identification method of YOLOv5s network model
CN116630920A
Traffic target identification method based on improved YOLOv8 model
CN117237915A
Small target traffic sign real-time detection method based on improved YOLOv5s
CN117333845A
Image optimization method and optimization system based on YOLOv5 network model
CN117744745A
