Target detection method and system based on YOLO in complex weather
By using differential image processing and multiple differentiable filters in the YOLO target detection method, combined with Focal Loss and cross-entropy loss functions, the problem of insufficient accuracy and robustness of target detection under complex weather is solved and the detection performance is improved. and efficiency.
Patent Information
- Application Number
- CN202410721232.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-08-30
AI Technical Summary
Existing target detection methods have insufficient detection accuracy and robustness under complex weather conditions. In particular, region proposal-based methods are slow, single-stage regression methods have reduced detection performance in complex environments, and feature pyramid networks ignore image recovery information. This results in insufficient model robustness.
The target detection method based on YOLO is used to enhance the image through pre-processing and differential image processing models. The target detection model is trained by combining Focal Loss and binary cross-entropy loss function. Multiple differentiable filters are used to process the image to enhance the robustness of the model. and detection performance.
It improves the real-time efficiency of target detection, enhances the recognition ability of complex environments and camouflaged targets, and improves the robustness and detection accuracy of the model.
Smart Images

Figure CN118570607A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision target detection, and more specifically, relates to a target detection method and system based on YOLO under complex weather conditions. Background Art
[0002] As one of the core tasks in the field of computer vision, object detection has been widely used in the fields of autonomous driving, security monitoring, intelligent transportation, etc. in recent years. However, complex weather conditions pose severe challenges to the accuracy and robustness of object detection. For example, in the field of autonomous driving, severe weather conditions such as rain, snow, haze, etc. can lead to image quality degradation, thus affecting the performance of the object detection algorithm. In addition, some camouflaged objects are highly similar to the background in terms of texture, color, shape, etc., and are easily ignored, which brings additional difficulties to object detection. Moreover, when the distribution difference between training data and actual test scenes is large, the performance of the object detection model is further limited. Therefore, a new object detection technology is urgently needed to improve the accuracy and robustness in complex weather conditions and solve the distribution difference problem between training data and actual scenes.
[0003] At present, there are several common target detection methods: the first is based on region proposal methods, such as the R-CNN model. This type of method first generates relevant regions from the image and then classifies them by training a neural network; the second is based on single-stage regression methods, such as the Single Shot Multibox Detector (SSD) model, which predicts object labels and bounding box coordinates through a single convolutional neural network; the third is based on feature pyramid networks, such as Faster R-CNN, which achieves multi-scale feature fusion and improves detection performance by constructing feature pyramids.
[0004] However, all three methods mentioned above have some defects that cannot be ignored: First, although the method based on region proposal has high detection accuracy, it is slow, resulting in low real-time detection efficiency. Second, the method based on single-stage regression has a faster recognition speed, but the detection performance is significantly reduced when facing complex environments, camouflaged targets and other problems. Third, the method based on feature pyramid network ignores the potential information that can be obtained in the weather-based image restoration process, resulting in insufficient robustness of the model. Summary of the invention
[0005] In view of the above defects or improvement needs of the prior art, the present invention provides a target detection method and system based on YOLO under complex weather conditions, which aims to solve the technical problem that the existing method based on region proposal has high detection accuracy but slow speed, resulting in low real-time detection efficiency, and the technical problem that the existing method based on single-stage regression has a fast recognition speed but the detection performance is significantly reduced when facing complex environments, camouflaged targets and other problems, and the technical problem that the existing method based on feature pyramid network ignores the potential information that can be obtained in the weather-based image restoration process, resulting in insufficient robustness of the model.
[0006] To achieve the above object, according to one aspect of the present invention, a target detection method based on YOLO in complex weather is provided, comprising the following steps:
[0007] (1) Acquire an image to be detected, and preprocess the acquired image to be detected to obtain a preprocessed image.
[0008] (2) Inputting the image preprocessed in step (1) into a pre-trained image processing model for image enhancement processing to obtain an image enhanced image.
[0009] (3) The enhanced image obtained in step (2) is input into a pre-trained target detection model to obtain the final target detection result.
[0010] Preferably, step (1) is specifically as follows: first, the acquired image to be detected is scaled using a resolution of 512×512, and then the pixel values of the scaled image are normalized from the range of [0, 255] to the range of [0, 1], thereby obtaining a preprocessed image.
[0011] Preferably, the image processing model is a differential image processing DIP model, which is trained by the following steps:
[0012] (2-1) Obtain an image dataset containing normal weather conditions and complex weather conditions, and perform a screening operation on the image dataset to obtain a screened image dataset.
[0013] (2-2) performing preprocessing and target labeling operations on the image dataset filtered in step (2-1) to obtain an image dataset containing a labeling file;
[0014] (2-3) Divide the image dataset containing the annotated files obtained in step (2-2) into a training set and a validation set in a ratio of 8:2;
[0015] (2-4) Construct an image processing model, which includes six differentiable filters, and determine the input and output of the image processing model, wherein the input is the original image to be processed and the output is the enhanced image.
[0016] (2-5) All the dehazed images in the training set obtained in step (2-3) are input into the first differentiable filter for training, and the loss function value is calculated. The model parameters of the first differentiable filter are updated using the loss function value to obtain the updated parameters of the first differentiable filter.
[0017] (2-6) Input all white balance images in the training set obtained in step (2-3) into the second differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the second differentiable filter to obtain the updated parameters of the second differentiable filter.
[0018] (2-7) Input all gamma-corrected images in the training set obtained in step (2-3) into the third differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the third differentiable filter to obtain the updated parameters of the third differentiable filter.
[0019] (2-8) Input all contrast images in the training set obtained in step (2-3) into the fourth differentiable filter for training, and calculate the loss function value, and use the loss function value to update the model parameters of the fourth differentiable filter to obtain the updated parameters of the fourth differentiable filter.
[0020] (2-9) Input all the tone images in the training set obtained in step (2-3) into the fifth differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the fifth differentiable filter to obtain the updated parameters of the fifth differentiable filter.
[0021] (2-10) Input all the sharpened images in the training set obtained in step (2-3) into the sixth differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the sixth differentiable filter to obtain the updated parameters of the sixth differentiable filter.
[0022] (2-11) Use the validation set to verify and adjust the updated parameters of the six filters obtained from steps (2-5) to (2-10) to obtain a trained image processing model.
[0023] Preferably, step (2-1) performs a screening operation on the image data set, specifically using a histogram analysis method to evaluate the clarity of each image therein, eliminating blurred and low-quality images, and using an oversampling method to ensure that the data set contains multiple categories of images and maintains a balance in the number of images of different categories; there are six categories of images: dehazed images, white balanced images, gamma corrected images, contrast images, hue images, and sharpened images;
[0024] The target labeling process in step (2-2) is to determine the position bounding box and category of the object to be detected in each image in the image dataset, thereby forming a json format labeling file corresponding to the image. The json format labeling files corresponding to all images in the image dataset constitute an image dataset containing the labeling files.
[0025] Preferably, the loss function in step (2-5) is a cross entropy loss function;
[0026] The calculation formula of the model parameters corresponding to the first differentiable filter is as follows:
[0027] t(x,ω)=1―ω*minC,(miny∈Ω(x)IC(y) / AC)
[0028] Among them, ω is a learnable parameter that controls the degree of dehazing, and its value range is 0 to 1, preferably 0.75. IC(y) is the pixel value of the dehazed image I at color channel C and position y. AC is the estimated global atmospheric light. Ω(x) is the local window centered on x, and minC represents the minimum value of color channel C.
[0029] The loss function in step (2-6) is the cross entropy loss function.
[0030] The calculation formula of the model parameters corresponding to the second differentiable filter is as follows:
[0031] Pw=(Wr*ri,Wg*gi,Wb*bi)
[0032] Among them, Wr, Wg, Wb are gain factors of R, G, B channels respectively, and their value range is 1 to 2, preferably 1.25, ri, gi, bi are pixel values of R, G, B channels of white balance image respectively.
[0033] The loss function in step (2-7) is the cross entropy loss function.
[0034] The calculation formula of the model parameters corresponding to the third differentiable filter is as follows:
[0035] Pg=Pi^G
[0036] Wherein, G is a learnable Gamma value, which ranges from 0 to 1, preferably 0.75, and Pi is the pixel value of the gamma-corrected image.
[0037] Preferably, the loss function in step (2-8) is a cross entropy loss function.
[0038] The calculation formula of the model parameters corresponding to the fourth differentiable filter is as follows:
[0039] Pt=α*En(Pi)+(1-α)*Pi
[0040] Where α is a learnable contrast parameter, which ranges from 0 to 1, preferably 0.75, En(Pi) is the contrast-enhanced version of the input image Pi, and Pi is the pixel value of the contrast image;
[0041] The loss function in step (2-9) is the cross entropy loss function.
[0042] The calculation formula of the model parameters corresponding to the fifth differentiable filter is as follows:
[0043] Pc=1 / TL*∑(clip(L*Pi―j,0,1)*tk)
[0044] Among them, tk is the learnable tone parameter, TL is the number of tone parameters, Pi is the pixel value of the tone image, Po is the pixel value of the output image, L is the linear interpolation interval, j is the interpolation index, and j=0,…,L-1.
[0045] The loss function in step (2-10) is the cross entropy loss function.
[0046] The calculation formula of the model parameters corresponding to the sixth differentiable filter is as follows:
[0047] F(x,λ)=I(x)+λ*(I(x)-Gau(I(x)))
[0048] Wherein, λ is a learnable sharpening parameter, whose value range is 0 to 1, preferably 0.75, I(x) is the pixel value of the sharpened image, and Gau(I(x)) is the Gaussian blur value of the pixel value of the sharpened image I(x).
[0049] Preferably, the target detection model is a YOLO model, which is trained by the following steps:
[0050] (3-1) Obtain a set of images to be detected through a perception sensor, and divide the set of images to be detected into a training set and a test set in a ratio of 8:2.
[0051] (3-2) Preprocess the training set obtained in step (3-1) to obtain a preprocessed training set.
[0052] (3-3) For each sample in the preprocessed training set obtained in step (3-2), it is input into the convolutional layer to obtain a feature map corresponding to the sample with a size of 256×256×32.
[0053] (3-4) For each sample in the preprocessed training set obtained in step (3-2), the feature map of size 256×256×32 corresponding to the sample obtained in step (3-3) is input into the dense module for feature reuse and convolution operations to obtain a feature map of size 256×256×256 corresponding to the sample.
[0054] (3-5) For each sample in the preprocessed training set obtained in step (3-2), the feature map of size 256×256×256 corresponding to the sample obtained in step (3-4) is input into the transition module for maximum pooling processing to obtain a feature map of size 64×64×256 corresponding to the sample.
[0055] (3-6) For each sample in the preprocessed training set obtained in step (3-2), an upsampling operation is performed on the feature map of size 64×64×256 corresponding to the sample obtained in step (3-5), and the sampling operation result is fused with the feature map of size 256×256×256 corresponding to the sample obtained in step (3-4), thereby obtaining three feature layers corresponding to the sample with sizes of 64×64, 128×128 and 256×256 respectively.
[0056] (3-7) For each sample in the preprocessed training set obtained in step (3-2), a 1×1 convolution operation is performed on the three feature layers corresponding to the sample obtained in step (3-6), and the results of the convolution operation are input into two parallel branches respectively, and the output results of the two branches are stacked, and finally the target detection result corresponding to the sample is output.
[0057] (3-8) For each sample in the preprocessed training set obtained in step (3-2), a loss function is calculated based on the target detection result corresponding to the sample obtained in step (3-7), and the target detection model is iteratively trained using the loss function until the YOLO-based target detection model converges, thereby obtaining a preliminarily trained YOLO-based target detection model.
[0058] (3-9) The test set obtained in step (3-1) is input into the YOLO-based target detection model preliminarily trained in step (3-8) for verification until the detection accuracy is optimal, thereby obtaining a trained YOLO-based target detection model.
[0059] Preferably, the loss function calculation formula of the target detection model is:
[0060] Lt=Ldet+λ*Ldc
[0061] Among them, λ is the coefficient of GRL, which is used to balance the detection loss and classification loss. Its value range is 0 to 1, preferably 0.75. Ldet represents the detection loss, and Ldc represents the classification loss.
[0062] Preferably, the detection loss Ldet uses the Focal Loss loss function, which is calculated as follows:
[0063]
[0064] Among them, i represents the i-th prediction box of the sample, i∈[1, the total number of prediction boxes in the sample], j represents the j-th true box of the sample, j∈[1, the total number of prediction boxes in the sample], yij represents the IoU value between the i-th prediction box and the j-th true box, which is used to determine whether it is a positive sample, pij represents the probability that the i-th prediction box belongs to the j-th category, α represents the balance factor, which is 0.5 and is used to balance the number of positive and negative samples, and γ represents the focus parameter, which is 0.25 and is used to focus on difficult samples.
[0065] The classification loss Ldc uses a binary cross entropy loss function, calculated as:
[0066]
[0067] Among them, x and y represent the position coordinates of the sample in the feature map obtained in step (3-3), t represents the true label of the sample, which takes a value of 0 or 1, and p (x,y) Indicates the probability that the target prediction of the sample at the position (x, y) is true.
[0068] According to another aspect of the present invention, a target detection system based on YOLO in complex weather is provided, comprising:
[0069] The first module is used to acquire the image to be detected and preprocess the acquired image to be detected to obtain a preprocessed image.
[0070] The second module is used to input the image preprocessed by the first module into a pre-trained image processing model for image enhancement processing to obtain an image after image enhancement.
[0071] The third module is used to input the enhanced image obtained by the second module into a pre-trained target detection model to obtain the final target detection result.
[0072] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:
[0073] (1) The present invention adopts step (1) and step (2) to achieve enhanced processing of the image to be detected through preprocessing and training of the differential image processing model, thereby solving the problem of low efficiency of real-time target detection.
[0074] (2) The present invention adopts steps (3-8) and trains the target detection model by combining Focal Loss and binary cross entropy loss function to achieve effective recognition of complex environment camouflaged targets in the image to be detected, thereby solving the problem of decreased detection performance when facing complex environment camouflaged targets.
[0075] (3) The present invention adopts steps (2-5) to (2-10) to achieve accurate recognition of targets in the image to be detected by training multiple specially designed differentiable filters and target detection models, thereby solving the problem of insufficient robustness of the target detection model. A target detection system based on YOLO in complex weather, comprising:
[0076] The first module is used to acquire the image to be detected and preprocess the acquired image to be detected to obtain a preprocessed image.
[0077] The second module is used to input the image preprocessed by the first module into a pre-trained image processing model for image enhancement processing to obtain an image after image enhancement.
[0078] The third module is used to input the enhanced image obtained by the second module into a pre-trained target detection model to obtain the final target detection result.
[0079] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:
[0080] (1) The present invention adopts step (1) and step (2) to achieve enhanced processing of the image to be detected through preprocessing and training of the differential image processing model, thereby solving the problem of low efficiency of real-time target detection.
[0081] (2) The present invention adopts steps (3-8) and trains the target detection model by combining Focal Loss and binary cross entropy loss function to achieve effective recognition of complex environment camouflaged targets in the image to be detected, thereby solving the problem of decreased detection performance when facing complex environment camouflaged targets.
[0082] (3) Since the present invention adopts steps (2-5) to (2-10), it can achieve accurate recognition of the target in the image to be detected by training multiple specially designed differentiable filters and target detection models, thereby solving the problem of insufficient robustness of the target detection model. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 It is a schematic diagram of the overall framework of the target detection method based on YOLO under complex weather conditions of the present invention. DETAILED DESCRIPTION
[0084] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0085] The basic idea of the present invention is to construct an image adaptive enhancement model, automatically select appropriate filters for processing according to the severe weather conditions of the image, construct a multi-scale adversarial domain adaptive network, and reduce the distribution difference between the source domain and the target domain by feature alignment and conversion, so as to ensure the accuracy of target detection in complex weather conditions.
[0086] like Figure 1 As shown, the present invention provides a target detection method based on YOLO in complex weather, comprising the following steps:
[0087] (1) Acquire an image to be detected, and preprocess the acquired image to be detected to obtain a preprocessed image.
[0088] Specifically, this step is as follows: first, the acquired image to be detected is resized using a resolution of 512×512, and then the pixel values of the resized image are normalized from the range of [0,255] to the range of [0,1] (i.e., normalization is achieved by dividing by 255), thereby obtaining a preprocessed image.
[0089] (2) Inputting the image preprocessed in step (1) into a pre-trained image processing model for image enhancement processing to obtain an image enhanced image.
[0090] Specifically, the image processing model of the present invention is a Differentiable Image Processing (DIP) model, which is trained by the following steps:
[0091] (2-1) Obtain an image dataset containing normal weather conditions and complex weather conditions (such as foggy weather and low light conditions), and perform a screening operation on the image dataset to obtain a screened image dataset.
[0092] Specifically, in this step, the image data set is screened by using a histogram analysis method to evaluate the clarity of each image, remove blurry and low-quality images, and use an oversampling method to ensure that the data set contains multiple categories of images (there are six categories of images in the present invention: dehazed images, white balance images, gamma corrected images, contrast images, hue images, and sharpened images), and maintain a balance in the number of images of different categories.
[0093] The advantage of this sub-step is that by evaluating the image clarity through the histogram analysis method, blurry and low-quality images can be effectively eliminated, thereby improving the overall quality of the dataset. At the same time, the oversampling method ensures that the dataset contains multiple categories of images and maintains a balance in the number of images of different categories, avoiding the problem of category imbalance during model training. Such a screening and processing process helps to improve the generalization ability and robustness of the model, enabling it to achieve better performance under both normal and complex weather conditions.
[0094] (2-2) performing preprocessing and target labeling operations on the image dataset filtered in step (2-1) to obtain an image dataset containing a labeling file;
[0095] Specifically, the preprocessing process in this step is exactly the same as the above step (1), and will not be repeated here.
[0096] The target annotation process in this step is to determine the position bounding box and category of the object to be detected in each image in the image dataset, thereby forming a json format annotation file corresponding to the image. The json format annotation files corresponding to all images in the image dataset constitute an image dataset containing annotation files.
[0097] (2-3) Divide the image dataset containing the annotated files obtained in step (2-2) into a training set and a validation set in a ratio of 8:2;
[0098] (2-4) Construct an image processing model, which includes six differentiable filters, and determine the input and output of the image processing model, wherein the input is the original image to be processed and the output is the enhanced image.
[0099] (2-5) All the dehazed images in the training set obtained in step (2-3) are input into the first differentiable filter for training, and the loss function value is calculated. The model parameters of the first differentiable filter are updated using the loss function value to obtain the updated parameters of the first differentiable filter.
[0100] Among them, the loss function used is the cross entropy loss function.
[0101] The calculation formula of the model parameters corresponding to the first differentiable filter is as follows:
[0102] t(x,ω)=1―ω*minC,(miny∈Ω(x)IC(y) / AC)
[0103] Among them, ω is a learnable parameter that controls the degree of dehazing, and its value range is 0 to 1, preferably 0.75. IC(y) is the pixel value of the dehazed image I at color channel C and position y. AC is the estimated global atmospheric light. Ω(x) is the local window centered on x, and minC represents the minimum value of color channel C.
[0104] (2-6) Input all white balance images in the training set obtained in step (2-3) into the second differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the second differentiable filter to obtain the updated parameters of the second differentiable filter.
[0105] Among them, the loss function used is the cross entropy loss function.
[0106] The calculation formula of the model parameters corresponding to the second differentiable filter is as follows:
[0107] Pw=(Wr*ri,Wg*gi,Wb*bi)
[0108] Among them, Wr, Wg, Wb are gain factors of R, G, B channels respectively, and their value range is 1 to 2, preferably 1.25, ri, gi, bi are pixel values of R, G, B channels of white balance image respectively.
[0109] (2-7) Input all gamma-corrected images in the training set obtained in step (2-3) into the third differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the third differentiable filter to obtain the updated parameters of the third differentiable filter.
[0110] Among them, the loss function used is the cross entropy loss function.
[0111] The calculation formula of the model parameters corresponding to the third differentiable filter is as follows:
[0112] Pg=Pi^G
[0113] Wherein, G is a learnable Gamma value, which ranges from 0 to 1, preferably 0.75, and Pi is the pixel value of the gamma-corrected image.
[0114] (2-8) Input all contrast images in the training set obtained in step (2-3) into the fourth differentiable filter for training, and calculate the loss function value, and use the loss function value to update the model parameters of the fourth differentiable filter to obtain the updated parameters of the fourth differentiable filter.
[0115] Among them, the loss function used is the cross entropy loss function.
[0116] The calculation formula of the model parameters corresponding to the fourth differentiable filter is as follows:
[0117] Pt=α*En(Pi)+(1-α)*Pi
[0118] Where α is a learnable contrast parameter, which ranges from 0 to 1, preferably 0.75, En(Pi) is the contrast-enhanced version of the input image Pi, and Pi is the pixel value of the contrast image.
[0119] (2-9) Input all the tone images in the training set obtained in step (2-3) into the fifth differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the fifth differentiable filter to obtain the updated parameters of the fifth differentiable filter.
[0120] Among them, the loss function used is the cross entropy loss function.
[0121] The calculation formula of the model parameters corresponding to the fifth differentiable filter is as follows:
[0122] Pc=1 / TL*∑(clip(L*Pi―j,0,1)*tk)
[0123] Among them, tk is the learnable tone parameter, TL is the number of tone parameters, Pi is the pixel value of the tone image, Po is the pixel value of the output image, L is the linear interpolation interval, j is the interpolation index, and j=0,…,L-1.
[0124] (2-10) Input all the sharpened images in the training set obtained in step (2-3) into the sixth differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the sixth differentiable filter to obtain the updated parameters of the sixth differentiable filter.
[0125] Among them, the loss function used is the cross entropy loss function.
[0126] The calculation formula of the model parameters corresponding to the sixth differentiable filter is as follows:
[0127] F(x,λ)=I(x)+λ*(I(x)-Gau(I(x)))
[0128] Wherein, λ is a learnable sharpening parameter, whose value range is 0 to 1, preferably 0.75, I(x) is the pixel value of the sharpened image, and Gau(I(x)) is the Gaussian blur value of the pixel value of the sharpened image I(x).
[0129] The advantage of the above sub-steps (2-5) to (2-10) is that by designing different differentiable filters and training them using the cross entropy loss function, the corresponding model parameters can be learned for different image processing tasks. The design of these filters allows the model to learn the intrinsic features of the image and the required transformations in an end-to-end manner, thereby enhancing and improving the image.
[0130] (2-11) Use the validation set to verify and adjust the updated parameters of the six filters obtained from steps (2-5) to (2-10) to obtain a trained image processing model.
[0131] (3) The enhanced image obtained in step (2) is input into a pre-trained target detection model to obtain the final target detection result.
[0132] Specifically, the target detection model of the present invention is a YOLO model, which is trained by the following steps:
[0133] (3-1) Obtain a set of images to be detected through a perception sensor, and divide the set of images to be detected into a training set and a test set in a ratio of 8:2.
[0134] (3-2) Preprocess the training set obtained in step (3-1) to obtain a preprocessed training set.
[0135] Specifically, the preprocessing process in this step is exactly the same as the above step (1), and will not be repeated here.
[0136] (3-3) For each sample in the preprocessed training set obtained in step (3-2), it is input into the convolutional layer (the convolutional layer contains 32 3×3 convolution kernels and performs convolution operation with a stride of 2 to extract the feature information in the sample) to obtain a feature map of size 256×256×32 corresponding to the sample.
[0137] (3-4) For each sample in the preprocessed training set obtained in step (3-2), the feature map of size 256×256×32 corresponding to the sample obtained in step (3-3) is input into the dense module for feature reuse and convolution operation (the dense module contains 1×1 and 3×3 convolution layers, which can effectively fuse features at different levels) to obtain a feature map of size 256×256×256 corresponding to the sample.
[0138] (3-5) For each sample in the preprocessed training set obtained in step (3-2), the feature map of size 256×256×256 corresponding to the sample obtained in step (3-4) is input into the transition module for maximum pooling processing (the transition module contains a 1×1 convolution layer for reducing the number of channels) to obtain a feature map of size 64×64×256 corresponding to the sample.
[0139] (3-6) For each sample in the preprocessed training set obtained in step (3-2), an upsampling operation is performed on the feature map of size 64×64×256 corresponding to the sample obtained in step (3-5), and the sampling operation result is fused with the feature map of size 256×256×256 corresponding to the sample obtained in step (3-4), thereby obtaining three feature layers corresponding to the sample with sizes of 64×64, 128×128 and 256×256 respectively.
[0140] (3-7) For each sample in the preprocessed training set obtained in step (3-2), a 1×1 convolution operation is performed on the three feature layers corresponding to the sample obtained in step (3-6) (to reduce the number of channels), and the results of the convolution operation are input into two parallel branches respectively (each branch contains two 3×3 convolution layers, the first branch is used for classification prediction (Cls branch), and the second branch is used for target detection (including Obj branch and Reg branch)), and the output results of the two branches are stacked, and finally the target detection result corresponding to the sample is output.
[0141] (3-8) For each sample in the preprocessed training set obtained in step (3-2), a loss function is calculated based on the target detection result corresponding to the sample obtained in step (3-7), and the target detection model is iteratively trained using the loss function until the YOLO-based target detection model converges, thereby obtaining a preliminarily trained YOLO-based target detection model.
[0142] The loss function of the target detection model consists of two parts: detection loss Ldet and classification loss Ldc.
[0143] The detection loss Ldet uses the Focal Loss loss function, which is calculated as follows:
[0144]
[0145] Among them, i represents the i-th prediction box of the sample, i∈[1, the total number of prediction boxes in the sample], j represents the j-th true box of the sample, j∈[1, the total number of prediction boxes in the sample], yij represents the IoU value between the i-th prediction box and the j-th true box, which is used to determine whether it is a positive sample, pij represents the probability that the i-th prediction box belongs to the j-th category, α represents the balance factor, which is 0.5 and is used to balance the number of positive and negative samples, and γ represents the focus parameter, which is 0.25 and is used to focus on difficult samples.
[0146] The classification loss Ldc uses a binary cross entropy loss function, calculated as:
[0147]
[0148] Among them, x and y represent the position coordinates of the sample in the feature map obtained in step (3-3), t represents the true label of the sample, which takes a value of 0 or 1, and p (x,y) Indicates the probability that the target prediction of the sample at the position (x, y) is true.
[0149] The loss function calculation formula of the target detection model is:
[0150] Lt=Ldet+λ*Ldc
[0151] Among them, λ is the coefficient of GRL, which is used to balance the detection loss and classification loss. Its value range is 0 to 1, and is preferably 0.75.
[0152] The advantage of this sub-step is that by combining Focal Loss and the binary cross entropy loss function, the object detection model can be effectively trained. Focal Loss can reduce the weight of easy-to-classify samples, so that the model pays more attention to difficult-to-classify samples during training, improving the model's learning ability for minority classes and difficult examples. At the same time, the binary cross entropy loss function can effectively measure the accuracy of classification predictions.
[0153] (3-9) The test set obtained in step (3-1) is input into the YOLO-based target detection model preliminarily trained in step (3-8) for verification until the detection accuracy is optimal, thereby obtaining a trained YOLO-based target detection model.
[0154] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A target detection method based on YOLO in complex weather, characterized in that: The following steps are involved: (1) Acquire an image to be detected, and preprocess the acquired image to be detected to obtain a preprocessed image. (2) Inputting the image preprocessed in step (1) into a pre-trained image processing model for image enhancement processing to obtain an image enhanced image. (3) The enhanced image obtained in step (2) is input into a pre-trained target detection model to obtain the final target detection result.
2. The target detection method based on YOLO in complex weather according to claim 1, characterized in that: Step (1) is as follows: first, the acquired image to be detected is resized using a resolution of 512×512, and then the pixel values of the resized image are normalized from the range of [0, 255] to the range of [0, 1], thereby obtaining a preprocessed image.
3. The target detection method based on YOLO in complex weather according to claim 1 or 2, characterized in that: The image processing model is a differential image processing DIP model, which is trained by the following steps: (2-1) Obtain an image dataset containing normal weather conditions and complex weather conditions, and perform a screening operation on the image dataset to obtain a screened image dataset. (2-2) performing preprocessing and target labeling operations on the image dataset filtered in step (2-1) to obtain an image dataset containing a labeling file; (2-3) Divide the image dataset containing the annotated files obtained in step (2-2) into a training set and a validation set in a ratio of 8:2; (2-4) Construct an image processing model, which includes six differentiable filters, and determine the input and output of the image processing model, wherein the input is the original image to be processed and the output is the enhanced image. (2-5) All the dehazed images in the training set obtained in step (2-3) are input into the first differentiable filter for training, and the loss function value is calculated. The model parameters of the first differentiable filter are updated using the loss function value to obtain the updated parameters of the first differentiable filter. (2-6) Input all white balance images in the training set obtained in step (2-3) into the second differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the second differentiable filter to obtain the updated parameters of the second differentiable filter. (2-7) Input all gamma-corrected images in the training set obtained in step (2-3) into the third differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the third differentiable filter to obtain the updated parameters of the third differentiable filter. (2-8) Input all contrast images in the training set obtained in step (2-3) into the fourth differentiable filter for training, and calculate the loss function value, and use the loss function value to update the model parameters of the fourth differentiable filter to obtain the updated parameters of the fourth differentiable filter. (2-9) Input all the tone images in the training set obtained in step (2-3) into the fifth differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the fifth differentiable filter to obtain the updated parameters of the fifth differentiable filter. (2-10) Input all the sharpened images in the training set obtained in step (2-3) into the sixth differentiable filter for training, and calculate the loss function value. Use the loss function value to update the model parameters of the sixth differentiable filter to obtain the updated parameters of the sixth differentiable filter. (2-11) Use the validation set to verify and adjust the updated parameters of the six filters obtained from steps (2-5) to (2-10) to obtain a trained image processing model.
4. The target detection method based on YOLO in complex weather according to any one of claims 1 to 3, characterized in that: Step (2-1) performs a screening operation on the image data set, specifically using a histogram analysis method to evaluate the clarity of each image, removing blurry and low-quality images, and using an oversampling method to ensure that the data set contains images of multiple categories and maintains a balance in the number of images of different categories; There are six categories of images: dehazed images, white-balanced images, gamma-corrected images, contrast images, hue images, and sharpened images; The target labeling process in step (2-2) is to determine the position bounding box and category of the object to be detected in each image in the image dataset, thereby forming a json format labeling file corresponding to the image. The json format labeling files corresponding to all images in the image dataset constitute an image dataset containing the labeling files.
5. The target detection method based on YOLO in complex weather according to claim 4, characterized in that: The loss function in step (2-5) is the cross entropy loss function; The calculation formula of the model parameters corresponding to the first differentiable filter is as follows: t(x,ω)=1―ω*minC,(miny∈Ω(x)IC(y) / AC) Among them, ω is a learnable parameter that controls the degree of dehazing, and its value range is 0 to 1, preferably 0.
75. IC(y) is the pixel value of the dehazed image I at color channel C and position y. AC is the estimated global atmospheric light. Ω(x) is the local window centered on x, and minC represents the minimum value of color channel C. The loss function in step (2-6) is the cross entropy loss function. The calculation formula of the model parameters corresponding to the second differentiable filter is as follows: Pw=(Wr*ri,Wg*gi,Wb*bi) Among them, Wr, Wg, Wb are gain factors of R, G, B channels respectively, and their value range is 1 to 2, preferably 1.25, ri, gi, bi are pixel values of R, G, B channels of white balance image respectively. The loss function in step (2-7) is the cross entropy loss function. The calculation formula of the model parameters corresponding to the third differentiable filter is as follows: Pg=Pi^G Wherein, G is a learnable Gamma value, which ranges from 0 to 1, preferably 0.75, and Pi is the pixel value of the gamma-corrected image.
6. The target detection method based on YOLO in complex weather according to claim 5, characterized in that: The loss function in step (2-8) is the cross entropy loss function. The calculation formula of the model parameters corresponding to the fourth differentiable filter is as follows: Pt=α*En(Pi)+(1-α)*Pi Where α is a learnable contrast parameter, which ranges from 0 to 1, preferably 0.75, En(Pi) is the contrast-enhanced version of the input image Pi, and Pi is the pixel value of the contrast image; The loss function in step (2-9) is the cross entropy loss function. The calculation formula of the model parameters corresponding to the fifth differentiable filter is as follows: Pc=1 / TL*(clip(L*Pi-j,0,1)*tk) Among them, tk is the learnable tone parameter, TL is the number of tone parameters, Pi is the pixel value of the tone image, Po is the pixel value of the output image, L is the linear interpolation interval, j is the interpolation index, and j=0,…,L-1. The loss function in step (2-10) is the cross entropy loss function. The calculation formula of the model parameters corresponding to the sixth differentiable filter is as follows: F(x,λ)=I(x)+λ*(I(x)-Gau(I(x))) Wherein, λ is a learnable sharpening parameter, whose value range is 0 to 1, preferably 0.75, I(x) is the pixel value of the sharpened image, and Gau(I(x)) is the Gaussian blur value of the pixel value of the sharpened image I(x).
7. The target detection method based on YOLO in complex weather according to claim 6, characterized in that: The target detection model is the YOLO model, which is trained by the following steps: (3-1) Obtain a set of images to be detected through a perception sensor, and divide the set of images to be detected into a training set and a test set in a ratio of 8:
2. (3-2) Preprocess the training set obtained in step (3-1) to obtain a preprocessed training set. (3-3) For each sample in the preprocessed training set obtained in step (3-2), it is input into the convolutional layer to obtain a feature map corresponding to the sample with a size of 256×256×32. (3-4) For each sample in the preprocessed training set obtained in step (3-2), the feature map of size 256×256×32 corresponding to the sample obtained in step (3-3) is input into the dense module for feature reuse and convolution operations to obtain a feature map of size 256×256×256 corresponding to the sample. (3-5) For each sample in the preprocessed training set obtained in step (3-2), the feature map of size 256×256×256 corresponding to the sample obtained in step (3-4) is input into the transition module for maximum pooling processing to obtain a feature map of size 64×64×256 corresponding to the sample. (3-6) For each sample in the preprocessed training set obtained in step (3-2), an upsampling operation is performed on the feature map of size 64×64×256 corresponding to the sample obtained in step (3-5), and the sampling operation result is fused with the feature map of size 256×256×256 corresponding to the sample obtained in step (3-4), thereby obtaining three feature layers corresponding to the sample with sizes of 64×64, 128×128 and 256×256 respectively. (3-7) For each sample in the preprocessed training set obtained in step (3-2), a 1×1 convolution operation is performed on the three feature layers corresponding to the sample obtained in step (3-6), and the results of the convolution operation are input into two parallel branches respectively, and the output results of the two branches are stacked, and finally the target detection result corresponding to the sample is output. (3-8) For each sample in the preprocessed training set obtained in step (3-2), a loss function is calculated based on the target detection result corresponding to the sample obtained in step (3-7), and the target detection model is iteratively trained using the loss function until the YOLO-based target detection model converges, thereby obtaining a preliminarily trained YOLO-based target detection model. (3-9) The test set obtained in step (3-1) is input into the YOLO-based target detection model preliminarily trained in step (3-8) for verification until the detection accuracy is optimal, thereby obtaining a trained YOLO-based target detection model.
8. The target detection method based on YOLO in complex weather according to claim 7, characterized in that: The loss function calculation formula of the target detection model is: Lt=Ldet+λ*Ldc Among them, λ is the coefficient of GRL, which is used to balance the detection loss and classification loss. Its value range is 0 to 1, preferably 0.
75. Ldet represents the detection loss, and Ldc represents the classification loss.
9. The target detection method based on YOLO in complex weather according to claim 8, characterized in that: The detection loss Ldet uses the Focal Loss loss function, which is calculated as follows: Among them, i represents the i-th prediction box of the sample, i∈[1, the total number of prediction boxes in the sample], j represents the j-th true box of the sample, j∈[1, the total number of prediction boxes in the sample], yij represents the IoU value between the i-th prediction box and the j-th true box, which is used to determine whether it is a positive sample, pij represents the probability that the i-th prediction box belongs to the j-th category, α represents the balance factor, which is 0.5 and is used to balance the number of positive and negative samples, and γ represents the focus parameter, which is 0.25 and is used to focus on difficult samples. The classification loss Ldc uses a binary cross entropy loss function, calculated as: Among them, x and y represent the position coordinates of the sample in the feature map obtained in step (3-3), t represents the true label of the sample, which takes a value of 0 or 1, and p (x,y) Indicates the probability that the target prediction of the sample at the position (x, y) is true.
10. A target detection system based on YOLO in complex weather, characterized in that: include: The first module is used to acquire the image to be detected and preprocess the acquired image to be detected to obtain a preprocessed image. The second module is used to input the image preprocessed by the first module into a pre-trained image processing model for image enhancement processing to obtain an image after image enhancement. The third module is used to input the enhanced image obtained by the second module into a pre-trained target detection model to obtain the final target detection result.
