A method for detecting small-target floating debris based on an improved YOLOv7 model
By improving the neck network of the YOLOv7 model and introducing dilated convolution and contextual feature information enhancement modules, the accuracy problem of detecting small-sized floating debris targets was solved, achieving higher detection accuracy and real-time performance.
Patent Information
- Application Number
- CN202311219251.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-20
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-09-20
AI Technical Summary
The existing YOLOv7 model lacks attention to small targets when detecting small floating debris, resulting in low detection accuracy, especially in complex water environments where it is difficult to identify small floating objects.
By introducing dilated convolution and contextual feature enhancement modules, the neck network of the YOLOv7 model is improved. Through the dilated spatial pyramid pooling module ASPP and the contextual content enhancement module CAM, more contextual information is obtained, enriching the feature fusion network and improving the small object detection capability.
It improves the model's accuracy in detecting small targets, reduces false negatives and missed detections, and has better recognition performance, especially under complex lighting and environmental conditions, while maintaining the efficiency of real-time detection.
Smart Images

Figure CN117292313B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a waste detection and classification technology, and more particularly to a method for detecting small-target floating waste based on an improved YOLOv7 model. Background Technology
[0002] Waste disposal has become a crucial issue for social development and environmental protection. Waste detection technology can automate waste sorting, improving accuracy and efficiency while reducing the workload and labor costs of waste disposal. However, current waste detection faces many challenges, such as the wide variety and high similarity of waste types, irregular sizes leading to obstruction and deformation, and significant interference and noise in the detection environment.
[0003] Among current detection methods, deep learning-based object detection methods are more direct and efficient. By training on large amounts of image or video data, they automatically extract features and learn object classification knowledge using algorithms such as Convolutional Neural Networks (CNNs). The YOLO (You Only Look Once) object detection algorithm can learn highly generalized features, achieving high detection accuracy and fast detection speed. YOLOv7, as the next generation of the YOLO series, has significantly improved both accuracy and speed. However, for current garbage detection tasks, because the network model focuses more on large and medium-sized targets and lacks attention to small targets, it leads to false positives and false negatives when detecting small-sized garbage targets with limited feature information. Especially for the detection of floating objects in aquatic environments, small floating objects are easily affected by factors such as water surface and lighting, making them difficult to identify. Their small size and blurred feature information are further amplified, thus requiring algorithm improvements to enhance the detection accuracy of small targets. Summary of the Invention
[0004] Traditional benchmark models and methods lack specificity when detecting small, undefined garbage targets in complex scenarios, and struggle to address the issue of lost feature information for small targets. To address this, we propose a small target detection method based on an improved YOLOv7 model. This method introduces contextual feature enhancement to obtain more information about small targets, enabling the detection of small garbage targets in complex scenarios.
[0005] The technical solution of this invention is as follows:
[0006] A method for detecting small floating debris based on an improved YOLOv7 model includes the following steps:
[0007] Step 1: Obtain the floating debris detection dataset from the perspective of the unmanned vessel, and divide it into training set, validation set and test set;
[0008] Step 2: Construct a small-target floating debris detection model based on the improved YOLOv7 model:
[0009] A benchmark model for detecting small-target floating debris based on YOLOv7 is constructed, consisting of an input network, a backbone network, a neck network, and a detection network.
[0010] Improvements to the neck network: Introduce dilated convolutions to improve the feature fusion part in the neck network, replace the spatial pyramid pooling module with the dilated spatial pyramid pooling module ASPP, and embed the context content enhancement module CAM. Use dilated convolutions with different dilation rates to obtain context information of different receptive fields, and inject them into the feature fusion network from top to bottom to enrich the context information.
[0011] Step 3: Train the small target floating debris detection model based on the improved YOLOv7 model, and perform detection on the test set to verify the superiority of the small target floating debris detection model based on the improved YOLOv7 model in the detection results.
[0012] Furthermore, the YOLOv7-based benchmark model for small-target floating debris detection in step 2 is as follows:
[0013] The input image is first preprocessed at the input end. The backbone network extracts features from the input image and inputs the extracted features into the neck network for feature fusion. The neck network follows the bidirectional feature fusion structure of the Feature Pyramid Network (FPN) and the Path Enhancement Network (PAN). The detection network maps each grid on the feature map to three output tensors, which correspond to the position, category, and confidence of the predicted box, respectively.
[0014] Furthermore, the backbone network in step 2 specifically includes:
[0015] The backbone network includes Conv, ELAN1, and MPConv modules. The pre-processed image is input into the backbone network, passes through four Conv modules, and then passes through three ELAN1 and MPConv modules in sequence. The output is then passed through the ELAN1 module to complete the feature extraction of the data. The Conv module consists of convolutional layers, batch normalization layers, and activation functions.
[0016] The ELAN1 module consists of four branches. The first and second branches are both 1×1 convolutional layers used for dimensionality reduction. The third branch performs two 3×3 convolutional layers with a stride of 1 after obtaining the output of the 1×1 convolution of the second branch. The fourth branch performs two more 3×3 convolutional layers with a stride of 1 after obtaining the output of the second 3×3 convolutional module of the previous branch.
[0017] The MPConv module consists of two branches. The first branch includes a max pooling layer and a 1×1 convolutional layer, while the second branch includes a 1×1 convolutional layer and a 3×3 convolutional layer with a stride of 2.
[0018] Furthermore, the improved neck network in step 2 is specifically as follows:
[0019] The improved neck network consists of ASPP module, Conv module, Upsample module, CAM module, ELAN2 module, and MPConv module;
[0020] After feature fusion is completed in the ASPP module, the output is input into the Conv module for dimensionality reduction and parameter reduction to obtain a new feature map. Then, the obtained feature map is input into the Upsample module for upsampling. Finally, the upsampled result is input into the CAM module.
[0021] Following the CAM module, the outputs of the four Conv modules, the first ELAN1 module, and the second ELAN1 module after the MPConv module in the previous backbone network are input into the Conv module. The result is then concatenated with the output of the CAM module to obtain the fused context information. After that, the ELAN2 module completes the extraction of feature information. After the ELAN2 module, the Conv and Upsample modules upsample the information from the previous context. Next, the outputs of the four Conv modules, two ELAN1 modules, and the third ELAN1 module after the MPConv module in the previous backbone network are input into the Conv module, and the result is concatenated with the upsampled information. After that, the information passes through the ELAN2 and MPConv modules in sequence, and is concatenated with the information from different layers above, respectively completing the acquisition of feature information at different scales for small, medium, and large targets, so that the different information obtained can be used for classification and regression prediction in the subsequent detection network.
[0022] Furthermore, the ASPP module in step 2 specifically includes:
[0023] The ASPP module consists of 1×1 convolutions, a pooling pyramid, and a pooling module. The pooling pyramid is composed of 3×3 convolutions with dilation rates of 6, 12, and 18, obtaining different feature maps through different dilated convolution ratios. The pooling module consists of an AdaptiveAvgPool2d layer, 1×1 convolutions, and upsampling. The AdaptiveAvgPool2d layer does not require specifying the kernel size and stride; only the final output size needs to be determined. It extracts features from each channel by compressing the feature maps of each channel to 1×1, thereby obtaining global feature information. The 1×1 convolutional layer further extracts and reduces the dimensionality of the features obtained in the previous step. Finally, upsampling restores the feature maps from 1×1 back to their original size. The feature maps obtained from the dimensionality reduction of the 1×1 convolutional layer, the feature maps generated by the three types of dilated convolutions, and the feature maps generated by the pooling module are concatenated to obtain information with multiple receptive fields. Finally, dimensionality reduction is performed again through a 1×1 convolution to obtain the final feature information.
[0024] Furthermore, the CAM module in step 2 specifically includes:
[0025] The CAM module consists of two parts: feature extraction and feature fusion. The feature extraction part uses 3×3 convolutions with dilation rates of 1, 3, and 5, and then feeds the acquired feature information into the feature fusion part. The feature fusion part provides three fusion methods: weighted fusion, adaptive fusion, and cascaded fusion. Weighted fusion adds the obtained feature information pixel by pixel. The left branch of adaptive fusion obtains the attention weights between channels through two 1×1 convolutional layers, Concat concatenation, and a normalization module, and calculates a weighted sum with the original input of the right branch to aggregate the context information to the output. Cascaded fusion concatenates the feature maps generated by the three types of convolutions.
[0026] Furthermore, the detection network in step 2 is specifically as follows:
[0027] The detection network has three branches, each predicting features at three different scales. These branches include the RepConv module and the Detect module. During training, the RepConv module consists of three branches: the first branch is a 3×3 convolutional module with a stride of 1 and a batch normalization (BN) layer; the second branch is a 1×1 convolutional module with a BN layer; and the third branch is a BN layer. The three branches are summed to obtain the output. During deployment, it consists only of a 3×3 convolutional module with a stride of 1 and a normalized BN layer, greatly accelerating inference. The RepConv module inputs its output into the Detect module to use a classification and regression network to predict the location, category, and confidence information of the corresponding bounding box.
[0028] Furthermore, the training operation in step 3 is as follows:
[0029] The system is trained using a training set, and the overall loss is calculated using a loss function. The loss function consists of three main parts: bounding box regression loss, confidence loss, and classification loss. The bounding box regression loss measures the model's regression accuracy for the target bounding box, evaluating its regression ability by calculating the difference between the predicted and ground truth bounding boxes. The confidence loss measures the model's confidence in the existence of the target; it evaluates the model's confidence by calculating the IoU between the predicted and ground truth bounding boxes. The classification loss measures the model's accuracy in classifying the target category; it evaluates the model's classification ability by calculating the cross-entropy loss between the predicted and ground truth categories. The network weights are continuously optimized during training using the loss function until the loss converges, thereby improving the accuracy and robustness of object detection.
[0030] Furthermore, the test verification operation in step 3 is as follows:
[0031] The improved YOLOv7 model for detecting small floating debris was tested and validated on a test set. The model performance was evaluated using evaluation metrics, including precision, recall, mean precision, and frames per second. The results were compared with those of current popular object detection algorithms.
[0032] The beneficial effects of this invention are as follows:
[0033] By improving the feature fusion network of the YOLOv7 model, a hollow spatial pyramid pooling module and a contextual content enhancement module were introduced. This allowed for the acquisition of information from different receptive fields, and the obtained feature information was injected into the feature fusion network from top to bottom to enrich the contextual information, resulting in more salient features of the target object and thus improving the model's multi-scale detection capability. This not only improved the detection performance for large and medium-sized targets but also acquired more global information for small targets, reducing false negatives and missed detections for small targets. It also showed better recognition performance for litter targets affected by lighting and environmental factors. Furthermore, the improved model did not introduce excessive parameters or computational overhead, ensuring good real-time detection performance and facilitating practical deployment.
[0034] Compared with the original model and some popular network models, this invention has better detection performance, reduced false negatives and false positives, and improved confidence in the detected objects. Attached Figure Description
[0035] Figure 1 This is a structural diagram of the improved YOLOv7 model of this invention;
[0036] Figure 2 This is a structural diagram of the hollow space pyramid pooling module ASPP of the present invention;
[0037] Figure 3 This is a structural diagram of the Contextual Content Enhancement Module (CAM) of the present invention;
[0038] Figure 4 The diagram shows the structure of the three fusion methods of the CAM module of this invention (a: weighted fusion; b: adaptive fusion; c: cascaded fusion).
[0039] Figure 5 This is a comparison chart of the detection results of the present invention. Detailed Implementation
[0040] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.
[0041] A method for detecting small floating debris based on an improved YOLOv7 model, the specific steps of which are as follows:
[0042] Step 1: Obtain the FloW-Img dataset, which shows floating debris detection from the perspective of an unmanned surface vessel. The FloW-Img dataset contains 2000 images of floating debris and 5271 labeled targets, with small targets (less than 32×32 pixels) making up more than half of them. The images were captured under different lighting and wave conditions, and the targets were observed from different directions and perspectives.
[0043] The dataset is divided into training, validation, and test sets in a 6:2:2 ratio, with 1200 images in the training set, and 400 images each in the validation and test sets. The dataset contains only one class: the bottle class.
[0044] Step 2: Build an improved YOLOv7 model for detecting small floating debris.
[0045] The YOLOv7 model network architecture is mainly divided into the input network, backbone network, neck network, and detection network.
[0046] The input network first preprocesses the input image, including data augmentation, adaptive anchor box calculation, and adaptive image scaling. The backbone network extracts features from the input image, and these extracted features are then fed into the neck network for feature fusion. The neck network follows a bidirectional feature fusion structure of Feature Pyramid Network (FPN) + Path Aggregation Network (PAN). The detection network maps each grid cell on the feature map to three output tensors, corresponding to the predicted bounding box's location, class, and confidence level, respectively.
[0047] This invention primarily improves the neck network feature fusion module; the network structure of other parts remains consistent with the original YOLOv7 model. The improved model is as follows: Figure 1 As shown.
[0048] The backbone network includes Conv (Convolution) modules, ELAN1 (Efficient Layer Aggregation Networks) modules, and MPConv (MaxPool Convolution) modules. The pre-processed image is input into the backbone network, passing through four Conv modules, then three ELAN1 and MPConv modules sequentially. The output is then passed through the ELAN1 module to complete feature extraction. The Conv module consists of convolutional layers (Conv), batch normalization (BN) layers, and an activation function (SiLU). The ELAN1 module consists of four branches: the first and second branches are both 1×1 convolutional layers used for dimensionality reduction; the third branch, after obtaining the output of the second branch's 1×1 convolution, performs two 3×3 convolutional layers with a stride of 1; the fourth branch, after obtaining the output of the second 3×3 convolutional module in the previous branch, performs two more 3×3 convolutional layers with a stride of 1. The MPConv module consists of two branches. The first branch includes a max pooling layer and a 1×1 convolutional layer, while the second branch includes a 1×1 convolutional layer and a 3×3 convolutional layer with a stride of 2.
[0049] The improved neck network consists of the ASPP (Atrous Spatial Pyramid Pooling) module, the Conv module, the Upsample module, the CAM (Context Augmentation Module), the ELAN2 module, and the MPConv module.
[0050] like Figure 2As shown, the ASPP module consists of 1×1 convolutions, a pooling pyramid, and a pooling module. The pooling pyramid is composed of 3×3 convolutions with dilation rates of 6, 12, and 18, obtaining different feature maps through different dilated convolution ratios. The pooling module consists of an AdaptiveAvgPool2d layer, 1×1 convolutions, and upsampling. The AdaptiveAvgPool2d layer does not require specifying the kernel size and stride; only the final output size needs to be determined. By compressing the feature maps of each channel to 1×1, features of each channel are extracted, thus obtaining global feature information. The 1×1 convolutional layer further extracts and reduces the dimensionality of the features obtained in the previous step. Finally, upsampling restores the feature maps from 1×1 back to their original size. The feature maps obtained from the dimensionality reduction of the 1×1 convolutional layer, the feature maps generated by the three types of dilated convolutions, and the feature maps generated by the pooling module are concatenated to obtain information with multiple receptive fields. Finally, dimensionality reduction is performed again using a 1×1 convolution to obtain the final feature information.
[0051] After feature fusion is completed in the ASPP module, the output is input into the Conv module for dimensionality reduction to decrease the number of parameters. Then, the resulting feature map is input into the Upsample module for upsampling. Finally, the upsampled result is input into the CAM module.
[0052] like Figure 3 As shown, the CAM module consists of two parts: feature extraction and feature fusion. The feature extraction part uses 3×3 convolutions with dilation rates of 1, 3, and 5, and then feeds the acquired feature information into the feature fusion part. Figure 4 As shown in (a), (b), and (c), the feature fusion part provides three fusion methods: weighted fusion, adaptive fusion, and cascaded fusion. Weighted fusion adds the obtained feature information pixel by pixel; the left branch of adaptive fusion obtains the attention weights between channels through two 1×1 convolutional layers, Concat (stitching), and Softmax (normalization) modules, and calculates a weighted sum with the original input of the right branch to aggregate the context information to the output; cascaded fusion stitches together the feature maps generated by the three convolutions.
[0053] Following the CAM module, the output of CAM is concatenated with the output of the second ELAN1 module of the backbone network, and then concatenated with the output of the Conv module to obtain the feature information of the fused context. This is then processed by the ELAN2 module to extract the feature information. The ELAN2 module differs from the ELAN1 module in that it has six branches. After the second branch, the output of the previous branch is passed through a 3×3 convolutional layer with a stride of 1 to obtain a new output. Finally, the results of the six branches are concatenated. Following the ELAN2 module, the Conv and Upsample modules upsample the context information.
[0054] Next, the upsampled information is concatenated with the output of the third ELAN1 module of the backbone network and the result obtained from the Conv module. Then, it passes through the ELAN2 and MPConv modules in sequence, and is concatenated with the information from different layers above, to complete the acquisition of feature information of small, medium and large targets at different scales, so that the different information obtained can be used for classification and regression prediction of the subsequent detection network.
[0055] The detection network has three branches, predicting features at three different scales: the RepConv (Re-param Convolution) module and the Detect module. During training, the RepConv module consists of three branches: the first is a 3×3 convolutional module with a stride of 1 and a batch normalization (BN) layer; the second is a 1×1 convolutional module with a batch normalization (BN) layer; and the third is a batch normalization (BN) layer. The three branches are summed to obtain the output. During deployment, it consists only of a 1×3 convolutional module with a stride of 1 and a batch normalization (BN) layer, significantly accelerating inference. The RepConv module inputs the output into the Detect module, which uses a classification and regression network to predict the location, category, and confidence information of the corresponding bounding box.
[0056] Step 3: Use the images of floating debris on the water surface from the perspective of the unmanned vessel obtained in Step 1 to train the small target floating debris detection model based on the improved YOLOv7. Then, perform detection on the test set to verify the superiority of the small target floating debris detection model based on the improved YOLOv7 in terms of detection results.
[0057] 1) Parameter settings
[0058] The CPU used in the experiment was an Intel(R) Core(TM) i7-11800H@2.30GHz, and the graphics card was an NVIDIA GeForce RTX 3050Ti; the software environment was Windows 10, Python 3.8, CUDA 11.8, cuDNN 8, and PyTorch 1.12.
[0059] The training hyperparameter settings include: epoch set to 200, batch size set to 8, Adam optimizer selected for training, initial learning rate set to 0.01, momentum set to 0.937, and weight decay coefficient set to 0.0005.
[0060] 2) Model Training
[0061] An improved YOLOv7 model was trained using a training set, and its overall loss was calculated using a loss function. The loss function consists of three main parts: bounding box regression loss, confidence loss, and classification loss. The bounding box regression loss measures the model's accuracy in regressing target bounding boxes, evaluating its regression ability by calculating the difference between the predicted and ground truth bounding boxes. The predicted bounding box is the box calculated by the detection model to identify the detected target; the ground truth bounding box is the manually labeled target location. The confidence loss measures the model's confidence in the existence of the target. It evaluates the model's confidence by calculating the IoU (Intersection over Union) between the predicted and ground truth bounding boxes. The classification loss measures the model's accuracy in classifying the target category. It evaluates the model's classification ability by calculating the cross-entropy loss between the predicted and ground truth categories. The network weights are continuously optimized during training using the loss function until the loss converges, thereby improving the accuracy and robustness of object detection.
[0062] 3) Model Testing
[0063] The trained small-target floating debris detection model based on the improved YOLOv7 was tested and validated on the test set. The model performance was evaluated using the following metrics: precision, recall, mean average precision (mAP), and frames per second (FPS). The relevant calculation formulas are as follows:
[0064] TP represents the number of correctly detected samples, and FP represents the number of incorrectly detected samples.
[0065] FN represents the number of samples that were missed.
[0066] The value of AP is the area enclosed by the Precision-Recall curve.
[0067] AP i represents the average precision of a certain category in the dataset, and c represents the number of categories.
[0068] Using the same experimental equipment, dataset, and parameters, we compared our model with current popular object detection models. The comparison results are shown in Table 1.
[0069]
[0070] As can be seen from Table 1, compared with the currently popular YOLOv3, YOLOv5, and YOLOv7 models, although the method of this invention has a slightly increased number of parameters and computational cost, the mean detection accuracy mAP is significantly improved. 0.5 and mAP 0.5:0.95 It outperforms other models in all aspects, and its FPS is also higher than that of YOLOv3 and YOLOv5 models. It has certain advantages in detection speed and detection accuracy, and can better meet the real-time requirements.
[0071] like Figure 5 As shown, this image compares the detection results of YOLOv5, YOLOv7, and an improved small object detection algorithm for the same image. The YOLOv5 and YOLOv7 models exhibit varying degrees of false negatives and false negatives when detecting small objects, while the improved YOLOv7 algorithm demonstrates higher detection accuracy.
[0072] The above-described embodiments are merely one implementation of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention should be determined by the appended claims.
Claims
1. A small target floating garbage detection method based on an improved YOLOv7 model, characterized in that, The method comprises the following steps: Step 1: Obtain the water surface floating garbage detection data set under the perspective of an unmanned ship, and divide the training set, the verification set and the test set; Step 2: Construct a small target floating garbage detection model based on an improved YOLOv7 model: The small target floating garbage detection benchmark model based on YOLOv7 is constructed, which is divided into an input end, a backbone network, a neck network and a detection network; The neck network is improved: a cavity convolution is introduced to improve the feature fusion part in the neck network, an ASPP module is used to replace a spatial pyramid pooling module, and a CAM module is embedded, different dilated rates of the cavity convolution are used to obtain context information of different receptive fields, and the context information is injected into a feature fusion network from top to bottom to enrich the context information; The improved neck network is composed of an ASPP module, a Conv module, an Upsample module, a CAM module, an ELAN2 module and an MPConv module; After the feature fusion of the ASPP module is completed, the output result obtained is input into the Conv module to reduce parameters through dimension reduction, and a new feature map is obtained; then the obtained feature map is input into the Upsample module for upsampling; then the result obtained through the upsampling is input into the CAM module; After the CAM module, the output results of the four Conv modules, the first ELAN1 module and the second ELAN1 module after the MPConv module in the previous part of the backbone network are input into the Conv module, and the obtained results are concatenated with the output results of the CAM module to obtain information fused with the context; then the feature information is extracted through the ELAN2 module; the context information is upsampled through the Conv and Upsample modules after the ELAN2 module; then the output results of the four Conv modules, the two ELAN1 modules and the third ELAN1 module after the MPConv module in the previous part of the backbone network are input into the Conv module, and the results are concatenated with the upsampled information; then the ELAN2 and MPConv modules are sequentially passed through, and the information of different layers is concatenated, so as to obtain different scale feature information of small targets, medium targets and large targets, so that the obtained different information is used for classification and regression prediction in the detection network; The ELAN1 module is composed of four branches, the first branch and the second branch are both a 1x1 convolution layer for dimension reduction; the third branch is obtained after the second branch 1x1 convolution output result, and then two 3x3 convolution layers with a step of 1 are performed; the fourth branch is obtained after the output result of the second 3x3 convolution module of the previous branch, and then two 3x3 convolution layers with a step of 1 are performed again; the ELAN2 module is different from the ELAN1 module in that it has six branches, after the second branch, the output of the previous branch is sequentially passed through a 3x3 convolution layer with a step of 1 to obtain a new output, and finally the results of the six branches are concatenated; Step 3: Train the small target floating garbage detection model based on the improved YOLOv7 model, and detect the trained model on the test set to verify the superiority of the small target floating garbage detection model based on the improved YOLOv7 model in the detection result.
2. The small target floating garbage detection method based on the improved YOLOv7 model according to claim 1, characterized in that, The small target floating garbage detection benchmark model based on YOLOv7 in step 2 is specifically: The input end first preprocesses the input picture, and the backbone network extracts the features of the input picture, and inputs the extracted features into the neck network for feature fusion. The neck network follows the bidirectional feature fusion structure of the feature pyramid FPN and the path enhancement network PAN; The detection network maps each grid on the feature map to three output tensors, corresponding to the position, category and confidence of the prediction box respectively.
3. The small target floating garbage detection method based on the improved YOLOv7 model according to claim 2, characterized in that, The backbone network in step 2 is specifically: The backbone network includes Conv module, ELAN1 module and MPConv module; the input end inputs the preprocessed picture into the backbone network, and after passing through four Conv modules, it successively passes through three ELAN1 and MPConv modules, and the obtained output result is further processed by the ELAN1 module to complete the feature extraction of the data; the Conv module is composed of a convolution layer, a batch normalization layer and an activation function; The MPConv module is composed of two branches, the first branch includes a maximum pooling layer and a 1x1 convolution layer, and the second branch includes a 1x1 convolution layer and a 3x3 convolution layer with a step of 2.
4. The small target floating garbage detection method based on the improved YOLOv7 model according to claim 3, characterized in that, The ASPP module in step 2 is specifically: The ASPP module is composed of a 1x1 convolution, a pooling pyramid and a pooling module; wherein the pooling pyramid is composed of 3x3 convolutions with dilation rates of 6, 12 and 18 respectively, and different feature maps are obtained by using different rates of hole convolution; the pooling module is composed of an AdaptiveAvgPool2d layer, a 1x1 convolution and an upsampling; the AdaptiveAvgPool2d layer does not need to specify the convolution kernel size and step, only needs to confirm the final output size, by compressing the feature maps of each channel to 1x1 respectively, the features of each channel are extracted, and the global feature information is obtained; the 1x1 convolution layer is further extracted and dimensionally reduced; finally, the upsampling is used to restore the feature map from 1x1 to the original size; the feature map obtained by dimensionally reducing the 1x1 convolution layer, the feature map generated by the three kinds of hole convolution, and the feature map generated by the pooling module are spliced to obtain information with multiple receptive fields, and finally the 1x1 convolution is used for dimension reduction to obtain the final feature information.
5. The method for detecting small floating garbage based on the improved YOLOv7 model according to claim 3, characterized in that, The CAM module in step 2 is specifically: The CAM module is composed of feature extraction and feature fusion; the feature extraction part uses 3x3 convolutions with dilation rates of 1, 3 and 5 respectively, and then sends the obtained feature information to the feature fusion part; The feature fusion part provides three fusion methods, which are weighted fusion, adaptive fusion and cascade fusion; The weighted fusion adds the obtained feature information between pixels; The adaptive fusion left branch obtains the attention weight between channels through two 1x1 convolution layers, a Concat splicing and a normalization module, and calculates a weighted sum with the original input of the right branch to aggregate the context information to the output; The cascaded fusion is to splice the feature maps generated by the three convolutions.
6. The method for detecting small floating garbage based on the improved YOLOv7 model according to claim 2, characterized in that, The detection network in step 2 is specifically: The detection network has three branches for predicting features of three different scales, including a RepConv module and a Detect module. The RepConv module is composed of three branches during training. The first branch is a 3x3 convolution module with a step of 1 and a BN layer; the second branch is a 1x1 convolution module and a BN layer; and the third branch is a BN layer. The three branches are added to obtain the output result. During deployment, only a 3x3 convolution module with a step of 1 and a normalization BN layer are used, which greatly speeds up the inference. The RepConv module inputs the output result into the Detect module to use a classification regression network to predict the position, category and confidence information of the corresponding bounding box.
7. The method according to claim 1, wherein, The training operation in step 3 is specifically: The training set is used for training, and the overall loss is calculated through a loss function. The loss function is composed of three parts: bounding box regression loss, confidence loss and classification loss. The bounding box regression loss is used to measure the regression accuracy of the model on the target bounding box. It evaluates the regression ability of the model by calculating the difference between the predicted bounding box and the true bounding box. The confidence loss is used to measure the confidence of the model on the target existence. It evaluates the confidence of the model by calculating the IoU between the predicted bounding box and the true bounding box. The classification loss is used to measure the classification accuracy of the model on the target category. It evaluates the classification ability of the model by calculating the cross-entropy loss between the predicted category and the true category. The loss function is used to continuously optimize the network weight during the training process until the loss converges, thereby improving the accuracy and robustness of target detection.
8. The method according to claim 1, wherein, The test verification operation in step 3 is specifically: The improved YOLOv7 model small target floating garbage detection method is tested and verified on the test set, and the model performance is evaluated using evaluation indicators, including precision, recall, average precision mean and frame rate per second. The detection results are compared with current popular target detection algorithms.
Citation Information
Patent Citations
Lightweight pedestrian tracking method in complex scene
CN115984969A
Multi-task face detection method and device, electronic equipment and storage medium
CN116189269A