Improved YOLOv8 small target detection method and system fusing attention mechanism
By optimizing the YOLOv8 network model, combining the attention mechanism and a smaller object detection layer, the problem of low detection accuracy of rats in the distribution station is solved, and more efficient and accurate small object detection is achieved.
Patent Information
- Application Number
- CN202411634393.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-03-11
AI Technical Summary
The prior art is difficult to effectively detect mice in power distribution stations, especially when the mouse imaging area is small, obstructed and the night contour texture is unclear, resulting in a decrease in detection accuracy.
The improved YOLOv8 small object detection method is adopted with the fusion attention mechanism. By optimizing the original YOLOv8 network model, including deleting the large object detection layer, adding a smaller object detection layer, building the C2f_Res2Block module and SA-SPPF module, and adding a GAM module to the Neck part, using the WIoU loss function for training.
Improves the performance of small object detection, enhances the robustness and generalization capabilities of the model, and enables more accurate detection of mice, especially in complex backgrounds and occlusions.
Smart Images

Figure CN119600258A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer vision small target detection technology, and in particular to an improved YOLOv8 small target detection method, system, device and storage medium integrating an attention mechanism. Background Art
[0002] In recent years, the power grid has been popularized to thousands of households. The growing demand for electricity has led to the continuous expansion of the scale of the power grid and the increasing complexity of the equipment structure. Therefore, the power grid system must lay a larger number of distribution stations, but this also significantly increases the workload of daily inspections and maintenance, and the management of power grid safety production has become increasingly difficult. Among them, the problem of rat infestation poses a great hidden danger to the normal operation of power facilities. For example, rats chew cables or power equipment, causing equipment failures and even fires. Therefore, real-time and effective rat monitoring can reduce the accident rate, improve the stability and reliability of the power system, and ensure the continuity and safety of power supply. It is an important measure to ensure the safe operation of the power grid system.
[0003] Traditional monitoring of rats in distribution stations mainly relies on manual inspections, the placement of physical capture devices (mousetraps, sticky mouse boards, etc.) and the placement of poison baits. Such methods have the limitations of low efficiency, reliance on manual experience and the possibility of causing secondary pollution.
[0004] First, at present, the rat monitoring data of distribution stations is basically collected through surveillance cameras. The monitoring angle of view is relatively wide, and the size of rats is small. Therefore, the imaging area in the monitoring image is usually less than 30*30 pixels, which belongs to the problem of small target detection. General target detection algorithms find it difficult to extract the characteristics of rats, which leads to missed detections and false detections.
[0005] Secondly, mice are nocturnal animals and rarely appear under strong light conditions. The surveillance image data in dark conditions is obtained by using infrared fill light from the camera, and are all grayscale images, which are similar to the body color of mice, and this is one of the difficulties in detection.
[0006] Furthermore, mice prefer to hide in corners, and the collected data often have problems such as varying degrees of occlusion, shapes and sizes, which also affect the performance of the detection algorithm.
[0007] In the current monitoring scenarios targeting rats, the detection environment is unique. The Chinese patent application with publication number CN118097715A discloses a method for detecting rats in an open kitchen and stove based on cross-attention enhancement. However, this solution recognizes and detects rats in an open kitchen and stove environment, without taking rat detection in a dark environment into consideration, and does not consider the problem of rat occlusion. Therefore, it is not suitable for rat detection in a distribution substation environment. Summary of the invention
[0008] Purpose of the invention: The purpose of the present invention is to provide an improved YOLOv8 small target detection method, system, device and storage medium integrating an attention mechanism, which can solve the problem that the existing technology is difficult to meet the needs of actual applications due to the small imaging area of mice, occlusion and unclear contour texture at night, resulting in reduced detection accuracy.
[0009] Technical solution: The present invention provides an improved YOLOv8 small target detection method integrating an attention mechanism, comprising:
[0010] Collect small target images and surveillance video data containing small targets, pre-process the small target images and surveillance video data containing small targets, and build a small target data set based on the processed small target images and surveillance video data containing small targets, annotate and divide the small target data set to obtain a training set, a validation set, and a test set;
[0011] The original YOLOv8 network model is optimized to obtain an improved YOLOv8 network model;
[0012] The improved YOLOv8 network model is trained using the training set. During the training process, the validation set is used to adjust the hyperparameters of the improved YOLOv8 network model to obtain a small target detection model. The performance of the small target detection model is evaluated using the test set.
[0013] The small target detection model is deployed in the surveillance camera, and the small target detection model is used to perform real-time monitoring and alarm on small targets that appear within the monitoring range of the surveillance camera.
[0014] Furthermore, small target images and surveillance video data containing small targets are collected, the small target images and surveillance video data containing small targets are preprocessed, and a small target data set is constructed based on the preprocessed small target images and surveillance video data containing small targets, and the small target data set is labeled and divided to obtain a training set, a validation set, and a test set, including:
[0015] Collect small target images and surveillance video data containing small targets to build an initial data set;
[0016] Preprocess all images in the initial data set, and build a small target data set based on the preprocessed small target images and surveillance video data containing small targets;
[0017] Use the LabelImg annotation tool, set to YOLO format, to manually annotate all images in the small object dataset;
[0018] The manually annotated small object dataset is divided into training set, validation set and test set in proportion.
[0019] Furthermore, the original YOLOv8 network model is optimized to obtain an improved YOLOv8 network model, including:
[0020] The 20 pixel × 20 pixel large target detection layer in the original YOLOv8 network model is deleted, and a 16 pixel × 16 pixel smaller target detection layer is added to obtain the optimized first YOLOv8 network model;
[0021] Build the C2f_Res2Block module to replace the C2f module in the optimized first YOLOv8 network model;
[0022] Construct the SA-SPPF module to replace the SPPF module in the optimized first YOLOv8 network model;
[0023] In the optimized first YOLOv8 network model, GAM modules are added to the output ends of the two Upsample modules in the Neck part to obtain an improved YOLOv8 network.
[0024] Furthermore, the 20 pixel × 20 pixel large target detection layer in the original YOLOv8 network model is deleted, and a 16 pixel × 16 pixel small target detection layer is added to obtain the optimized first YOLOv8 network model, including:
[0025] Delete the fifth CBS module and the fourth C2f module in the BackBone part of the original YOLOv8 network model;
[0026] The first C2f module in the BackBone part of the original YOLOv8 network model is connected to the first Concat module in the Neck part, the second C2f module in the BackBone part is connected to the second Concat module in the Neck part, and the third C2f module in the BackBone part is connected to the SPPF module to obtain the optimized first YOLOv8 network model.
[0027] Furthermore, a C2f_Res2Block module is constructed to replace the C2f module in the optimized first YOLOv8 network model, including:
[0028] Use the Res2Net module to replace the Bottleneck structure of the C2f module in the optimized first YOLOv8 network model, and build the optimized C2f_Res2Block module;
[0029] Replace all seven C2f modules in the optimized first YOLOv8 network model with the optimized C2f_Res2Block module.
[0030] Furthermore, a SA-SPPF module is constructed to replace the SPPF module in the optimized first YOLOv8 network model, including:
[0031] Add a SimAM module to the output of the first CBS module in the original SPPF module structure, and add a SimAM module to the input of the second CBS module;
[0032] Connect the feature map at the input of the original SPPF module with the Concat module to construct the optimized SA-SPPF module;
[0033] The SPPF module of the BackBone part in the optimized first YOLOv8 network model is replaced with the optimized SA-SPPF module.
[0034] Furthermore, the training set is used to train the improved YOLOv8 network model. During the training process, the validation set is used to adjust the hyperparameters of the improved YOLOv8 network model to obtain a small target detection model. The test set is used to evaluate the performance of the small target detection model, including:
[0035] Use WIoU loss function to replace the CIoU loss function of the original YOLOv8 network model;
[0036] The images in the training set are input into the improved YOLOv8 network model for iterative optimization. After each training cycle, the indicators of the improved YOLOv8 network model are calculated on the validation set, and the hyperparameters of the improved YOLOv8 network model during the training process are appropriately adjusted. The training is iterated until the WIoU loss function is fully converged, and the parameters of the improved YOLOv8 network model are saved to obtain the small target detection model. The performance of the small target detection model is evaluated using the test set.
[0037] Based on the same inventive concept, an improved YOLOv8 small target detection system integrating an attention mechanism of the present invention includes:
[0038] An image acquisition and preprocessing module is used to acquire small target images and surveillance video data containing small targets, preprocess the small target images and surveillance video data containing small targets, and construct a small target data set based on the processed small target images and surveillance video data containing small targets, and annotate and divide the small target data set to obtain a training set, a validation set, and a test set;
[0039] The model optimization module is used to optimize the original YOLOv8 network model to obtain an improved YOLOv8 network model;
[0040] The model training module is used to train the improved YOLOv8 network model using the training set, and to adjust the hyperparameters of the improved YOLOv8 network model using the validation set during the training process to obtain a small target detection model; and to evaluate the performance of the small target detection model using the test set;
[0041] The small target detection module is used to deploy the small target detection model in the surveillance camera, and use the small target detection model to perform real-time monitoring and alarm on small targets that appear within the monitoring range of the surveillance camera.
[0042] Based on the same inventive concept, the present invention provides an improved YOLOv8 small target detection device that integrates an attention mechanism, including a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the steps of the improved YOLOv8 small target detection method that integrates the attention mechanism.
[0043] Based on the same inventive concept, a computer-readable storage medium of the present invention stores a computer program thereon, which, when executed by a processor, implements the steps of the improved YOLOv8 small target detection method that integrates the above-mentioned attention mechanism.
[0044] Beneficial effects: Compared with the prior art, the significant technical effects of the present invention are as follows:
[0045] The present invention constructs an initial data set by collecting mouse pictures from different platforms and video frames containing mice in surveillance videos, and performs preprocessing such as rotating and cropping images, adjusting image brightness and contrast, etc., to increase the diversity of training data and enhance the generalization ability of the model.
[0046] The present invention designs an improved YOLOv8 network model architecture, deletes the large target detection layer of the original YOLOv8 network model, adds a smaller target detection layer, improves the detection performance, reduces the number of network parameters, and speeds up the training and detection speed of the model.
[0047] The present invention designs a SA-SPPF module. This structure combines the SimAM module with the SPPF module of the original YOLOv8 network model, adds a feature map fusion branch, enriches the feature map representation, and enhances the attention to small target areas, which is beneficial to solving the problems of complex background and severe occlusion of small targets and improving the robustness of the model.
[0048] The present invention adds a GAM module to the Neck part of the improved YOLOv8 network model architecture, models the global environment by calculating the global attention weight, enhances the contextual information of small targets, and further improves the model accuracy.
[0049] The present invention uses the WIoU loss function to replace the CIoU loss function of the original YOLOv8 network model, which speeds up the training speed of the model, balances the imbalance problem of positive and negative samples, accelerates model convergence, improves regression accuracy, and enhances the overall detection performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a flowchart of an improved YOLOv8 small target detection method integrating an attention mechanism disclosed in an embodiment of the present invention;
[0051] Figure 2 This is the original YOLOv8 network architecture diagram;
[0052] Figure 3 It is a structural diagram of a C2f_Res2Block module disclosed in an embodiment of the present invention;
[0053] Figure 4 It is a structural schematic diagram of a SA-SPPF module disclosed in an embodiment of the present invention;
[0054] Figure 5 is a structural schematic diagram of a GAM module disclosed in an embodiment of the present invention;
[0055] Figure 6 It is an optimized YOLOv8 network architecture diagram disclosed in an embodiment of the present invention;
[0056] Figure 7 It is a structural schematic diagram of an improved YOLOv8 small target detection system integrating an attention mechanism disclosed in an embodiment of the present invention;
[0057] Figure 8 It is a structural schematic diagram of an improved YOLOv8 small target detection device integrating an attention mechanism disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0058] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It will be understood by those skilled in the art that the purposes and advantages that can be achieved with the present invention are not limited to the specific description of the above beneficial effects, and the above and other purposes that can be achieved by the present invention will be more clearly understood based on the following detailed description.
[0059] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed in the present invention can be implemented in hardware, software or a combination of the two. Whether it is implemented in hardware or software depends on the specific application and design of the technical solution. Professional and technical personnel can use different methods to implement the functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0060] Reference to "embodiments" in the present invention means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0061] Example 1
[0062] See also Figure 1 , Figure 1 : is a flowchart of an improved YOLOv8 small target detection method integrating an attention mechanism disclosed in an embodiment of the present invention. Figure 1 The improved YOLOv8 small target detection method described is applied to a distribution station, such as for monitoring rats in a distribution station, etc., and the embodiments of the present invention are not limited thereto. Figure 1 As shown, the improved YOLOv8 small target detection method integrating the attention mechanism may include the following operations:
[0063] S1. Collect small target images and surveillance video data containing small targets, pre-process the small target images and surveillance video data containing small targets, and build a small target dataset based on the processed small target images and surveillance video data containing small targets, annotate and divide the small target dataset to obtain a training set, a validation set, and a test set. The specific steps are as follows:
[0064] S1.1. Collect small target images and surveillance video data containing small targets to build an initial data set;
[0065] The initial dataset was constructed by using crawler technology to crawl public static images containing one or more mice from image websites, capturing surveillance videos containing mice from short video platforms and capturing video frames containing mice, and extracting video frames containing mice from distribution station surveillance videos.
[0066] S1.2, preprocess all images in the initial data set, and construct a small target data set based on the preprocessed small target images and the surveillance video data containing small targets;
[0067] All images in the initial data set are preprocessed, including rotating and cropping images, adjusting image brightness and contrast, to improve the quality of the initial data set.
[0068] S1.3. Use the LabelImg annotation tool, set to YOLO format, to manually annotate all images in the small object dataset;
[0069] S1.4. Divide the manually annotated small object dataset into training set, validation set and test set in proportion.
[0070] The small object dataset includes mouse images and surveillance video frames of mice.
[0071] In this embodiment, the division ratio adopted is 7:2:1, that is, 70% of the data in the data set is divided into a training set for model training, 20% of the data is divided into a validation set for model validation, and 10% of the data is divided into a test set for model testing. The specific division ratio can be adjusted and optimized according to actual training.
[0072] S2. Optimize the original YOLOv8 network model to obtain an improved YOLOv8 network model.
[0073] like Figure 2 As shown in the figure, the original YOLOv8 network architecture diagram contains three layers: BackBone (backbone network), Neck (connection fusion layer), and Head (detection head layer). The BackBone part extracts image features through five CBS modules (convolution modules), four C2f modules, and one SPPF module (pyramid pooling module). The Neck part further processes and fuses image features through four C2f modules, four Concat modules, two CBS modules, and two Upsample modules (upsample modules). The Head detects and locates objects of different sizes through the decoupling head for large objects, the decoupling head for medium objects, and the decoupling head for small objects.
[0074] like Figure 2 and Figure 6 As shown, the specific steps of step S2 are as follows:
[0075] S2.1, delete the 20pixel×20pixel large target detection layer in the original YOLOv8 network model, add a 16pixel×16pixel smaller target detection layer, and obtain the optimized first YOLOv8 network model;
[0076] The large target detection layer of the original YOLOv8 network model is deleted, including adjusting the decoupling head for large targets in the Head part of the original YOLOv8 network model and the CBS module and C2f module used to connect the decoupling head for large targets in BackBone to the decoupling head for medium targets in the Head part of the YOLOv8 network model and the CBS module and C2f module used to connect the decoupling head for medium targets in BackBone.
[0077] A smaller target detection layer of the original YOLOv8 network model is added, including adjusting the decoupling head for small targets in the Head part of the original YOLOv8 network model and the CBS module and C2f module for connecting the decoupling head for small targets in BackBone to the decoupling head for smaller targets in the Head part of the YOLOv8 network model and the CBS module and C2f module for connecting the decoupling head for smaller targets in BackBone, to obtain an optimized first YOLOv8 network model;
[0078] Step S2.1 The specific steps are as follows:
[0079] S2.1.1. Delete the fifth CBS module and the fourth C2f module in the BackBone part of the original YOLOv8 network model;
[0080] S2.1.2. Connect the first C2f module in the BackBone part of the original YOLOv8 network model to the first Concat module in the Neck part, connect the second C2f module in the BackBone part to the second Concat module in the Neck part, and connect the third C2f module in the BackBone part to the SPPF module to obtain the optimized first YOLOv8 network model.
[0081] The decoupling head for large targets in the original Head part is optimized and adjusted to a decoupling head for medium targets; the decoupling head for medium targets is optimized and adjusted to a decoupling head for small targets; and the decoupling head for small targets is optimized and adjusted to a decoupling head for even smaller targets.
[0082] It is understandable that the embodiment of the present invention is for mouse (small target) recognition, and the decoupling head for large targets preset in the original network is not suitable for the current scenario. Therefore, deleting the branch for large target detection can improve the detection performance, reduce the number of network parameters, speed up the model training and detection speed, and achieve the purpose of optimizing the YOLOv8 network model.
[0083] S2.2, construct the C2f_Res2Block module to replace the C2f module in the optimized first YOLOv8 network model; Figure 3 As shown, the specific steps are as follows:
[0084] S2.2.1. Use the Res2Net module to replace the Bottleneck structure of the C2f module in the optimized first YOLOv8 network model, and construct the optimized C2f_Res2Block module.
[0085] S2.2.2. Replace all seven C2f modules in the optimized first YOLOv8 network model with the optimized C2f_Res2Block module.
[0086] Res2Net uses Multi-Scale Sub-Networks to process features of different resolutions and cascades the output features of each scale. This structure allows the network to learn low-resolution and high-resolution feature representations at the same time, improves the network's perception ability, enhances the model's attention to important information in night images, and improves the model's detection performance and generalization ability.
[0087] S2.3. Construct the SA-SPPF module to replace the SPPF module in the optimized first YOLOv8 network model. The specific steps are as follows:
[0088] S2.3.1, if Figure 4 As shown, in the optimized first YOLOv8 network model, a SimAM module is added to the output end of the first CBS module in the original SPPF module, and a SimAM module is added to the input end of the second CBS module;
[0089] S2.3.2, connect the feature map at the input end of the original SPPF module with the Concat module to construct the optimized SA-SPPF module;
[0090] S2.3.3. Replace the SPPF module of the BackBone part in the optimized first YOLOv8 network model with the optimized SA-SPPF module.
[0091] The original feature map of the SPPF module is input into the Concat module to enrich the feature representation. The SimAM module generates three-dimensional parameter weights through neuron perception to indicate the importance of key feature information of small targets. At the same time, it divides the complex background area and the small target area into pixels to enhance the attention to the small target area, which is conducive to solving the problem of complex background and severe occlusion of small targets and improving the robustness of the model.
[0092] S2.4. Add GAM modules (global attention mechanism modules) to the output ends of the two Upsample modules in the Neck part of the optimized first YOLOv8 network model to obtain an improved YOLOv8 network.
[0093] like Figure 5 As shown in the figure, the GAM module consists of a channel attention part and a spatial attention part. Refers to weighted operation.
[0094] The working mechanism of the GAM module is to refine the input feature map in two stages. Among them, the channel attention module mainly focuses on the relationship between different channels in the feature map, and enhances useful features and suppresses useless features by evaluating the importance of each channel. Specifically, the channel attention module performs average pooling and maximum pooling on the input feature map to generate two global descriptors, and then calculates the channel attention map through the convolution layer. The spatial attention module mainly focuses on the importance of different spatial positions in the feature map. Specifically, the spatial attention module averages and calculates the maximum value of the feature map after channel attention processing, generates two spatial descriptors, and then calculates the spatial attention map through the convolution layer. The channel attention map and the spatial attention map are multiplied with the input feature map respectively to achieve feature refinement and finally generate a global context representation.
[0095] Therefore, the GAM module can enhance the contextual information of small objects through global modeling and further improve the model accuracy.
[0096] In this embodiment, the optimization of the YOLOv8 network model architecture is mainly as follows: by adjusting the decoupling head for large targets in the Head part of the original YOLOv8 network model and the CBS module and C2f module for connecting the decoupling head for large targets in the BackBone to the decoupling head for medium targets in the Head part of the original YOLOv8 network model and the CBS module and C2f module for connecting the decoupling head for medium targets in the BackBone; adjusting the decoupling head for small targets in the Head part of the original YOLOv8 network model and the CBS module and C2f module for connecting the decoupling head for small targets in the BackBone to the decoupling head for smaller targets in the Head part of the YOLOv8 network model and the CBS module and C2f module for connecting the decoupling head for smaller targets in the BackBone.
[0097] In the embodiment of the present invention, the optimization of the feature extraction part of the YOLOv8 network model is to construct an optimized C2f module, C2f_Res2Block module, by combining the Res2Net module with the C2f module of the original YOLOv8 network model to replace the C2f module in the original YOLOv8 network model.
[0098] In the embodiment of the present invention, the optimization of the feature fusion part of the YOLOv8 network model is achieved by combining the SimAM module with the SPPF module of the original YOLOv8 network model to construct an optimized SPPF module, the SA-SPPF module, to replace the SPPF module in the original YOLOv8 network model.
[0099] In the embodiment of the present invention, the optimization of the Neck part of the YOLOv8 network model is achieved by adding a GAM module.
[0100] S3. Use the training set to train the improved YOLOv8 network model. During the training process, use the validation set to adjust the hyperparameters of the improved YOLOv8 network model to obtain a small target detection model. Use the test set to evaluate the performance of the small target detection model. The specific steps are as follows:
[0101] S3.1. Use WIoU loss function to replace the CIoU loss function of the original YOLOv8 network model;
[0102] The training speed of the YOLOv8 network model in the embodiment of the present invention is optimized by replacing the original CIoU loss function with the WIoU loss function.
[0103] S3.2. Input the images in the training set into the improved YOLOv8 network model for iterative optimization. After each training cycle, calculate the indicators of the improved YOLOv8 network model on the validation set, appropriately adjust the hyperparameters of the improved YOLOv8 network model during the training process, iterate the training until the WIoU loss function fully converges, save the parameters of the improved YOLOv8 network model, and obtain the small target detection model. Use the test set to evaluate the performance of the small target detection model.
[0104] In this embodiment, the model performance is evaluated by three indicators: precision (Precision, P), recall (Recall, R), and mAP.
[0105] The CIoU loss function introduces multiple additional computational dimensions, increasing the computational complexity during model training. When computing resources are limited, the training speed will be slowed down, and the CIoU loss function has limited improvement effect in small target detection problems. The WIoU loss function proposes a dynamic non-monotonic focusing mechanism and adopts a gradient gain allocation strategy, which can reduce the dominant role of high-quality anchor boxes on the model during training, so that high-quality anchor boxes will not excessively affect the optimization of the model. At the same time, it can reduce the negative impact of low-quality anchor boxes on model training, such as generating erroneous gradient information. Therefore, the WIoU loss function can balance the problem of imbalance between positive and negative samples, accelerate model convergence, improve regression accuracy, and improve the overall detection performance of the model.
[0106] S4. Deploy the small target detection model in the monitoring camera of the experimental environment (distribution station), and use the small target detection model to perform real-time monitoring and alarm on small targets that appear within the monitoring range of the monitoring camera. Specifically, the following steps are included:
[0107] S4.1. Deploy the small target detection model in the surveillance camera of the distribution station.
[0108] S4.2. Obtain the confidence level corresponding to each frame of the video in real time.
[0109] S4.3. Determine whether the confidence of the current frame of the video is greater than the confidence threshold. If it is greater than the confidence threshold, it is determined that there is a mouse in the current monitoring area.
[0110] S4.4, upload the current frame image containing the mouse, the confidence of the frame image, the time, the location name of the monitoring area and the coordinate values of the four corners of the detection box in the frame image to the server database.
[0111] S4.5. The server backend sends the above message to the staff, notifying them to take appropriate measures in a timely manner.
[0112] The technical solution of the present invention has the characteristics of fast reasoning speed, strong real-time performance, high detection accuracy and high generalization ability. After the iterative training is completed, it can be deployed in the monitoring cameras of each power distribution station, and a monitoring and early warning system can be established to realize real-time monitoring of rodent infestation in the power distribution station.
[0113] Example 2
[0114] See also Figure 7 , Figure 7 : is a schematic diagram of the structure of an improved YOLOv8 small target detection system integrating an attention mechanism disclosed in an embodiment of the present invention. The system can realize rat monitoring in a power distribution station, and specifically includes:
[0115] An image acquisition and preprocessing module is used to acquire small target images and surveillance video data containing small targets, preprocess the small target images and surveillance video data containing small targets, and construct a small target data set based on the processed small target images and surveillance video data containing small targets, and annotate and divide the small target data set to obtain a training set, a validation set, and a test set;
[0116] The model optimization module is used to optimize the original YOLOv8 network model to obtain an improved YOLOv8 network model;
[0117] The model training module is used to train the improved YOLOv8 network model using the training set, and to adjust the hyperparameters of the improved YOLOv8 network model using the validation set during the training process to obtain a small target detection model; and to evaluate the performance of the small target detection model using the test set;
[0118] The small target detection module is used to deploy the small target detection model in the surveillance camera, and use the small target detection model to perform real-time monitoring and alarm on small targets that appear within the monitoring range of the surveillance camera.
[0119] In an optional embodiment, the improved YOLOv8 small target detection method integrating the attention mechanism includes: a) collecting small target images and surveillance video data containing small targets, and preprocessing these data to construct a small target data set; b) optimizing the original YOLOv8 network model to obtain an improved YOLOv8 network model; c) training the improved YOLOv8 network model based on the preprocessed small target data set to obtain a small target detection model; d) deploying the small target detection model in a surveillance camera to perform real-time monitoring and alarm on small targets.
[0120] Example 3
[0121] See also Figure 8 , Figure 8 : is a schematic diagram of the structure of an improved YOLOv8 small target detection device integrating an attention mechanism disclosed in an embodiment of the present invention. Figure 8 The described device can be applied to power distribution stations, such as for monitoring rats in power distribution stations, and the embodiments of the present invention are not limited thereto.
[0122] like Figure 8 As shown, the device may include a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the steps of the method described in the above embodiment and can achieve the technical effect consistent with the above method.
[0123] The memory may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the memory may be used to read and write non-removable, non-volatile magnetic media (commonly referred to as a "hard drive"). A program / utility having a set (at least one) of program modules may be stored in, for example, the memory, such program modules including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment. The program modules typically perform the functions and / or methods in the embodiments described herein.
[0124] The processor executes various functional applications and data processing by running the program stored in the memory, such as implementing the method provided in the first embodiment of the present invention.
[0125] Example 4
[0126] Embodiment 4 of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method described in the above embodiment are implemented and the technical effect consistent with the above method can be achieved.
[0127] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.
[0128] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0129] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0130] Computer program code for performing the operation of the present invention may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0131] Of course, the storage medium containing computer executable instructions provided by an embodiment of the present invention, whose computer executable instructions are not limited to the above method operations, can also execute related operations in the method provided by any embodiment of the present invention.
[0132] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. An improved YOLOv8 small target detection method integrating attention mechanism, characterized in that: include: Collect small target images and surveillance video data containing small targets, pre-process the small target images and surveillance video data containing small targets, and build a small target data set based on the processed small target images and surveillance video data containing small targets, annotate and divide the small target data set to obtain a training set, a validation set, and a test set; The original YOLOv8 network model is optimized to obtain an improved YOLOv8 network model; The improved YOLOv8 network model is trained using the training set. During the training process, the validation set is used to adjust the hyperparameters of the improved YOLOv8 network model to obtain a small target detection model. The performance of the small target detection model is evaluated using the test set. The small target detection model is deployed in the surveillance camera, and the small target detection model is used to perform real-time monitoring and alarm on small targets that appear within the monitoring range of the surveillance camera.
2. The improved YOLOv8 small target detection method integrating attention mechanism according to claim 1. Characterized in that: Collect small target images and surveillance video data containing small targets, preprocess the small target images and surveillance video data containing small targets, and build a small target dataset based on the preprocessed small target images and surveillance video data containing small targets. Label and divide the small target dataset to obtain a training set, a validation set, and a test set, including: Collect small target images and surveillance video data containing small targets to build an initial data set; Preprocess all images in the initial data set, and build a small target data set based on the preprocessed small target images and surveillance video data containing small targets; Use the LabelImg annotation tool, set to YOLO format, to manually annotate all images in the small object dataset; The manually annotated small object dataset is divided into training set, validation set and test set in proportion.
3. The improved YOLOv8 small target detection method integrating attention mechanism according to claim 1. Characterized in that: The original YOLOv8 network model is optimized to obtain an improved YOLOv8 network model, including: The 20 pixel × 20 pixel large target detection layer in the original YOLOv8 network model is deleted, and a 16 pixel × 16 pixel smaller target detection layer is added to obtain the optimized first YOLOv8 network model; Build the C2f_Res2Block module to replace the C2f module in the optimized first YOLOv8 network model; Construct the SA-SPPF module to replace the SPPF module in the optimized first YOLOv8 network model; In the optimized first YOLOv8 network model, GAM modules are added to the output ends of the two Upsample modules in the Neck part to obtain an improved YOLOv8 network.
4. The improved YOLOv8 small target detection method integrating attention mechanism according to claim 3. Characterized in that: The 20 pixel × 20 pixel large target detection layer in the original YOLOv8 network model is deleted, and a 16 pixel × 16 pixel small target detection layer is added to obtain the optimized first YOLOv8 network model, including: Delete the fifth CBS module and the fourth C2f module in the BackBone part of the original YOLOv8 network model; The first C2f module in the BackBone part of the original YOLOv8 network model is connected to the first Concat module in the Neck part, the second C2f module in the BackBone part is connected to the second Concat module in the Neck part, and the third C2f module in the BackBone part is connected to the SPPF module to obtain the optimized first YOLOv8 network model.
5. The improved YOLOv8 small target detection method integrating attention mechanism according to claim 3. Characterized in that: Build the C2f_Res2Block module to replace the C2f module in the optimized first YOLOv8 network model, including: Use the Res2Net module to replace the Bottleneck structure of the C2f module in the optimized first YOLOv8 network model, and build the optimized C2f_Res2Block module; Replace all seven C2f modules in the optimized first YOLOv8 network model with the optimized C2f_Res2Block module.
6. The improved YOLOv8 small target detection method integrating attention mechanism according to claim 3. Characterized in that: Construct the SA-SPPF module to replace the SPPF module in the optimized first YOLOv8 network model, including: In the optimized first YOLOv8 network model, a SimAM module is added to the output end of the first CBS module in the original SPPF module structure, and a SimAM module is added to the input end of the second CBS module; Connect the feature map at the input of the original SPPF module with the Concat module to construct the optimized SA-SPPF module; The SPPF module of the BackBone part in the optimized first YOLOv8 network model is replaced with the optimized SA-SPPF module.
7. The improved YOLOv8 small target detection method integrating attention mechanism according to claim 1, characterized in that: The improved YOLOv8 network model is trained using the training set. During the training process, the validation set is used to adjust the hyperparameters of the improved YOLOv8 network model to obtain a small target detection model. The performance of the small target detection model is evaluated using the test set, including: Use WIoU loss function to replace the CIoU loss function of the original YOLOv8 network model; The images in the training set are input into the improved YOLOv8 network model for iterative optimization. After each training cycle, the indicators of the improved YOLOv8 network model are calculated on the validation set, and the hyperparameters of the improved YOLOv8 network model during the training process are appropriately adjusted. The training is iterated until the WIoU loss function is fully converged, and the parameters of the improved YOLOv8 network model are saved to obtain the small target detection model. The performance of the small target detection model is evaluated using the test set.
8. An improved YOLOv8 small target detection system integrating attention mechanism, characterized in that: include: An image acquisition and preprocessing module is used to acquire small target images and surveillance video data containing small targets, preprocess the small target images and surveillance video data containing small targets, and construct a small target data set based on the processed small target images and surveillance video data containing small targets, and annotate and divide the small target data set to obtain a training set, a validation set, and a test set; The model optimization module is used to optimize the original YOLOv8 network model to obtain an improved YOLOv8 network model; The model training module is used to train the improved YOLOv8 network model using the training set, and to adjust the hyperparameters of the improved YOLOv8 network model using the validation set during the training process to obtain a small target detection model; and to evaluate the performance of the small target detection model using the test set; The small target detection module is used to deploy the small target detection model in the surveillance camera, and use the small target detection model to perform real-time monitoring and alarm on small targets that appear within the monitoring range of the surveillance camera.
9. An improved YOLOv8 small target detection device integrating attention mechanism, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the electronic device implements the steps of the improved YOLOv8 small target detection method integrating the attention mechanism as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the improved YOLOv8 small target detection method integrating the attention mechanism as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method for detecting mouse with bright kitchen and kitchen range based on cross attention enhancement
CN118097715A