Mouse hole detection method based on BSM-YOLO
By introducing BiFormer module and Shuffle Attention mechanism in mouse hole detection, combining the four-level pyramid structure and MPDIoU loss function, the problem of unstable detection results in the existing technology is solved, and efficient and accurate mouse hole detection is achieved to adapt to complex environments. , significantly improves detection accuracy and practicality.
Patent Information
- Application Number
- CN202411363825.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-28
- Publication Date
- 2025-01-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing mouse hole detection methods rely on manual inspection or simple image processing technology, which makes it difficult to guarantee the accuracy and consistency of the detection results, and are sensitive to ambient light changes and noise interference, with high false detection and miss detection rates and time-consuming It is laborious and the test results are unstable.
The BiFormer module and Shuffle Attention mechanism were introduced to build the BSM-YOLO mouse hole detection model, and the bounding box was optimized through the four-level pyramid structure and MPDIoU loss function to improve detection accuracy and ability to adapt to complex environments.
It significantly improves the efficiency and accuracy of mouse hole detection, can process video streams or image sequences in real time, reduces false detection and missed detection, improves the practicality and reliability of the detection model in practical applications, and the average detection accuracy reaches 94.5%. The missed detection rate and false detection rate have been greatly reduced.
Smart Images

Figure CN119295399A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of target detection, and in particular relates to a rat hole detection method based on BSM-YOLO. Background Art
[0002] Existing computer vision technology has been widely used in various object detection tasks. In particular, the YOLO (You Only Look Once) series of algorithms have become an important tool in the field of target detection due to their high speed and high precision. As the latest version of this series, YOLOv5 has significantly improved accuracy and efficiency. Traditional rathole detection methods mainly rely on manual inspection or simple image processing techniques, such as edge detection and morphological operations. In addition, manual detection requires a lot of manpower, and due to the influence of human factors, the accuracy and consistency of the detection results are difficult to guarantee. Limitations of traditional image processing methods: Methods based on traditional image processing are sensitive to interference such as changes in ambient light and noise, and are difficult to cope with complex actual scenes, resulting in high false detection and missed detection rates. These methods are usually time-consuming and labor-intensive, and are easily interfered by environmental factors, resulting in unstable detection results. Therefore, the present invention provides a rathole detection method based on BSM-YOLO. Summary of the invention
[0003] In order to solve the above technical problems, the present invention proposes a rathole detection method based on BSM-YOLO to solve the problems existing in the above-mentioned prior art.
[0004] To achieve the above object, the present invention provides a rathole detection method based on BSM-YOLO, comprising the following steps:
[0005] The BiFormer module and Shuffle Attention mechanism are introduced into the YOLOv5 target detection model to build the BSM-YOLO rat hole detection model;
[0006] The acquired image data is input into the BSM-YOLO rat hole detection model to obtain the rat hole detection result.
[0007] Optionally, the process of performing image processing by the BSM-YOLO rathole detection model to obtain a rathole detection result includes:
[0008] Performing preprocessing and convolution processing on the image to obtain a first image;
[0009] Inputting the first image into a four-level pyramid structure to obtain a second image;
[0010] performing feature learning on the second image based on the Shuffle Attention mechanism to obtain target features;
[0011] Based on the target features, the MPDIoU loss function is used to optimize the bounding box to obtain the rathole detection result.
[0012] Optionally, the process of inputting the first image into a four-level pyramid structure to obtain the second image includes:
[0013] Construct a four-level pyramid structure based on the BiFormer module;
[0014] Inputting the first image into the first stage of a four-level pyramid structure to obtain an image segmentation block vector;
[0015] The image segmentation block vectors sequentially pass through the second stage to the fourth stage of the four-level pyramid structure to obtain a second image.
[0016] Optionally, the BiFormer module includes an upper router and a lower router; the process of acquiring the second image further includes acquiring and capturing global features based on the upper router, and acquiring local features based on the lower router.
[0017] Optionally, the process of performing feature learning on the second image to obtain target features includes:
[0018] grouping the channel dimension of the second image;
[0019] Channel attention learning and spatial attention learning are performed on each group of channels to obtain channel attention features and spatial attention features;
[0020] The channel attention features and the spatial attention features are weightedly fused to obtain target features containing contextual information.
[0021] Optionally, the process of performing bounding box optimization based on the MPDIoU loss function to obtain a rathole detection result includes:
[0022] Calculate the Distance-IoU value between the predicted bounding box and the true bounding box;
[0023] The Distance-IoU value is maximized to optimize the position and shape of the bounding box.
[0024] The present invention also provides a computer terminal device, comprising:
[0025] one or more processors;
[0026] A memory, coupled to the processor, for storing one or more programs;
[0027] When the one or more programs are executed by the one or more processors, the one or more processors implement a rathole detection method based on BSM-YOLO.
[0028] The present invention also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, a rathole detection method based on BSM-YOLO is implemented.
[0029] Compared with the prior art, the present invention has the following advantages and technical effects:
[0030] The present invention significantly improves the efficiency and accuracy of rathole detection by proposing BSM-YOLO. The present invention can process video streams or image sequences in real time, identify and locate ratholes in real time, and immediately trigger alarms and record detection results. This real-time performance greatly improves the practicality and reliability of the rathole detection model in practical applications.
[0031] Through the deep learning capabilities of YOLOv5, the present invention can adapt to various complex environmental conditions, including illumination changes, background complexity, and noise interference, so that it can work stably in various situations and avoid false detection and missed detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0033] Figure 1 Flow chart of a rathole detection method based on BSM-YOLO according to an embodiment of the present invention;
[0034] Figure 2 A four-level pyramid structure diagram of an embodiment of the present invention;
[0035] Figure 3 A flowchart of the Shuffle Attention mechanism is introduced for the embodiment of the present invention;
[0036] Figure 4 A schematic diagram of loss value calculation according to an embodiment of the present invention;
[0037] Figure 5 4 is an overall framework diagram of BSM-YOLO according to an embodiment of the present invention. DETAILED DESCRIPTION
[0038] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0039] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0040] Embodiment 1
[0041] like Figure 1 As shown, this embodiment provides a rathole detection method based on BSM-YOLO, which uses deep learning and computer vision technology to achieve automatic and high-precision detection of ratholes. The technical solution of the present invention solves the main problems in the prior art through a series of innovative measures. The specific technical solution is as follows: the BiFormer module and the Shuffle Attention mechanism are introduced into the target detection model of YOLOv5 to construct a BSM-YOLO rathole detection model; the acquired image data is input into the BSM-YOLO rathole detection model to obtain the rathole detection result.
[0042] Furthermore, the process of the BSM-YOLO rathole detection model performing image processing to obtain rathole detection results includes: preprocessing and convolution processing the image to obtain a first image; inputting the first image into a four-level pyramid structure to obtain a second image; performing feature learning on the second image based on the Shuffle Attention mechanism to obtain target features; and optimizing the bounding box based on the target features using the MPDIoU loss function to obtain the rathole detection results.
[0043] As a specific implementation of this embodiment, the target detection algorithm BSM-YOLO based on YOLOv5: First, the model adopts the BiFormer module based on Bi-Level Routing Attention to simultaneously capture the global and local feature information of the rat hole image; then, the Shuffle Attention mechanism is applied to better learn the dependencies and complex relationships between features; finally, the MPDIoU loss function is used to more accurately describe the position and shape of the bounding box to reduce redundant bounding boxes. The loss function also accelerates the convergence speed of the model. Its core advantage lies in the efficient feature extraction capability, which can provide high-precision detection results while maintaining high detection speed.
[0044] Furthermore, the process of inputting the first image into the four-level pyramid structure to obtain the second image includes: constructing a four-level pyramid structure based on the BiFormer module; inputting the first image into the first stage of the four-level pyramid structure to obtain an image segmentation block vector; and the image segmentation block vector sequentially passes through the second stage to the fourth stage of the four-level pyramid structure to obtain the second image.
[0045] As a specific implementation of this embodiment, in order to solve the problem that the model is not sufficiently extracting small target features, this embodiment introduces a BiFormer module to capture the global and local features of the rat hole image at the same time, thereby improving the detection accuracy of small targets and enhancing the adaptability of the model's multi-scale features;
[0046] like Figure 2 As shown in the figure, BiFormer built on the BRA module adopts a four-level pyramid structure. In the first stage, overlapping blocks and BiFormer blocks are used to divide the image into small patches and convert them into vectors. In the second to fourth stages, downsampling and BiFormer blocks are combined to reduce the spatial resolution of the input image and increase the number of channels. The changes in image size and number of channels are shown in Figure (a). The details of the BiFormer block structure are shown in Figure (b). The two key components of BiFormer are the upper router and lower router contained in BRA. The upper router is responsible for capturing global context information, and the lower router is responsible for capturing details of local areas. This mechanism enables the BiFormer model to have better performance in the rat hole detection task.
[0047] Furthermore, the process of performing feature learning on the second image to obtain target features includes: grouping the channel dimensions of the second image; performing channel attention learning and spatial attention learning on each group of channels to obtain channel attention features and spatial attention features; and performing weighted fusion on the channel attention features and the spatial attention features to obtain target features containing contextual information.
[0048] As a specific implementation of this embodiment, in order to better enable the model to learn the complex relationship between features and reduce the interference of background on rathole detection, this embodiment introduces the Shuffle Attention (SA) mechanism, which effectively enhances the feature expression ability of the model;
[0049] like Figure 3 As shown in Figure 1, first, SA groups the input feature maps according to the channel dimension. Assuming that the number of channels of the input feature map is c, it can be divided into g groups, each group contains c / g channels, and then each feature X k Will be split into two branches along the channel dimension, one branch X k1 For learning channel attention features, another branch X k2Used to learn spatial attention features. After the channel attention branch undergoes global average pooling, fully connected layers, and Sigmoid activation functions, the model learns the importance of each channel for the rathole detection task. Then, the channel features in each group are weighted by the channel attention weights calculated by element-wise product. The weighted features will contain richer contextual information and dependencies between channels.
[0050] Furthermore, the process of optimizing the bounding box based on the MPDIoU loss function to obtain the rathole detection result includes: calculating the Distance-IoU value between the predicted bounding box and the true bounding box; maximizing the Distance-IoU value to optimize the position and shape of the bounding box.
[0051] As a specific implementation of this embodiment, in order to more accurately describe the position and shape of the bounding box and simplify the calculation process, this embodiment replaces the loss function with Minimum Points Distance Inter-section over Union (MPDIoU), thereby improving the model's detection capability for targets of different sizes and aspect ratios.
[0052] like Figure 4 As shown in the figure, the MPDIoU loss function can enable the network to better learn the position and shape of the bounding box by maximizing the Distance-IOU value between the two bounding boxes. MPDIoU not only considers the size of the overlapping area, but also factors such as the center point distance, width and height deviation, which is more comprehensive and accurate when evaluating the similarity between bounding boxes. The MPDIoU loss function simplifies the calculation process, which enables the loss value to be calculated faster during training and enables the model to converge faster. The existing loss function cannot be optimized when the predicted bounding box has the same aspect ratio as the true bounding box but the width and height values are completely different. As shown in the figure, assuming that for a certain true box (W gt , H gt ), there are two prediction boxes whose centers coincide with it (W gt / k,H gt / k), (kW gt , kH gt ), MPDIoU sets the value of the predicted box inside the true box to be lower than the predicted bounding box outside the true labeled bounding box.
[0053] Furthermore, the present invention intends to protect the BSM-YOLO model proposed in this embodiment. In this model, firstly, the present embodiment introduces the BiFormer module to achieve high-precision small target detection; secondly, the SA mechanism is introduced to enhance the model's ability to learn complex relationships between features and improve the model's feature expression; finally, the MPDIoU loss function is used to optimize the model.
[0054] The overall framework of BSM-YOLO is as follows Figure 5 As shown in the figure. First, the input end receives image data with a size of 640×640 pixels and preprocesses it, including image normalization and channel order adjustment. In order to improve the generalization ability of the model, the input end performs mosaic data enhancement on the image, including random scaling, random cropping, random flipping, color jittering, etc., which increases the diversity and richness of the data set. Then, after passing through multiple stacked C3 modules and multiple CBS convolutional layers and an SPPF, the image enters the BiFormer module based on Bi-Level Routing Attention (BRA), which captures global and local feature information at the same time through a two-layer routing attention mechanism to achieve high-precision detection of small targets. Next, after passing through the feature pyramid network, the input image enters the SA mechanism to better learn the dependencies and complex relationships between features, enhance the performance expression of the model, and more fully extract the target features. Finally, the MPDIoU loss function is used to accelerate the convergence speed and improve the robustness of the model.
[0055] This embodiment also includes a rathole detection device, which includes the following main parts:
[0056] Image acquisition module: This module uses DJI Mavic drones to collect data. It can collect image data in the environment in real time and input these data into subsequent processing units.
[0057] Image processing and detection module: This module uses a deep learning model based on YOLOv5 for image processing and target detection. This embodiment proposes a single-stage detection model BSM-YOLO based on the improvement of YOLOv5. The BSM-YOLO model provides a solution to the problems of insufficient feature extraction and inability to accurately distinguish between targets and backgrounds in small target detection. Experimental results show that the algorithm has good performance in terms of accuracy, robustness, and practicality.
[0058] The present invention realizes automatic detection of ratholes through the YOLOv5 deep learning algorithm, reducing the reliance on manual detection. YOLOv5 has the advantages of high precision and high speed in target detection, and can accurately identify and locate ratholes. Through the training and optimization of the deep learning model, the stability and reliability of the detection system in different environments are improved. By utilizing the efficient detection capability of YOLOv5, real-time rathole detection is realized to meet the timeliness requirements in practical applications.
[0059] The present invention significantly improves the efficiency and accuracy of rathole detection by proposing BSM-YOLO. The present invention uses the BSM-YOLO algorithm for real-time rathole detection, and the number of detection frames per second is increased by 8.7f / s compared with the baseline model, achieving high-speed target recognition and positioning. The present invention greatly improves the detection accuracy of ratholes in complex environments through the deep learning model of BSM-YOLO. Experimental data show that the average detection accuracy of the present invention reaches 94.5%, and the missed detection rate and false detection rate are greatly reduced.
[0060] Embodiment 2
[0061] This embodiment also provides a computer terminal device, including:
[0062] one or more processors;
[0063] A memory, coupled to the processor, for storing one or more programs;
[0064] When one or more programs are executed by one or more processors, the one or more processors implement a rathole detection method based on BSM-YOLO.
[0065] Embodiment 3
[0066] This embodiment also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, a rathole detection method based on BSM-YOLO is implemented.
[0067] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A rathole detection method based on BSM-YOLO, characterized in that: The following steps are involved: The BiFormer module and Shuffle Attention mechanism are introduced into the YOLOv5 target detection model to build the BSM-YOLO rat hole detection model; The acquired image data is input into the BSM-YOLO rat hole detection model to obtain the rat hole detection result.
2. The rathole detection method based on BSM-YOLO according to claim 1, characterized in that: The process of performing image processing to obtain rathole detection results by the BSM-YOLO rathole detection model includes: Performing preprocessing and convolution processing on the image to obtain a first image; Inputting the first image into a four-level pyramid structure to obtain a second image; performing feature learning on the second image based on the Shuffle Attention mechanism to obtain target features; Based on the target features, the MPDIoU loss function is used to optimize the bounding box to obtain the rathole detection result.
3. The rathole detection method based on BSM-YOLO according to claim 2, characterized in that: The process of inputting the first image into the four-level pyramid structure to obtain the second image includes: Construct a four-level pyramid structure based on the BiFormer module; Inputting the first image into the first stage of a four-level pyramid structure to obtain an image segmentation block vector; The image segmentation block vectors sequentially pass through the second stage to the fourth stage of the four-level pyramid structure to obtain a second image.
4. The rathole detection method based on BSM-YOLO according to claim 3, characterized in that: The BiFormer module includes an upper router and a lower router; the process of acquiring the second image also includes acquiring and capturing global features based on the upper router and acquiring local features based on the lower router.
5. The rathole detection method based on BSM-YOLO according to claim 2, characterized in that: The process of performing feature learning on the second image to obtain target features includes: grouping the channel dimension of the second image; Channel attention learning and spatial attention learning are performed on each group of channels to obtain channel attention features and spatial attention features; The channel attention features and the spatial attention features are weightedly fused to obtain target features containing contextual information.
6. The rathole detection method based on BSM-YOLO according to claim 2, characterized in that: The process of optimizing the bounding box based on the MPDIoU loss function to obtain the rathole detection result includes: Calculate the Distance-IoU value between the predicted bounding box and the true bounding box; The Distance-IoU value is maximized to optimize the position and shape of the bounding box.
7. A computer terminal device, characterized in that: include: one or more processors; A memory, coupled to the processor, for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the rathole detection method based on BSM-YOLO as described in any one of claims 1 to 6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the rathole detection method based on BSM-YOLO as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Agricultural pest identification method based on improved YOLOv5
CN117456257A
Model training method and ship detection method
CN117557963A
Forest fire detection method and system, electronic equipment and medium
CN117911763A
Cited By
Mouse trapping system based on YOLO mouse hole detection model
CN120765914A
A mouse catching system based on a YOLO mouse hole detection model
CN120765914B