All-weather-oriented target detection method and system
By rendering image datasets under different weather conditions and improving the YOLOv5 network, a multi-level domain adversarial structure and EIOU loss function are introduced to solve the domain shift problem of the object detection model in changing environments, achieving higher detection accuracy and robustness.
Patent Information
- Application Number
- CN202410877378.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-11-01
AI Technical Summary
Existing object detection models suffer from performance degradation under varying environmental conditions, mainly due to the domain offset between the training dataset and the real-world application dataset. Existing methods are time-consuming, labor-intensive, and may raise privacy concerns.
By employing domain adaptation techniques, a dataset is constructed by rendering images of scenes and target objects under different weather conditions. The YOLOv5 network is improved by introducing a multi-level domain adversarial structure and the EIOU loss function to alleviate domain bias and improve the model's generalization ability.
It significantly improved the model's detection accuracy under different weather conditions, increasing it by 13.5%, and achieved higher target detection accuracy and robustness under extreme weather conditions.
Smart Images

Figure CN118887601A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an all-weather target detection method and system. Background Art
[0002] With the continuous advancement of deep learning technology, object detection models have been widely used in many fields, showing great potential; in order to achieve good detection performance, these models usually need to be trained on a large amount of data collected under ideal environmental conditions, such as clear weather; however, in the real world, models often face changing environmental conditions such as rain, snow, fog or insufficient light, which can significantly degrade the performance of the model; this performance degradation is mainly due to the domain offset between the training dataset (source domain) and the dataset in actual applications (target domain), that is, the inconsistent data distribution.
[0003] To reduce the distribution difference between the source domain and the target domain, existing methods include:
[0004] Directly collect and annotate data sets from a variety of environments and scenarios for training. This method requires a huge amount of data and cannot cover all scenarios in the real world.
[0005] Joint Domain Alignment and Discriminative Feature Learning for Unsupervised Deep Domain Adaptation, for existing public or private datasets, domain adaptation technology is used to match and align the data distribution of the source domain and the target domain.
[0006] Self-Supervised Domain Adaptation for Computer Vision Tasks Self-supervised learning, by guiding the model to learn more general feature representations.
[0007] Unsupervised Multi-Task Domain Adaptation multi-task learning, by training the model to perform multiple tasks simultaneously to enhance its generalization ability; integrated learning, by integrating the predictions of multiple models to improve adaptability to new environments.
[0008] However, none of the above methods take into account that directly collecting and annotating datasets from multiple environments may cause privacy issues, and the annotation process is time-consuming and laborious. Summary of the invention
[0009] In view of the shortcomings of the existing methods, the present invention chooses to adopt domain adaptation technology to effectively reduce the distribution difference between the source domain and the target domain.
[0010] The technical solution adopted by the present invention is: an all-weather target detection method comprises the following steps:
[0011] Step 1: Render images of scenes and target objects under different weather conditions to construct a source domain dataset; collect images of scenes and target objects under different weather conditions in real time to construct a target domain dataset;
[0012] As a preferred implementation of the present invention, Unity 3D is used for rendering.
[0013] As a preferred embodiment of the present invention, the scenes include: city streets, highways, tunnels and rural roads.
[0014] As a preferred embodiment of the present invention, weather conditions include: sunny days, rainy days, foggy days and snowy days.
[0015] Step 2: Build an improved yolov5 network, replace the 1st CBS convolution, the 2nd CBS convolution and the 8th CBS convolution of the backbone with CBS_1 convolution; input the low-level features generated by the 1st and 2nd layers of CBS convolution and the high-level features generated by the 8th layer into the GRL layer to generate pixel-level and semantic-level features that are common to both the source domain and the target domain;
[0016] As a preferred embodiment of the present invention, the CBS_1 convolution includes: conv, GRL layer, Dd, BN normalization and SiLU.
[0017] As a preferred implementation of the present invention, step two also includes: inserting the GRL layer and Dd in sequence between the 12th layer Unsample and the 13th layer Concat of the improved yolov5 network neck.
[0018] As a preferred embodiment of the present invention, Dd includes: four groups of fully connected layers and Relu activation functions are connected in series, then pass through a fully connected layer and a Softmax function, and output the probability distribution of each domain.
[0019] Step 3: Input the data set containing the source domain and the target domain into the improved yolov5 network for training, and use the minimization loss function to converge the model.
[0020] As a preferred implementation of the present invention, the minimization loss function adopts EIOU.
[0021] As a preferred embodiment of the present invention, an all-weather target detection system includes: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement an all-weather target detection method.
[0022] As a preferred embodiment of the present invention, a computer readable medium stores computer program code, and the computer program code implements an all-weather target detection method when executed by a processor.
[0023] Beneficial effects of the present invention:
[0024] 1. Taking yolov5 as the benchmark detector, a new domain adaptation module is added on its basis to alleviate the domain shift problem;
[0025] 2. Introduce pixel-level domain adversarial structures in the low layers of the backbone network to alleviate local feature differences (such as texture and color), and introduce image-level domain adversarial structures in the high layers of the backbone network to alleviate global feature differences (such as image layout and object composition); introduce image-level domain adversarial structures after the fusion of multiple feature layers in the neck network to further alleviate global feature differences from higher semantic levels and multiple scales; in addition, we use EIOU, which is more sensitive to small targets and has better robustness than IOU, and can locate targets more accurately;
[0026] 3. The final loss function of the entire model consists of two parts: the loss of the detection task and the loss of domain adaptation. The detection task itself includes classification and regression losses, and the loss of domain adaptation includes the loss of two domain discriminators of the backbone network and the loss of one domain discriminator of the neck network. This loss function design enables the model to maintain its original performance in the source domain, while reducing the distribution difference between the source domain and the target domain, and promoting the generalization ability of the model in the target domain.
[0027] 4. Experimental tests are conducted on multiple benchmark datasets, namely migrating street view data from sunny weather to extreme weather (rain, fog, snow, hail, etc.). The results show that the proposed scheme significantly outperforms the original YOLOv5 and the most advanced domain adaptation method. In the most general Foggy-Cityscapes to Cityscapes task, the mAP exceeds the original YOLOv5 method by 13.5%, greatly improving the detector's ability to adapt to different weather environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is the all-weather target detection logic block diagram of the present invention;
[0029] Figure 2 It is the improved yolov5 network structure diagram of the present invention;
[0030] Figure 3 The structure diagram of the domain discriminator;
[0031] Figure 4 (a) and (b) are the detection effect diagrams in different scenes. DETAILED DESCRIPTION
[0032] The present invention is further described below in conjunction with the accompanying drawings and embodiments. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore it only shows the components related to the present invention.
[0033] like Figure 1 As shown, an all-weather target detection method includes the following steps:
[0034] Step 1: Render the image, construct a source domain dataset, collect a target domain dataset, and build a source domain dataset and a target domain dataset;
[0035] First, a scene and a target object should be selected, and the materials and textures of the scene and the object should be set. Secondly, a suitable rendering engine and parameters should be selected to perform the rendering process. For example, when using Unity 3D to render the training environment of an autonomous vehicle, it is crucial to simulate various driving environments including urban streets, highways, tunnels, and rural roads. The rendered images need to show in detail the changes in lighting from sunrise to daytime, dusk to night, and the visual effects under different weather conditions such as sunny days, rainy days, foggy days, and snowy days. In addition, the environment should also include dynamic elements on the road, such as moving vehicles, pedestrians crossing the road, and changing traffic lights, as well as static objects such as roadside buildings, roadside trees, and road signs, so that the synthesized image can truly reflect the complexity and diversity of the real world, enabling it to be correctly identified and predicted under various conditions. During the rendering process, the position and bounding box of each object on the image are automatically calculated, and labels and other related attributes such as categories and colors are assigned to each object, thereby automatically generating labels to form a labeled source domain dataset.
[0036] Install a monocular camera on an autonomous intelligent system, such as a drone, robot, or self-driving vehicle; place it in a scene in a real environment, collect images of the scene, and form an unlabeled target domain dataset; divide the target domain into training and test sets in a ratio of 8:2; convert the constructed source and target domain datasets into the YOLO format, with the data volume of the source and target domains being 2:1.
[0037] Step 2: Build an adaptive target detection model based on yolov5. The improved part is to propose a multi-level fine-grained domain adversarial structure to align the intermediate features extracted by yolov5.
[0038] Step 21: Figure 2As shown in the figure, a CBS_1 module is constructed. The CBS_1 convolution includes: conv, GRL (Gradient Reversal Layer), Dd (domain discriminator), BN normalization and SiLU; the first CBS convolution, the second CBS convolution and the eighth CBS convolution of the backbone network of yolov5 are replaced by CBS_1 convolution. The first and second CBS_1 convolutions perform low-level feature extraction on the input image, that is, the extracted low-level features focus on details and local information, while the eighth convolution performs more advanced semantic feature extraction on the previously extracted features, including context and global information, so that the yolov5 model learns domain-invariant features at different levels (pixel level and semantic level).
[0039] The low-level and high-level features generated by the 1st, 2nd, and 8th layers of CBS convolution are fed into the gradient reversal layer. During the front-end propagation process, GRL is equivalent to an identity function, that is, assuming that x is the input of GRL, then the output y of GRL is simply equal to x. The features passing through it are not changed, and the model can make predictions normally. However, during the back-propagation process, the direction of the gradient is reversed, so that the parameter update direction of the feature extractor is opposite, thereby encouraging the feature representation generated by the feature extractor to confuse the domain discriminator, making it difficult to distinguish the domain to which the feature belongs. In this way, the feature extractor is trained to generate pixel-level and semantic-level features that are common to both the source domain and the target domain, rather than features specific to a certain domain.
[0040] The specific process of back propagation:
[0041] The transferred gradient is multiplied by a negative number, usually -1, so that the parameter update direction of the feature extractor is opposite. This gradient is the gradient of the relevant parameters of the feature extractor calculated by the binary classification loss function of Dd. The purpose is to allow GRL to "cheat" the feature extractor and encourage it to produce features that are difficult for the domain discriminator to distinguish, so as to reduce the distribution difference between the source domain and the target domain.
[0042] Step 22. In the neck network, GRL and Dd are inserted between the 12th layer Unsample and the 13th layer Concat; GRL and Dd are inserted between the 16th layer Unsample and the 17th layer Concat; these two positions generate feature maps of different scales, aggregating the feature representations of low and high layers, but in the example, due to the influence of fog, the features of some targets such as bicycles, pedestrians, cars, etc. are still quite different from those in clear weather. Therefore, GRL and Dd are added at this position to further enhance the target-invariant features in the aggregated feature maps. This multi-level domain adaptation method helps the yolov5 model achieve better generalization ability and higher accuracy in the target domain.
[0043] Add Dd after GRL: The features processed by GRL (the features are the features of the output of GRL forward propagation) are then input to Dd, which processes these features through one or more fully connected layers, such as Figure 3 As shown in the figure, Dd is composed of four groups of fully connected layers and Relu activation functions connected in series, and then passes through the fully connected layer and Softmax function to output the probability distribution of each domain to determine whether these features belong to the source domain or the target domain, and the cross entropy loss is used to calculate the loss probability.
[0044] The source domain and part of the target domain data set are input into the improved yolov5 model, and the feature extraction network is used to extract features from the source domain and the target domain. The extracted features flow through GRL for forward propagation; and the features passing through the GRL layer are used to train Dd to distinguish whether the features come from the source domain or the target domain; and the loss function based on Dd is used to calculate the gradient of the relevant parameters of the feature extractor. The relevant parameters include the network structure parameters and some hyperparameters in the training process. During the back propagation process, the gradient transmission direction is changed to update the parameter weights of the feature extractor, so that the features generated by the feature extractor are difficult to distinguish by Dd, and the cycle is repeated until the iteration ends.
[0045] Step 3: Input the dataset containing the source domain and the target domain into the improved yolov5 network for training, converge the model by minimizing the loss function, and obtain the weight file;
[0046] EIOU is used to replace the original loss function; EIOU loss consists of three parts: overlap loss, center distance loss, and width and height loss, which can speed up the convergence of the model and make it more sensitive to small targets.
[0047] After training, save the weight file containing the improved yolov5 model and domain discriminator.
[0048] Deploy the weight file to the improved yolov5 model, test it on the test set of the target domain, and check the final effect.
[0049] Deploy the improved yolov5 model into the autonomous intelligent system to achieve real-time detection in all-weather environments;
[0050] The improved yolov5 model is deployed to the hardware end of the autonomous intelligent system. First, the image is acquired through the monocular camera installed in the autonomous intelligent system. Secondly, the acquired image is preprocessed, including adjusting the image size and normalization. Finally, the image is input into the detection model, and the detection result is output, that is, the target in the current scene is identified and located.
[0051] like Figure 4 (a) and (b) are the recognition effect diagrams under two different climatic conditions, different scenes and different targets. It can be seen that the target objects under different conditions can be accurately identified; the accuracy of the improved yolov5 model is compared with the yolov5 model, and the overall accuracy is improved by 13.5%.
[0052] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A target detection method for all-weather, characterized in that: The following steps are involved: Step 1: Render images of scenes and target objects under different weather conditions to construct a source domain dataset; Collect images of scenes and target objects under different weather conditions in real time to build a target domain dataset; Step 2: Build an improved yolov5 network, replace the 1st CBS convolution, the 2nd CBS convolution and the 8th CBS convolution of the backbone with CBS_1 convolution; input the low-level features generated by the 1st and 2nd layers of CBS convolution and the high-level features generated by the 8th layer into the GRL layer to generate pixel-level and semantic-level features for the source and target domains; Step 3: Input the data set containing the source domain and the target domain into the improved yolov5 network for training, and use the minimization loss function to converge the model.
2. The all-weather target detection method according to claim 1, characterized in that: CBS_1 convolution includes: conv, GRL layer, Dd, BN normalization and SiLU.
3. The all-weather target detection method and system according to claim 1, characterized in that: Step 2 also includes: inserting the GRL layer and Dd in sequence between the 12th layer Unsample and the 13th layer Concat of the improved yolov5 network neck.
4. The all-weather target detection method according to claim 3, characterized in that: Dd includes: four groups of fully connected layers and Relu activation functions connected in series, then passing through a fully connected layer and a Softmax function, and outputting the probability distribution of each domain.
5. The all-weather target detection method according to claim 1, characterized in that: The loss function to be minimized is EIOU.
6. The all-weather target detection method according to claim 1, characterized in that: Rendering is done using Unity 3D.
7. The all-weather target detection method according to claim 1, characterized in that: Scenarios include: City streets, highways, tunnels and country roads.
8. The all-weather target detection method and system according to claim 1, characterized in that: Weather conditions include: sunny, rainy, foggy and snowy.
9. The all-weather target detection system is characterized by: include: a memory for storing instructions executable by a processor; A processor, configured to execute instructions to implement the all-weather target detection method as described in any one of claims 1 to 8.
10. A computer readable medium storing computer program code, characterized in that: When the computer program code is executed by a processor, the computer program code implements the all-weather target detection method as described in any one of claims 1 to 8.
