Target detection method, device, equipment and storage medium
By standardizing the foggy day images and data amplification, the improved YOLOv5 model is trained and verified to determine the optimal detection model, which solves the problem of low target detection accuracy in foggy days, and achieves higher detection accuracy and lower error detection rate.
Patent Information
- Application Number
- CN202111164524.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-09-30
AI Technical Summary
In foggy environments, existing deep learning-based object detection methods are prone to miss detection and misdetecting small target objects, resulting in low detection accuracy.
A target detection method is proposed, by acquiring the reference image, performing standardized processing and data amplification, and divided into training sets, verification sets and test sets. The improved YOLOv5 model is trained and verified, and the optimal detection model is determined to be used to detect the image to be detected.
This method can reduce scene error detection and miss detection rates and improve detection accuracy, especially in foggy environments, the detection effect of small target objects is significantly improved.
Smart Images

Figure CN113869248B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a target detection method, device, equipment and storage medium. Background Art
[0002] Foggy weather is one of the important branch scenes of vehicle and pedestrian detection. In rainy and foggy weather, the contrast of the pictures taken by the camera decreases and the recognizability is low. Objects in the distance are not easy to be detected and identified, which easily leads to a large number of missed and false detections, resulting in a decrease in detection effect. In actual environments, traffic accidents caused by low visibility account for a large proportion. Using target detection in foggy environments to accurately perceive traffic information ahead of the road is of great significance to reducing the incidence of traffic accidents and protecting drivers and passengers.
[0003] At present, deep learning-based detection methods are often used to achieve end-to-end target detection in vehicle and pedestrian detection. However, in foggy environments, it is easy to miss or misdetect small target objects, and the detection accuracy is low. Therefore, how to provide a convenient target detection method to reduce scene false detection and missed detection rates and improve detection accuracy has become an urgent problem to be solved. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a target detection method, which can reduce the scene false detection and missed detection rate and improve the detection accuracy.
[0005] The present invention also provides a target detection device.
[0006] The present invention also provides a target detection device.
[0007] The present invention also provides a computer-readable storage medium.
[0008] According to a first aspect of the present invention, a target detection method includes:
[0009] Acquire a reference image, wherein the reference image includes a foggy image;
[0010] Performing standardization processing on the foggy image to obtain a standard foggy image;
[0011] Dividing the standard foggy image into a training set, a validation set and a test set according to a preset ratio;
[0012] The improved YOLOv5 model is trained according to the training set to obtain a trained detection model, wherein the improved YOLOv5 model is a model obtained by improving the feature fusion layer on the basis of the original YOLOv5 model;
[0013] Verifying the detection model according to the verification set and the test set to determine the optimal detection model;
[0014] According to the optimal detection model, target detection is performed on the image to be detected to obtain vehicle data and pedestrian data.
[0015] The target detection method according to the embodiment of the present invention has at least the following beneficial effects: the target detection method obtains a reference image, and performs standardization processing on the foggy image included in the reference image to obtain a standard foggy image; divides the standard foggy image into a training set, a verification set, and a test set according to a preset ratio; trains the improved YOLOv5 model according to the training set to obtain a trained detection model; verifies the detection model according to the verification set and the test set to determine the optimal detection model; finally, performs target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data, which can reduce scene false detection and missed detection rates and improve detection accuracy.
[0016] According to some embodiments of the present invention, the step of performing standardization processing on the foggy image to obtain a standard foggy image includes:
[0017] Defogging the foggy image according to a preset defogging algorithm to obtain a defogging foggy image;
[0018] The foggy image after the defogging process is labeled to obtain a standard foggy image.
[0019] According to some embodiments of the present invention, the improving the feature fusion layer based on the original YOLOv5 model specifically includes:
[0020] The PANet network of the original YOLOv5 model is replaced by the FPG feature fusion structure.
[0021] According to some embodiments of the present invention, training the improved YOLOv5 model according to the training set to obtain a trained detection model includes:
[0022] Input the images of the training set into the CSPDarknet53 network of the improved YOLOv5 model for feature extraction to generate a first feature layer;
[0023] Inputting the first feature layer into the FPG feature fusion structure of the improved YOLOv5 model to obtain three second feature layers;
[0024] Determine, according to the second feature layer, the bounding boxes in the bounding box list and the confidence level corresponding to each bounding box;
[0025] The bounding box is screened using a non-maximum suppression method to obtain a final bounding box.
[0026] According to some embodiments of the present invention, the adopting a non-maximum suppression method to screen the bounding box to obtain a final bounding box includes:
[0027] Bounding box sorting step: sorting the bounding boxes in the bounding box list according to the confidence level;
[0028] Deleting the bounding box with the highest confidence in the bounding box list, and adding the bounding box with the highest confidence to the output list;
[0029] Calculate the areas of all bounding boxes in the bounding box list and the intersection-over-union ratio of the bounding box with the highest confidence and the target bounding box;
[0030] Screening step: if the IoU is greater than a preset IoU threshold, deleting the target bounding box from the bounding box list;
[0031] Repeat the bounding box sorting step to the screening step until the bounding box list is empty, and the bounding box in the output list is the final bounding box.
[0032] According to some embodiments of the present invention, the verifying the detection model according to the verification set and the test set to determine the optimal detection model includes:
[0033] Obtaining a MAP index when the verification set and the test set are used to verify the detection model;
[0034] According to the MAP index, the optimal detection model is determined.
[0035] According to some embodiments of the present invention, dividing the standard foggy image into a training set, a validation set, and a test set according to a preset ratio further includes:
[0036] The standard foggy image is subjected to data augmentation processing, wherein the data augmentation processing includes at least one of horizontal flipping, random color transformation, random brightness transformation, random contrast transformation, color temperature transformation, and random cropping.
[0037] According to a second aspect of the present invention, a target detection device includes:
[0038] An image acquisition module, used to acquire a reference image, wherein the reference image includes a foggy image;
[0039] A standardization processing module, used for performing standardization processing on the foggy image to obtain a standard foggy image;
[0040] An image division module, used for dividing the standard foggy image into a training set, a verification set and a test set according to a preset ratio;
[0041] A model training module, used for training the improved YOLOv5 model according to the training set to obtain a trained detection model, wherein the improved YOLOv5 model is a model obtained by improving the feature fusion layer on the basis of the original YOLOv5 model;
[0042] An optimal detection model determination module, used to verify the detection model according to the verification set and the test set, and determine the optimal detection model;
[0043] The detection module is used to perform target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data.
[0044] According to the target detection device of the embodiment of the present invention, there are at least the following beneficial effects: the target detection device acquires a reference image through an image acquisition module, and the standardization processing module performs standardization processing on the foggy image included in the reference image to obtain a standard foggy image; the image division module divides the standard foggy image into a training set, a verification set and a test set according to a preset ratio; the model training module trains the improved YOLOv5 model according to the training set to obtain a trained detection model; the optimal detection model determination module verifies the detection model according to the verification set and the test set to determine the optimal detection model; the final detection module performs target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data, which can reduce the scene false detection and missed detection rates and improve the detection accuracy.
[0045] According to a third aspect of the present invention, a vehicle and pedestrian detection device for improving YOLOv5 includes:
[0046] at least one processor, and
[0047] a memory communicatively connected to the at least one processor; wherein,
[0048] The memory stores instructions, and the instructions are executed by the at least one processor so that the at least one processor implements the target detection method as described in the embodiment of the first aspect when executing the instructions.
[0049] According to the embodiment of the present invention, the vehicle and pedestrian detection device based on the improved YOLOv5 has at least the following beneficial effects: the vehicle and pedestrian detection device based on the improved YOLOv5 adopts the above-mentioned target detection method, obtains a reference image, and standardizes the foggy image included in the reference image to obtain a standard foggy image; divides the standard foggy image into a training set, a verification set and a test set according to a preset ratio; trains the improved YOLOv5 model according to the training set to obtain a trained detection model; verifies the detection model according to the verification set and the test set to determine the optimal detection model; finally, performs target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data, which can reduce the scene false detection and missed detection rates and improve the detection accuracy.
[0050] According to the computer-readable storage medium of the fourth aspect embodiment of the present invention, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the target detection method as described in the first aspect embodiment.
[0051] The computer-readable storage medium according to the embodiment of the present invention has at least the following beneficial effects: the computer-readable storage medium executes the above-mentioned target detection method, obtains a reference image, and standardizes the foggy image included in the reference image to obtain a standard foggy image; divides the standard foggy image into a training set, a verification set, and a test set according to a preset ratio; trains the improved YOLOv5 model according to the training set to obtain a trained detection model; verifies the detection model according to the verification set and the test set to determine the optimal detection model; finally, performs target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data, which can reduce scene false detection and missed detection rates and improve detection accuracy.
[0052] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The present invention will be further described below with reference to the accompanying drawings and embodiments, wherein:
[0054] Figure 1 is a flow chart of a target detection method according to an embodiment of the present invention;
[0055] Figure 2 for Figure 1 Flow chart of step S102;
[0056] Figure 3 for Figure 1 Flow chart of step S104;
[0057] Figure 4It is a schematic diagram of an improved FPG feature fusion structure according to an embodiment of the present invention;
[0058] Figure 5 for Figure 3 Flow chart of step S304;
[0059] Figure 6 for Figure 1 Flow chart of step S105;
[0060] Figure 7 Schematic diagram of the structure of a target detection device according to an embodiment of the present invention.
[0061] Reference numerals: 710, image acquisition module; 720, standardization processing module; 730, image segmentation module; 740, model training module; 750, optimal detection model determination module; 760, detection module. DETAILED DESCRIPTION
[0062] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0063] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0064] In the description of the present invention, "several" means more than one, "many" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0065] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention in combination with the specific content of the technical solution.
[0066] In the description of the present invention, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0067] First, refer to Figure 1 , the target detection method of the embodiment of the present invention includes:
[0068] S101, acquiring a reference image, wherein the reference image includes a foggy image;
[0069] S102, performing standardization processing on the foggy image to obtain a standard foggy image;
[0070] S103, dividing the standard foggy image into a training set, a validation set, and a test set according to a preset ratio;
[0071] S104, training the improved YOLOv5 model according to the training set to obtain a trained detection model, wherein the improved YOLOv5 model is a model obtained by improving the feature fusion layer on the basis of the original YOLOv5 model;
[0072] S105, verifying the detection model according to the verification set and the test set to determine the optimal detection model;
[0073] S106, performing target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data.
[0074] When detecting vehicles and pedestrians in a foggy environment, a reference image is first obtained, which includes a foggy image, which is a number of images containing vehicles and pedestrians in a foggy environment. The foggy image is standardized, including defogging of the foggy image, etc., and the foggy image is processed into a fog-free image, thereby obtaining a standard foggy image. The standard foggy image is divided into a training set, a validation set, and a test set according to a preset ratio. It should be noted that the preset ratio can be set according to actual needs. For example, these standard foggy images are divided into a training set, a validation set, and a test set according to a ratio of 7:2:1, and the standard foggy images of the three image sets are annotated to obtain a standard foggy image with a label. Then, the standard foggy image of the training set is input into the improved YOLOv5 model, and the improved YOLOv5 model is trained to obtain a trained detection model, wherein the improved YOLOv5 model is a model after the feature fusion layer is improved on the basis of the original YOLOv5 model. Furthermore, the detection model is verified using the validation set and the test set to determine the optimal detection model. Finally, target detection is performed on the image to be detected based on the optimal detection model to obtain vehicle data and pedestrian data. This method can reduce the scene false detection and missed detection rates and improve detection accuracy.
[0075] It should be noted that the improvement of the feature fusion layer based on the original YOLOv5 model specifically includes replacing the PANet network of the original YOLOv5 model with the FPG (Feature Pyramid Grids) feature fusion structure. The FPG feature fusion structure is a deep multi-path feature pyramid that represents the feature scale space as a regular grid of parallel bottom-up paths, and is achieved by multi-directional lateral connection fusion, including lateral, bottom-up, integrated downward, and skip connections.
[0076] Reference Figure 2 In some embodiments, step S102 includes:
[0077] S201, performing defogging processing on the foggy image according to a preset defogging algorithm to obtain a defogging foggy image;
[0078] S202, annotating the defogging foggy image to obtain a standard foggy image.
[0079] In the process of standardizing foggy images, a dehazing algorithm based on deep learning can be used to establish an end-to-end dehazing model using CNN (convolutional neural network), and the dehazing model can be used to restore foggy images to approximately fog-free images. For example, an atmospheric scattering model is constructed based on the DehazeNet algorithm to restore foggy images to fog-free images. The atmospheric scattering model includes two parts: the attenuation model and the ambient light model. The atmospheric scattering model expression is:
[0080] I(x)=I(x)e -rd(x) +A(1-e -rd(x) );
[0081] Where x is the spatial coordinate of the image pixel, I(x) is the observed foggy image, J(x) is the fog-free image to be restored, r represents the atmospheric scattering coefficient, d(x) represents the scene depth, and A is the global atmospheric light, which is usually assumed to be a global constant and has nothing to do with the spatial coordinate x.
[0082] In some other specific embodiments, GAN (Generative Adversarial Network) can also be used to directly obtain a defogging algorithm, such as GCANet, etc. Other algorithms are also possible, and are not limited to these.
[0083] In some embodiments, after the standard foggy images are divided into a training set, a validation set, and a test set according to a preset ratio. It is also necessary to annotate the standard foggy images of the three image sets to obtain standard foggy images with labels. Specifically, a VOCdevkit folder can be created in the root directory of the project, a VOC2007 folder can be established in the folder, and new folders and files can be created in the VOC2007 folder, including an Annotations folder for storing label files and a label file format in an xml file format, an ImageSets folder, and a JPEGImages folder for storing all picture files, wherein the image file format of the JPEGImages folder is a JPG image format. At the same time, a Main folder is created in the Imagesets folder, and a new file is created in the Main folder, the new file including a train.txt file of the serial numbers of all training set images, a val.txt file of the serial numbers of all validation set images, a test.txt file of the serial numbers of all test set images, and a trainval.txt file of the serial numbers of all training set images and validation set images. Then, the Labelimg script is used to manually annotate the image set containing vehicles and pedestrians after defogging, and all vehicles and pedestrians of different categories are annotated in the form of rectangular boxes. Among them, the annotated xml file contains information such as image name, category name, and coordinates of the four vertices of the target position rectangular box. All label files are saved in the Annotations folder. By annotating each standard foggy image in the above image set, the image features of the standard foggy image can be more easily identified, thereby improving detection efficiency.
[0084] In some embodiments, step S103 includes:
[0085] Data augmentation processing is performed on the standard foggy image, wherein the data augmentation processing includes at least one of horizontal flipping, random color transformation, random brightness transformation, random contrast transformation, color temperature transformation, and random cropping.
[0086] In order to improve the comprehensiveness and quantity of image data, the standard foggy images in each image set (including training set, validation set and test set) can also be subjected to data augmentation operations such as horizontal flipping, random color transformation, random brightness transformation, random contrast transformation, color temperature transformation, random cropping, etc., to expand the image data of each image set.
[0087] Reference Figure 3 and Figure 4 In some embodiments, step S104 includes:
[0088] S301, input the image of the training set into the CSPDarknet53 network of the improved YOLOv5 model for feature extraction to generate the first feature layer;
[0089] S302, inputting the first feature layer into the FPG feature fusion structure of the improved YOLOv5 model to obtain three second feature layers;
[0090] S303, determining the bounding boxes in the bounding box list and the confidence corresponding to each bounding box according to the second feature layer;
[0091] S304: Use a non-maximum suppression method to screen the bounding box to obtain a final bounding box.
[0092] Since the YOLOV5 network has an extremely fast inference speed, occupies little space, and has strong detection performance. Therefore, in the embodiments of this application, the YOLOV5 model is improved to obtain a detection model that meets the requirements. The improvement of the YOLOV5 model can be to improve the feature fusion layer on the basis of the original YOLOv5 model, specifically including replacing the PANet network of the original YOLOv5 model with the FPG (Feature Pyramid Grids) feature fusion structure. Specifically, the training set images processed by annotation are input into the CSPDarknet53 network of the improved YOLOv5 model for feature extraction. Since the size of the convolution kernel of each CSP module is 3×3, three first feature layers of different sizes can be obtained through feature extraction. These three first feature layers are marked as C1, C2, and C3. These three first feature layers are input into the Neck part of the improved YOLOv5 model. After improvement, the Neck part is mainly composed of the FPG feature fusion structure. The FPG feature fusion structure is used to perform feature fusion on the three input first feature layers. For example, the features in the FPG feature fusion structure include three first feature layers C1, C2, and C3, the path channel P, and the number of path channels n, where the value range of n is 1 < n < 9. The features at the same level are connected through the path by the horizontal solid line, and the above features are projected by using 1×1 horizontal convolution on each first feature layer, and these features are fused with the corresponding features in the adjacent path. In order to shorten the path from the shallow path low-level features to the deep path high-level features, a direct connection can be introduced to construct a bottom-up path across levels (diagonal upward dotted line). In addition, the top-down information flow is realized by integrating the downward connection (diagonal downward thick solid line), and this method can fuse the upsampled features and the downsampled features. In addition, in order to simplify the training of the FPG feature fusion structure, a skip connection (cross-layer dotted line), such as 1×1 convolution, is added between the first path and the subsequent path at the same level. By inputting the first feature layer into the FPG feature fusion structure of the improved YOLOv5 model, three second feature layers can be obtained. According to the second feature layer, the bounding boxes in the bounding box list and the confidence corresponding to each bounding box can be determined. It should be noted that at the initial prediction of the model, there are multiple bounding boxes for one category; the confidence represents the confidence level that there is indeed an object in the bounding box and the confidence level that the bounding box includes all the features of the entire object. Therefore, after obtaining the bounding boxes and the confidence corresponding to each bounding box, the non-maximum suppression method needs to be used to filter out the duplicate bounding boxes to improve the accuracy of model training.
[0093] Referring to Figure 5 , in some embodiments, step S304 includes:
[0094] S401, bounding box sorting step: sorting the bounding boxes in the bounding box list according to the confidence levels;
[0095] S402, deleting the bounding box with the highest confidence in the bounding box list, and adding the bounding box with the highest confidence to the output list;
[0096] S403, calculating the areas of all bounding boxes in the bounding box list and the intersection-over-union ratio of the bounding box with the highest confidence level to the target bounding box;
[0097] S404, screening step: if the IoU is greater than a preset IoU threshold, deleting the target bounding box from the bounding box list;
[0098] S405, repeating the bounding box sorting step to the screening step until the bounding box list is empty, and the bounding box in the output list is the final bounding box.
[0099] In order to improve the accuracy of screening, when the non-maximum suppression method is used to screen the bounding boxes, the bounding box sorting step can be performed first: sort the bounding boxes in the bounding box list according to the size of the confidence, delete the bounding box with the highest confidence in the bounding box list, and add the bounding box with the highest confidence to the output list. Calculate the area of all bounding boxes in the bounding box list and the intersection and union ratio of the bounding box with the highest confidence and the target bounding box, where the intersection and union ratio refers to the ratio of the intersection area of two boxes to the union area of two boxes, indicating the degree of intersection of the two boxes. Then, perform the screening step, and screen the bounding boxes according to the preset screening conditions, that is, if the intersection and union ratio is greater than the preset intersection and union ratio threshold, delete the target bounding box in the bounding box list, repeat the bounding box sorting step to the screening step, until the bounding box list is empty, then the bounding box in the output list is the final bounding box (i.e., the predicted box). In this way, it is relatively easy to obtain a bounding box that meets the requirements, which improves the screening accuracy and efficiency.
[0100] Reference Figure 6 In some embodiments, step S105 includes:
[0101] S501, obtaining the MAP index when the verification set and the test set are used to verify the detection model;
[0102] S502: Determine the optimal detection model according to the MAP index.
[0103] In order to improve the detection accuracy, after the detection model is trained, it is also necessary to determine the optimal detection model. Specifically, the standard foggy images of the verification set can be input into the trained detection model to observe the convergence of the verification set accuracy. At the same time, monitor whether the trained detection model is overfitting, and manually adjust the hyperparameters. By comparing the comprehensive index MAP of the trained detection model, the detection model with the highest MAP index is selected as the optimal detection model. At the same time, the test set is used to further evaluate the test effect of the optimal detection model. After the optimal detection model is optimized, the optimal detection model after optimization is used to detect vehicles and pedestrians in the images to be detected in foggy environments, which can reduce the scene false detection and missed detection rates and improve detection accuracy.
[0104] Second, refer to Figure 7 , the target detection device of the embodiment of the present invention comprises:
[0105] An image acquisition module 710 is used to acquire a reference image, wherein the reference image includes a foggy image;
[0106] The standardization processing module 720 is used to perform standardization processing on the foggy image to obtain a standard foggy image;
[0107] An image division module 730 is used to divide the standard foggy image into a training set, a validation set and a test set according to a preset ratio;
[0108] A model training module 740 is used to train the improved YOLOv5 model according to the training set to obtain a trained detection model, wherein the improved YOLOv5 model is a model obtained by improving the feature fusion layer on the basis of the original YOLOv5 model;
[0109] The optimal detection model determination module 750 is used to verify the detection model according to the verification set and the test set to determine the optimal detection model;
[0110] The detection module 760 is used to perform target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data.
[0111] In a third aspect, an embodiment of the present invention provides a vehicle pedestrian detection device for improving YOLOv5, comprising at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions, and the instructions are executed by the at least one processor, so that when the at least one processor executes the instructions, a target detection method as in the embodiment of the first aspect is implemented.
[0112] In a fourth aspect, the present invention further provides a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the target detection method of the embodiment of the first aspect.
[0113] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments. Various changes can be made within the knowledge of ordinary technicians in the relevant technical field without departing from the purpose of the present invention. In addition, the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
Claims
1. A target detection method, characterized in that: include: Acquire a reference image, wherein the reference image includes a foggy image; Performing standardization processing on the foggy image to obtain a standard foggy image; Dividing the standard foggy image into a training set, a validation set and a test set according to a preset ratio; The improved YOLOv5 model is trained according to the training set to obtain a trained detection model, wherein the improved YOLOv5 model is a model obtained by replacing the PANet network of the original YOLOv5 model with an FPG feature fusion structure on the basis of the original YOLOv5 model, and the FPG feature fusion structure represents the feature scale space as a regular grid of parallel bottom-up paths; Verifying the detection model according to the verification set and the test set to determine the optimal detection model; Performing target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data; The step of training the improved YOLOv5 model according to the training set to obtain a trained detection model includes: The images of the training set are input into the CSPDarknet53 network of the improved YOLOv5 model for feature extraction to generate three first feature layers; the first feature layer is input into the FPG feature fusion structure of the improved YOLOv5 model to obtain three second feature layers, wherein the FPG feature fusion structure includes multiple path channels, each first feature layer passes through multiple path channels in sequence at its own level, and the FPG feature fusion structure also includes: lateral connections established between adjacent paths at the same level, bottom-up connections established on the same path at different levels, integrated downward connections established between adjacent channels at different levels, and jump connections established between the first path at the same level and the remaining paths except the first path; according to the second feature layer, the bounding box in the bounding box list and the confidence corresponding to each bounding box are determined; the bounding box is screened by using the non-maximum suppression method to obtain the final bounding box.
2. The target detection method according to claim 1, characterized in that: The step of performing standardization processing on the foggy image to obtain a standard foggy image includes: Defogging the foggy image according to a preset defogging algorithm to obtain a defogging foggy image; The foggy image after the defogging process is labeled to obtain a standard foggy image.
3. The target detection method according to claim 1, characterized in that: The non-maximum suppression method is used to filter the bounding box to obtain a final bounding box, including: Bounding box sorting step: sorting the bounding boxes in the bounding box list according to the confidence level; Deleting the bounding box with the highest confidence in the bounding box list, and adding the bounding box with the highest confidence to the output list; Calculate the areas of all bounding boxes in the bounding box list and the intersection-over-union ratio of the bounding box with the highest confidence and the target bounding box; Screening step: if the IoU is greater than a preset IoU threshold, deleting the target bounding box from the bounding box list; Repeat the bounding box sorting step to the screening step until the bounding box list is empty, and the bounding box in the output list is the final bounding box.
4. The target detection method according to claim 1, characterized in that: The step of verifying the detection model according to the verification set and the test set to determine the optimal detection model includes: Obtaining a MAP index when the verification set and the test set are used to verify the detection model; According to the MAP index, the optimal detection model is determined.
5. The target detection method according to any one of claims 1 to 4, characterized in that: The step of dividing the standard foggy image into a training set, a validation set and a test set according to a preset ratio also includes: The standard foggy image is subjected to data augmentation processing, wherein the data augmentation processing comprises at least one of horizontal flipping, random color transformation, random brightness transformation, random contrast transformation, color temperature transformation, and random cropping.
6. A target detection device, characterized in that: include: An image acquisition module, used to acquire a reference image, wherein the reference image includes a foggy image; A standardization processing module, used for performing standardization processing on the foggy image to obtain a standard foggy image; An image division module, used for dividing the standard foggy image into a training set, a verification set and a test set according to a preset ratio; A model training module is used to train the improved YOLOv5 model according to the training set to obtain a trained detection model, wherein the improved YOLOv5 model is a model obtained by replacing the PANet network of the original YOLOv5 model with an FPG feature fusion structure on the basis of the original YOLOv5 model, and the FPG feature fusion structure represents the feature scale space as a regular grid of parallel bottom-up paths; wherein the step of training the improved YOLOv5 model according to the training set to obtain the trained detection model includes: inputting the image of the training set into the CSPDarknet53 network of the improved YOLOv5 model for feature extraction to generate three first feature layers; the first feature The first feature layer is input into the FPG feature fusion structure of the improved YOLOv5 model to obtain three second feature layers, wherein the FPG feature fusion structure includes multiple path channels, each first feature layer passes through multiple path channels in sequence at its own level, and the FPG feature fusion structure also includes: lateral connections established between adjacent paths at the same level, bottom-up connections established on the same path at different levels, integrated downward connections established between adjacent channels at different levels, and jump connections established between the first path at the same level and the remaining paths except the first path; according to the second feature layer, determine the bounding box in the bounding box list and the confidence corresponding to each bounding box; use the non-maximum suppression method to screen the bounding box to obtain the final bounding box; An optimal detection model determination module, used to verify the detection model according to the verification set and the test set, and determine the optimal detection model; The detection module is used to perform target detection on the image to be detected according to the optimal detection model to obtain vehicle data and pedestrian data.
7. A target detection device, characterized in that include: at least one processor, and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions, and the instructions are executed by the at least one processor, so that the at least one processor implements the target detection method according to any one of claims 1 to 5 when executing the instructions.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the target detection method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Steel bar counting method based on target detection
CN112580542A
Logistics operation violation behavior detection method, device and equipment and storage medium
CN112686595A