Target detection method, device and equipment based on improved YOLOV5 algorithm and medium
By improving the data annotation and modular feature extraction and enhancement of the YOLOV5 algorithm, the difficulty of detection of targets at different scales in pedestrian detection is solved, and efficient and accurate pedestrian detection is achieved, which is suitable for intelligent traffic and autonomous driving.
Patent Information
- Application Number
- CN202510481121.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-07-29
AI Technical Summary
The existing YOLOV5 algorithm is difficult to effectively detect pedestrian targets of different scales, especially small targets, in pedestrian detection, and the detection efficiency is low, which cannot meet the real-time needs of intelligent transportation and autonomous driving.
By annotating the image data, a VOC data set is generated, and the improved YOLOV5 algorithm is used for training, combining the backbone, neck and head modules for feature extraction and enhancement, using custom loss functions for classification, generating anchor boxes of different scales, and filtering the anchor boxes to determine the final detection box location.
It significantly improves the accuracy and efficiency of pedestrian detection, especially the robustness of detection for small targets, and achieves high-precision and real-time pedestrian detection to meet the needs of autonomous driving systems.
Smart Images

Figure CN120388352A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision, and particularly to a pedestrian detection method, device, equipment and medium based on an improved YOLOV5 algorithm. Background Art
[0002] In recent years, the incidence rate of traffic accidents remains high. In terms of personnel identification, especially in traffic safety, it will have very important research significance to conduct research on pedestrian detection in complex pedestrian scenarios.
[0003] Object detection technology is one of the three major tasks in the field of computer vision, and this task aims to identify the types and positions of objects in images.
[0004] In recent years, with the development of deep learning and artificial intelligence, more and more people apply them to various fields. The application scenarios in fields such as autonomous driving are complex and changeable, so using deep learning methods will achieve incredibly excellent results. At the same time, this detection method can be applied to video surveillance. With the popularization and iterative update of the surveillance system, the crime rate in recent years has been greatly reduced compared with that at the beginning of the 21st century. As a single-class detection method, the pedestrian detection method can be easily nested into the field of video surveillance, so as to achieve more accurate positioning of information such as the identity of people.
[0005] However, although YOLOv5 performs well in object detection tasks, there are still some challenges in the specific scenario of pedestrian detection:
[0006] In pedestrian detection, small objects (such as pedestrians in the distance) are often difficult to be accurately detected because they occupy fewer pixels in the image and the feature information is not obvious. It can be seen that pedestrian objects may show different scales in the image, which increases the difficulty of detection.
[0007] In applications such as intelligent transportation and autonomous driving, pedestrian detection needs to be completed quickly and accurately in real-time video streams, which puts higher requirements on the efficiency of the algorithm. Summary of the Invention
[0008] The purpose of this application is to provide a target detection method, device, equipment and medium based on an improved YOLOV5 algorithm to solve the problems of great difficulty in detecting pedestrian targets with different scales in images and low detection efficiency.
[0009] To achieve the above purpose, this application provides the following solutions:
[0010] In the first aspect, this application provides a target detection method based on an improved YOLOV5 algorithm, including:
[0011] Annotate the image data to obtain a VOC dataset; the VOC dataset includes a training set;
[0012] Train the YOLOV5 algorithm according to the training set to obtain a convolutional neural network model;
[0013] Extract features of the image in the convolutional neural network model according to the backbone module;
[0014] Based on the neck module, enhance the extracted features according to the attention module, and classify the detected objects according to a custom loss function to determine the object classification result;
[0015] Output the object classification result according to the head module and determine the corrected anchor boxes at different scales;
[0016] Filter the anchor boxes to determine the output detection boxes;
[0017] Determine the position of the object on the image according to the output detection boxes.
[0018] Optionally, annotate the pedestrians in the image data and format the image data into the VOC dataset format to obtain a VOC dataset;
[0019] Divide the VOC dataset into a training set, a validation set, and a test set according to a ratio.
[0020] Optionally, set the hyperparameters and pre-trained weight parameters during the training of the YOLOV5 algorithm, and train the YOLOV5 algorithm according to the training set to obtain an improved YOLOV5 algorithm; the improved YOLOV5 algorithm is a convolutional neural network model.
[0021] Optionally, normalize the image in the convolutional neural network model and scale the normalized image;
[0022] Perform interval slicing, residual operations, and BN operations on the scaled image according to the backbone module to obtain feature maps of different scales;
[0023] Extract features of the image in the convolutional neural network model based on the feature maps of different scales.
[0024] Optionally, enhance the features of pedestrians in object detection according to the attention module;
[0025] Based on a custom loss function, highlight the positive samples of pedestrians and weaken the negative samples of pedestrians; the positive samples are the image regions that include pedestrians and the positions of pedestrians are annotated; the negative samples refer to the image regions that do not include pedestrians or include the background.
[0026] Optionally, feature fusion is performed based on the feature maps of different scales to determine a new feature map;
[0027] Generate anchor boxes of different scales based on the new feature map;
[0028] Perform position correction on the anchor boxes according to the convolution operation, and classify the objects within the anchor boxes to determine the classification results.
[0029] Optionally, among the multiple anchor boxes obtained by the detector, calculate all class scores corresponding to each anchor box, and select the class with the highest score as the class detected by the anchor box;
[0030] Based on the class, determine the position of the image in the anchor box according to the anchor box; the anchor box includes the center coordinates of the anchor box, the width of the anchor box, and the height of the anchor box;
[0031] Filter the anchor box based on the position of the image in the anchor box to determine the output detection box;
[0032] Determine the position of the pedestrian on the anchor box according to the output detection box to complete the detection of the pedestrian.
[0033] In a second aspect, the present application provides a pedestrian detection device based on an improved YOLOV5 algorithm, including:
[0034] A VOC dataset determination module for annotating image data to obtain a VOC dataset; the VOC dataset includes a training set;
[0035] A convolutional neural network model determination module for training the YOLOV5 algorithm according to the training set to obtain a convolutional neural network model;
[0036] A feature extraction module for extracting features of the image in the convolutional neural network model according to the backbone module;
[0037] A classification module for target detection, which is used to enhance the extracted features based on the neck module according to the attention module, and classify the detected targets according to a custom loss function to determine the target classification results;
[0038] An anchor box determination module for outputting the target classification results according to the head module and determining the corrected anchor boxes at different scales;
[0039] An output detection box determination module for filtering the anchor box to determine the output detection box;
[0040] A target position determination module, configured to determine the position of a target on the image according to the output detection box.
[0041] In a third aspect, the present application provides a computer device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement the steps of the target detection method based on the improved YOLOV5 algorithm described in any one of the above.
[0042] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the target detection method based on the improved YOLOV5 algorithm described in any one of the above are implemented.
[0043] According to the specific embodiments provided by the present application, the present application has the following technical effects:
[0044] The present application provides a target detection method, device, device and medium based on an improved YOLOV5 algorithm. By annotating image data, a VOC data set is obtained; the YOLOV5 algorithm is trained according to the training set to obtain a convolutional neural network model; according to the backbone module, features of the image in the convolutional neural network model are extracted; based on the neck module, the extracted features are enhanced according to the attention module, and the detected targets are classified according to a custom loss function to determine the target classification result. The attention module significantly improves the detection accuracy and efficiency by dynamically focusing on key features, and reduces the detection difficulty of pedestrian targets with different scales in the image; the target classification result is output according to the head module, and the corrected anchor boxes at different scales are determined; the image in the convolutional neural network model is normalized and scaled, and the detection robustness of small pedestrians is enhanced through image scaling; the anchor boxes are filtered to determine the output detection box; the position of the target on the image is determined according to the output detection box, and the pedestrian detection task is quickly and accurately completed. The pedestrians are detected according to the YOLOV5 algorithm, which improves the efficiency of pedestrian detection. Description of the Drawings
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to these drawings.
[0046] Figure 1 It is a schematic flowchart of a target detection method based on an improved YOLOV5 algorithm in an embodiment of the present application.
[0047] Figure 2 Schematic diagram of the pedestrian detection process provided by an embodiment of the present application.
[0048] Figure 3 Schematic diagram of the network structure of the YOLOV5 algorithm provided by an embodiment of the present application.
[0049] Figure 4 Schematic diagram of the actual test effect provided by an embodiment of the present application.
[0050] Figure 5 Schematic diagram of the actual test effect provided by an embodiment of the present application.
[0051] Figure 6 Schematic diagram of the actual test effect provided by an embodiment of the present application.
[0052] Figure 7 Schematic diagram of the actual test effect provided by an embodiment of the present application.
[0053] Figure 8 Schematic diagram of the structure of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0054] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0055] To make the above objects, features, and advantages of the present application more obvious and understandable, the present application will be further described in detail below with reference to the accompanying drawings and specific implementation manners.
[0056] The present application proposes a pedestrian detection method based on an improved YOLOV5 algorithm. Instead of using the traditional lidar ranging method for detection, this method adopts the improved YOLOV5 algorithm related to deep learning. This algorithm has the advantages of high detection accuracy and strong real-time performance. After being combined with the autonomous driving system, it can judge the distance of pedestrians in the street view, and give recognition and positioning, realizing a high degree of unmanned intelligence. In actual detection, the accuracy of pedestrians reaches 70.9% mAP, the processing speed is 0.02 s / image, and the missed detection rate is only 16.8%, with excellent results.
[0057] In view of the current complex traffic conditions, an improved YOLOV5 algorithm based on convolutional neural network can be used for detection. At the same time, this method can be applied to autonomous driving. The autonomous driving system feeds back the position of pedestrians through real-time images and transmits it to the backend for processing, so as to make a series of operations such as steering and avoiding, braking or accelerating, and no one needs to intervene manually throughout the process. The combination of pedestrian detection technology and autonomous driving realizes a high degree of unmanned and intelligent, and at the same time has high accuracy and good real-time performance in detecting pedestrians.
[0058] As Figure 1 shown, the embodiment of the present application provides a target detection method based on an improved YOLOV5 algorithm, and the specific steps are as follows.
[0059] S1: Label the image data to obtain a VOC dataset; the VOC dataset includes a training set.
[0060] S2: Train the YOLOV5 algorithm according to the training set to obtain a convolutional neural network model.
[0061] S3: Extract features of the image in the convolutional neural network model according to the backbone module.
[0062] S4: Based on the neck module, enhance the extracted features according to the attention module, and classify the detected targets according to the custom loss function to determine the target classification result.
[0063] S5: Output the target classification result according to the head module and determine the corrected anchor boxes at different scales.
[0064] S6: Filter the anchor boxes to determine the output detection boxes.
[0065] S7: Determine the position of the target on the image according to the output detection box.
[0066] Further, in an exemplary embodiment, S1 can be replaced by the following steps.
[0067] S101: Label the pedestrians in the image data and make the image data into the VOC dataset format to obtain a VOC dataset.
[0068] Collect the image data required for training and testing the YOLOV5 algorithm. Screen and fuse through the open-source traffic pedestrian dataset to generate the required image data;
[0069] Label the pedestrians in the image data and make the image data into the VOC dataset format required by the YOLOV5 algorithm to obtain a VOC pedestrian dataset.
[0070] S102: Divide the VOC dataset into a training set, a validation set, and a test set according to a ratio.
[0071] Common datasets for pedestrian detection are Citypersons, CrowdHuman, and CalTech. Since there are fewer pedestrian instances in CalTech, data screening is performed using CrowdHuman and Citypersons at a ratio of 7:3. Among them, the batch selected from the CrowdHuman dataset contains 6,000 images, and 2,491 images are selected from the Citypersons dataset, totaling 8,491 images to form a new dataset. Then, the training set, validation set, and test set are randomly divided according to a ratio of 3:1:1. Since the focus is on pedestrians, there is only one category during annotation: Pedestrain. Finally, 5,095 images are used for training, 1,700 images are used for testing, and 1,696 images are used for validation. The basis for this division is that most of the images in CrowdHuman are crawled from the network, and there are significant differences between the images, so more images are needed to support the data.
[0072] Further, in an exemplary embodiment, S2 can be replaced by the following steps.
[0073] Set the hyperparameters and pre-trained weight parameters during the training process of the YOLOV5 algorithm. Among them, hyperparameters: learning rate 0.001, number of iterations 300 times, batch_size is set to 64, stochastic gradient descent is adopted, the momentum parameter momentum is set to 0.937, the weight decay is set to 0.0005, and the initial size of the input image is 512×512; pre-trained weight parameters: The pre-trained basic network uses the darknet53 network, and the dataset is trained based on the Imagenet dataset to obtain the initial weights.
[0074] Train the YOLOV5 algorithm according to the training set to obtain an improved YOLOV5 algorithm; the improved YOLOV5 algorithm is a convolutional neural network model.
[0075] Set the hyperparameters and pre-trained weight parameters of the network during the training process, optimize the attention module and loss function module in the model, and train the training set through the YOLOV5 algorithm to obtain the trained model and weight file, that is, the model and weight file of the convolutional neural network corresponding to the YOLOV5 algorithm.
[0076] Further, in an exemplary embodiment, as Figure 2 shown, S3 can be replaced by the following steps.
[0077] S301: Normalize the images in the convolutional neural network model and scale the normalized images.
[0078] S302: Perform interval slicing, residual operations, and BN operations on the scaled images according to the backbone module to obtain feature maps of different scales.
[0079] S303: Extract features from the images in the convolutional neural network model based on the feature maps of different scales.
[0080] Based on the trained model, the forward propagation of the CNN is then performed to achieve the detection function. The overall detection process is as follows. The detection process of the YOLOV5 algorithm for pedestrians is divided into the backbone part, the neck part, and the head part. As Figure 3 shown, it is a rough network structure diagram of the YOLOV5 algorithm. First, the image is normalized to 416×416. After calculating the scaling ratio, the size of the image with another resolution is obtained and sent to the backbone part of the YOLOV5 network. The backbone part is the remaining part of the darknet53 basic network after removing the last global average pooling layer, fully connected layer, and softmax classification layer. Then, it undergoes interval slicing through a unique Focus mechanism, and then a series of operations such as residual and BN are performed through the structures of CSP_1 and CSP_2 to obtain three feature maps of different scales (taking YOLOV5s as an example here), which are 76×76×64, 38×38×256, and 19×19×1024 in size according to the pixel length, pixel width, and number of channels. Here, the pixel length represents the number of pixels in the horizontal direction, the pixel width represents the number of pixels in the vertical direction, and the number of channels represents the number of channel layers that make up the current feature.
[0081] Furthermore, in an exemplary embodiment, S4 can be replaced by the following steps.
[0082] S401: Enhance the features of pedestrians in object detection according to the attention module.
[0083] S402: Based on the custom loss function, highlight the positive samples of pedestrians and weaken the negative samples of pedestrians; the positive samples are the image regions that include pedestrians and the positions of pedestrians are annotated; the negative samples refer to the image regions that do not include pedestrians or include the background.
[0084] The subsequent operation is the neck part of the YOLOV5 algorithm. Different from the neck parts of previous YOLO series, it draws on the CSPnet network architecture and replaces the previous ordinary convolution operation in the way of passing through the CSP2 module (CSP2 is a combination of CBL, upsampling, and concat modules, excluding other forms of feature enhancement). Subsequently, it passes through the improved attention SEAttention module (SEAttention is an attention module composed of network structures such as ReLu, residual, and BN) to achieve feature enhancement for the category of pedestrians. During the forward propagation process, the loss plays a role in driving the detector to learn. In the improved YOLOV5 model, VariFocalLoss is used instead of the original unchanged Loss. Due to the particularity of pedestrian detection, while highlighting the positive samples of pedestrians, the negative samples are weakened to a certain extent, which plays a crucial role in improving the recall rate and reducing the missed detection situation. In object detection, positive and negative samples are used to train the classifier to determine whether a certain area contains pedestrians, thereby helping the model effectively distinguish pedestrians from the background, which can help complete the classification of the detection target and determine the target classification result. In the Neck part of the model, the designed nested SEAttention is composed of multiple modules and plays a role in enhancing at the feature level. The generated fixed-scale feature map becomes a multi-channel tensor after global average pooling (GAP). Compared with the simple method of vector tiling, it can macroscopically suppress overfitting and make the input size more flexible. Subsequently, the obtained tensor undergoes a dimensionality reduction operation through a 1×1 convolution, and then the features are input into Sigmoid for normalization and combined with the residual network model. The original features and the processed features are directly added at the pixel level to obtain the final enhanced feature map.
[0085] Further, in an exemplary embodiment, S5 can be replaced by the following steps.
[0086] S501: Perform feature fusion based on the feature maps of different scales to determine a new feature map.
[0087] The normalized feature map with a size of 608×608×16 is reduced by half in scale after two 3×3 convolutions. At this time, the feature scale is 304×304×64. Subsequently, after passing through 1 residual module (1×1 convolution + 3×3 convolution + residual), the scale remains unchanged, still 304×304×64. Then, after a 3×3 convolution, the scale is reduced by half and the number of channels is doubled, resulting in a feature map of 152×152×128. Subsequently, after two residual modules and a 3×3 convolution, a feature map of 76×76×256 is obtained. After passing through 8 residual modules, it remains a feature map of 76×76×256. This is the largest-scale feature map participating in the concatenate fusion subsequently, with the smallest receptive field and responsible for detecting small targets. Subsequently, after a 3×3 convolution and 8 residual modules, a medium-scale feature map of 38×38×512 is obtained, with a medium-sized receptive field and responsible for detecting medium-sized targets. After that, after a 3×3 convolution and 4 residual modules, a smallest-scale feature map of 19×19×1024 is obtained, with the largest receptive field and responsible for detecting large targets.
[0088] S502: Generate anchor boxes of different scales based on the new feature map.
[0089] The subsequent operation is the head part of the YOLOV5 algorithm. Three different-scale anchor boxes (anchor) are initially generated on the small-scale 19×19×1024 feature map, with sizes {(116×90), (156×198), (373×326)} respectively, and the number is 19×19. Subsequently, through a series of 1×1 convolutions and 3×3 convolutions, the positions of the anchor boxes (anchor) are corrected and the pedestrians or backgrounds contained in the boxes are classified, outputting a tensor data of 19×19×24, which includes the pedestrian class scores, confidence scores, center coordinates and width and height of the corrected pedestrian detection box predictions at the smallest scale.
[0090] S503: Correct the positions of the anchor boxes according to the convolution operation, classify the targets within the anchor boxes, and determine the classification results.
[0091] The subsequent operation is the neck part of the YOLOV5 algorithm. Different from the neck parts of previous YOLO series, it draws on the CSPnet network architecture and replaces the previous ordinary convolution operation in the way of passing through the CSP2 module (CSP2 is a combination of CBL, upsampling, and concat modules, excluding other forms of feature enhancement). Subsequently, it passes through the improved attention SEAttention module (SEAttention is an attention module composed of network structures such as ReLu, residual, and BN) to achieve feature enhancement for the category of pedestrians. During the forward propagation process, the loss plays a role in driving the detector to learn. In the improved YOLOV5 model, VariFocalLoss is used instead of the original unchanged Loss. Due to the particularity of pedestrian detection, while highlighting the positive samples of pedestrians, the negative samples are weakened to a certain extent, which plays a crucial role in improving the recall rate and reducing the missed detection situation.
[0092] The 19×19×1024 feature map of the small scale is subjected to a series of 1×1 convolutions, 3×3 convolutions, and upsampling to obtain a 38×38×256 feature map. Subsequently, the feature map of this scale and the medium-scale 38×38×512 feature map obtained from the backbone part are fused by the concatenate method (here, concatenate is to simply splice the pixel ranges) to obtain a 38×38×768 feature map. Then, three different-scale anchor boxes (anchor) are initially generated on the 38×38×768 feature map, with sizes of {(30×61), (62×45), (59×119)}, and the number is 38×38. Similar to the processing method of the small scale, through a series of 1×1 convolutions and 3×3 convolutions, the positions of the anchor boxes (anchor) are corrected and the objects contained in the boxes are classified, and a 38×38×24 tensor data is output, which contains the scores of each category, confidence scores, center coordinates, and width and height of the boxes predicted and corrected under the medium scale. Subsequently, the same operation is performed on the 38×38×768 feature map to obtain a 76×76×384 feature map, and anchor boxes (anchor) of {(10×13), (16×30), (33×23)} are initially generated on it, with the number of 76×76. Then, through a series of 1×1 convolutions and 3×3 convolutions, the positions of the anchor boxes (anchor) are corrected and the objects contained in the boxes are classified, and a 76×76×24 tensor data is output, which contains the scores of each category, confidence scores, center coordinates, and width and height of the boxes corresponding to the corrected boxes under the largest scale.
[0093] Furthermore, in an exemplary embodiment, S6 can be replaced by the following steps.
[0094] S601: Among the multiple anchor boxes obtained by the detector, calculate all class scores corresponding to each anchor box, and select the class with the highest score as the class detected by the anchor box.
[0095] S602: Based on the class, determine the position of the image in the anchor box according to the anchor box; the anchor box includes the center coordinates of the anchor box, the width of the anchor box, and the height of the anchor box.
[0096] S603: Based on the position of the image in the anchor box, filter the anchor box to determine the output detection box.
[0097] S604: Determine the position of the pedestrian on the anchor box according to the output detection box to complete the detection of the pedestrian.
[0098] Through the above operations, corrected boxes at three different scales can be obtained. For each corrected box, the one with the highest class score is the class detected by the box (for example, in the feedback of a pedestrian instance, there are 0.96, 0.8, and 0.2 at the same time, and the detection box with the highest score will be fed back as the output of the pedestrian instance). According to the center coordinates and width and height, the specific position of the box on the original image can be obtained. Subsequently, a threshold of 0.45 is set according to the confidence score, and those boxes with a confidence score lower than 0.45 are excluded as the first filtering.
[0099] Perform non-maximum suppression (NMS) secondary filtering on the boxes obtained from the first screening to obtain the final output detection box, which contains the detected pedestrians and the class name Pedestrain set for the pedestrians; perform performance evaluation on all the pictures in the test set, and calculate the mAP (reflecting the target detection accuracy) to be 70.9%, and the FPS (reflecting the target detection speed) is 0.02 s / picture, and the MissRate (miss detection rate) is 16.8%. It has high accuracy and fully meets the real-time requirements.
[0100] The calculation process for the evaluation metrics mAP and MissRate is as follows:
[0101] (1) Calculate the intersection over union (IOU) of the area of the box predicted by the YOLO algorithm and the actual box. The larger the IOU, the more fitting the predicted box is to the actual box. An IOU greater than the threshold of 0.45 represents a correct prediction. The specific formula is as follows:
[0102]
[0103] Among them, Area of Overlap represents the area of the intersection region between the predicted bounding box and the actual bounding box; Area of Union represents the area of the union region between the detected bounding box and the actual bounding box.
[0104] (2) In object detection, to calculate the precision of a certain class C in an image, the specific formula is as follows:
[0105]
[0106] Among them, N(TruePositions) C represents the number of correctly predicted class C in an image; N(TotalObjects) C represents the actual number of objects belonging to class C in an image; Precesion C represents the precision of class C in an image;
[0107] (3) Similarly, in object detection, to calculate the average precision of all images of class C in the test set, the specific formula is as follows:
[0108]
[0109] Among them, ΣPrecesion C represents the sum of the precisions of class C in all images of the test set; N(Total images) C represents the number of images containing class C in the test set; AveragePrecesion C represents the average precision of class C.
[0110] (4) To calculate mAP, the specific formula is as follows:
[0111]
[0112] Among them, ΣAveragePrecesion represents the sum of the average precisions of all classes in the test set; N(classes) represents the total number of classes in the test set; MeanAveragePrecesion represents mAP, that is, the mean average precision.
[0113] (5) To calculate MissRate (false negative rate), the specific formula is as follows:
[0114]
[0115] Among them, FN represents the case where the predicted result is a negative sample but the prediction is incorrect, that is, the background is regarded as a pedestrian; GT represents the GroundTruth, indicating the only one true annotation result of a sample in the picture; Recall represents the recall rate, indicating the ratio of the pedestrians marked in the picture that are detected.
[0116] Through the calculation of the above mAP evaluation index, the precision and the missed detection rate in the pedestrian detection dataset are obtained as follows: the detection precision reaches: 70.9%, and the missed detection rate reaches: 16.8%. The precision is very high and the missed detection rate is very low. The test effects in actual different scenarios are as Figure 4 、 Figure 5 、 Figure 6 and Figure 7 shown.
[0117] In an exemplary embodiment, the embodiment of the present application provides a pedestrian detection device based on an improved YOLOV5 algorithm, and the specific modules are described as follows.
[0118] The VOC dataset determination module is used to annotate the image data to obtain the VOC dataset; the VOC dataset includes the training set.
[0119] The convolutional neural network model determination module is used to train the YOLOV5 algorithm according to the training set to obtain a convolutional neural network model.
[0120] The feature extraction module is used to extract features of the image in the convolutional neural network model according to the backbone module.
[0121] The classification module for target detection is used to enhance the extracted features based on the neck module according to the attention module, and classify the detected targets according to the custom loss function to determine the target classification result.
[0122] The anchor box determination module is used to output the target classification result according to the head module and determine the corrected anchor boxes at different scales.
[0123] The output detection box determination module is used to filter the anchor boxes to determine the output detection box.
[0124] The target position determination module is used to determine the position of the target on the image according to the output detection box.
[0125] In an exemplary embodiment, a computer device is provided. The computer device can be a server or a terminal, and its internal structure diagram can be as Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to detect targets based on the improved YOLOV5 algorithm. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, it implements a pedestrian detection method based on the improved YOLOV5 algorithm.
[0126] Those skilled in the art can understand that Figure 8 the structure shown in is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements. In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0127] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0128] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0129] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0130] The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0131] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0132] In this article, specific examples are used to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A target detection method based on an improved YOLOV5 algorithm, characterized in that: Including: Annotating the image data to obtain a VOC dataset; the VOC dataset includes a training set; Training the YOLOV5 algorithm according to the training set to obtain a convolutional neural network model; Extracting features of the image in the convolutional neural network model according to the backbone module; Based on the neck module, enhancing the extracted features according to the attention module, and classifying the detected targets according to a custom loss function to determine the target classification result; Outputting the target classification result according to the head module and determining the corrected anchor boxes at different scales; Filtering the anchor boxes to determine the output detection boxes; Determining the position of the target on the image according to the output detection boxes.
2. The pedestrian detection method based on the improved YOLOV5 algorithm according to claim 1, characterized in that Annotating the image data to obtain a VOC dataset, specifically including: Annotating pedestrians in the image data and making the image data into the VOC dataset format to obtain a VOC dataset; Dividing the VOC dataset into a training set, a validation set, and a test set according to a ratio.
3. The pedestrian detection method based on the improved YOLOV5 algorithm according to claim 1, characterized in that: Training the YOLOV5 algorithm according to the training set to obtain a convolutional neural network model, specifically including: Setting the hyperparameters and pre-training weight parameters during the training of the YOLOV5 algorithm, and training the YOLOV5 algorithm according to the training set to obtain an improved YOLOV5 algorithm; the improved YOLOV5 algorithm is a convolutional neural network model.
4. The pedestrian detection method based on the improved YOLOV5 algorithm according to claim 1, wherein, Extracting features of the image in the convolutional neural network model according to the backbone module, specifically including: Normalizing the image in the convolutional neural network model and scaling the normalized image; Performing interval slicing, residual operations, and BN operations on the scaled image according to the backbone module to obtain feature maps of different scales; Extracting features of the image in the convolutional neural network model based on the feature maps of different scales.
5. The pedestrian detection method based on the improved YOLOV5 algorithm according to claim 1, characterized in that, Based on the neck module, enhancing the extracted features according to the attention module, and classifying the detected targets according to a custom loss function to determine the target classification result, specifically including: Enhancing the features of pedestrians in target detection according to the attention module; Based on a custom loss function, highlighting the positive samples of pedestrians and weakening the negative samples of pedestrians; the positive samples are image regions including pedestrians and the marked positions of pedestrians; the negative samples refer to image regions not including pedestrians or including the background.
6. The pedestrian detection method based on the improved YOLOV5 algorithm according to claim 1, wherein Outputting the target classification result according to the head module and determining the corrected anchor boxes at different scales, specifically including: Performing feature fusion based on the feature maps of different scales to determine a new feature map; Generating anchor boxes of different scales based on the new feature map; Correcting the positions of the anchor boxes according to convolutional operations and classifying the targets within the anchor boxes to determine the classification result.
7. The pedestrian detection method based on the improved YOLOV5 algorithm according to claim 1, characterized in that, Filtering the anchor boxes to determine the output detection boxes, specifically including: Among the multiple anchor boxes obtained by the detector, calculating the scores of all categories corresponding to each anchor box, and selecting the category with the highest score as the category detected by the anchor box; Based on the category, determine the position of the image in the anchor box according to the anchor box; the anchor box includes the center coordinates of the anchor box, the width of the anchor box, and the height of the anchor box; Based on the position of the image in the anchor box, filter the anchor box to determine the output detection box; Determine the position of the pedestrian on the anchor box according to the output detection box to complete the detection of the pedestrian.
8. A pedestrian detection device based on an improved YOLOV5 algorithm, characterized in that: The pedestrian detection device based on the improved YOLOV5 algorithm includes: The VOC dataset determination module is used to annotate image data to obtain the VOC dataset; the VOC dataset includes a training set; The convolutional neural network model determination module is used to train the YOLOV5 algorithm according to the training set to obtain a convolutional neural network model; The feature extraction module is used to extract features of the image in the convolutional neural network model according to the backbone module; The classification module for target detection is used to enhance the extracted features based on the neck module according to the attention module, and classify the detected targets according to the custom loss function to determine the target classification result; The anchor box determination module is used to output the target classification result according to the head module and determine the corrected anchor boxes at different scales; The output detection box determination module is used to filter the anchor box to determine the output detection box; The target position determination module is used to determine the position of the target on the image according to the output detection box.
9. A computer device, comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the target detection method based on the improved YOLOV5 algorithm according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the target detection method based on the improved YOLOV5 algorithm according to any one of claims 1-7.