A lightweight target learning detection method based on improved YOLOv8
By improving the data enhancement and model optimization methods of YOLOv8, the problem of parameter redundancy and computational complexity of YOLOv8 in fire detection has been solved, and the accuracy and speed of small target detection have been improved, making it suitable for terminal equipment deployment.
Patent Information
- Application Number
- CN202410416923.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-08
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-04-08
AI Technical Summary
The existing YOLOv8 target detection technology has problems with redundant model parameters and high computational complexity in fire detection, which makes it difficult to deploy lightweight mobile devices, and the data enhancement method cannot ensure parameter balance, affecting detection accuracy.
The improved Mixup algorithm is used for data enhancement, the YOLO detection model is trained and optimized through the MVB module, the MobileViTBlock module and self-attention calculation are introduced, and combined with the moving index average EMA, a lightweight mobile device target detection model based on the improved YOLOv8 is constructed to ensure Smooth update of parameter averages.
It has realized the lightweight improvement of YOLOv8, improved the accuracy and detection speed of small target detection, reduced resource consumption, ensured the balance between the extraction of global feature information and high performance, provided a solid foundation for terminal device deployment, and reduced Missed and incorrect detections.
Smart Images

Figure CN118212588B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision processing, and in particular to a lightweight target learning detection method based on improved YOLOv8. Background Art
[0002] Among the disasters that threaten public safety, fire is the most common one. Fire is characterized by uncertainty, complexity, and suddenness, and its occurrence can easily cause serious economic losses and casualties. With the rapid development of social economy, the factors that cause fires are gradually increasing, and various fire accidents continue to occur, seriously threatening the safety of people's lives and property and social harmony and stability. For fire early warning, it is necessary to detect and identify fire smoke, especially the detection of small fires or smoke in the early stages of a fire.
[0003] Early fire warnings mostly use traditional fire detectors, that is, the smoke, temperature or other factors generated by the fire trigger the detector to start the warning and fire extinguishing system. Various types of flame detectors mainly include thermal induction detectors and light induction detectors, which generally have defects such as response delays, easy failure or failure, and are not suitable for large spaces or outdoor scenes, which are difficult to solve.
[0004] In recent years, with the continuous deepening of deep learning related theories and the large-scale improvement of computer computing power, deep learning-based target detection technology has been further applied in industrial scenarios (industrial digital design, intelligent warehousing, and autonomous driving). YOLO (You Only Look Once) is a classic one-stage target detection algorithm. Its advantages are high real-time performance, simplicity and efficiency, multi-scale detection, global context information utilization, and multi-task learning. These features make it perform well in fast target detection and real-time application scenarios. Applying the YOLO series of detection algorithms and models to detection scenarios such as industry and life has become a hot research issue.
[0005] The target detection technology represented by YOLOv8 is currently the most advanced single-stage target detection technology, which greatly improves the detection performance and efficiency compared with the YOLO series and other target detection technologies. However, the YOLOv8 backbone network uses CNN-based CSPDarknet, which is difficult to extract the global feature information of the fire, and there are also problems such as model parameter redundancy and high computational complexity, which makes it difficult to deploy lightweight mobile devices and there is still a lot of room for improvement in meeting end-to-end industrial deployment.
[0006] For example, the Chinese patent application number is 202311205610.0, and the publication date is 2013.12.16. It discloses a YOLOv8-based fireworks detection method that integrates global information, and specifically discloses the following steps: S1: Collect pictures and videos of flames and smoke, extract frames from the collected videos, obtain image data, and annotate the image data to obtain a fireworks data set; S2: Enhance the fireworks data set to obtain an enhanced data set; S3: Build a BGCNet global context information network and add it between the backbone feature extraction network and feature pyramid network of the YOLOv8 network to obtain an improved YOLOv8 network; adjust parameters and train a YOLOv8 network detection model that integrates global information; S4: Load the YOLOv8 network detection model that integrates global information, input the enhanced data set, and perform fireworks detection; analyze the model inference results, and perform corresponding fireworks alarms according to different triggering thresholds. The above methods improve the accuracy and practicality of smoking behavior detection.
[0007] However, this method only explains how to adjust the pre-training parameters, but the adjustment of the pre-training parameters does not consider how to ensure that different parameter values are used in different stages of model training, and the parameters can be more average after adjustment, and there will be no subsequent weighted calculations affecting the effect of the model due to unbalanced parameter adjustment, resulting in inaccurate learning and detection. For example, due to the fact that the parameters are too small at a certain stage, small targets cannot be detected, or the parameters are too large at a certain stage, resulting in the problem of low detection accuracy of the target. In addition, after the enhancement process of the data set, blindly expanding the data through methods such as data rotation cannot achieve the average of the entire data fusion, thereby ensuring the accuracy of the data set. At the same time, the improved algorithm needs to add the network that constructs the BGCNet global context information, thereby increasing the YOLOv8 network, and the amount of data that needs to be processed is large. Summary of the invention
[0008] The present invention provides a lightweight target learning detection method based on improved YOLOv8, which achieves a balance between model lightweight and performance by improving the YOLOv8 structure, improves the accuracy of target detection results, and reduces missed detection and false detection of small targets.
[0009] To achieve the above object, the technical solution of the present invention is: a lightweight target learning detection method based on improved YOLOv8, the specific steps include:
[0010] (1) The fire smoke images in the scene are collected by the collection device to generate a data set, and the acquired fire smoke image data set is annotated. The improved Mixup algorithm is used to perform data enhancement preprocessing on the annotated flame data set in a uniformly distributed manner to form a processed data set.
[0011] (2) Divide the processed data set into training set, test set and validation set according to the preset ratio.
[0012] (3) The YOLO detection model is trained and optimized through the MVB module, and a lightweight mobile device target detection model based on the improved YOLOv8 is constructed.
[0013] (4) The lightweight mobile device target detection model based on the improved YOLOv8 is trained iteratively, and the parameters obtained by training the lightweight mobile device target detection model based on the improved YOLOv8 are subjected to moving exponential average EMA to obtain the parameter average value vt.
[0014] The process of moving average EMA with trained parameters includes the following steps:
[0015] (41) Set the parameter set θ = [θ1, θ2, ..., θ n ].
[0016] (42) Calculate the parameter mean v based on the parameter set t .
[0017] Parameter mean v t The expression is:
[0018] .
[0019] In the formula, v t Represents the average value of the parameters of the previous t times, which is close to the most recent The average value of the parameters; θ t is the parameter value of the tth time; A is the adjustable weighted value.
[0020] (43) Bias correction is performed on the parameter mean value.
[0021] (5) Based on the performance evaluation indicators, the fire detection model is screened out to obtain the optimal target detection model.
[0022] (6) Use the optimal target detection model to detect the images in the test set, output the bounding box with the highest confidence, and complete the detection of fire images.
[0023] The beneficial effects of the above method are as follows: by adding the MVB module to the backbone network of YOLOv8, a new backbone network for lightweight mobile devices based on improved YOLOv8 is constructed, and compared with the original model, YOLOv8 lightweight improvement is achieved, small target detection is optimized, and the problems of model parameter redundancy and high computational complexity are solved. Compared with the original model, a balance between extracting global feature information and high performance is achieved, laying a solid foundation for transplantation to terminal devices; in terms of data enhancement, the Mixup algorithm is used, and the image fusion method of Mixup is modified to a certain extent. The data set is enlarged using a uniform distribution mode, which increases the training data set and can also greatly improve the robustness of the algorithm. This allows for higher accuracy in detection while maintaining a faster detection speed. At the same time, the parameters are trained on a lightweight mobile device target detection model based on the improved YOLOv8 to perform a moving average EMA. The exponential moving average EMA can be used to estimate the local mean of the variable, so that the update of the variable is related to the historical value over a period of time. The exponential moving average EMA can be regarded as the average of the values of the variable over a period of time. Compared with direct assignment of values to the variable, the value obtained by the exponential moving average EMA is smoother and has less jitter on the image, and will not cause the exponential moving average to fluctuate greatly due to an abnormal value. Different parameter values are used at different stages of model training to better average the parameters of the model, so that the parameters used at different stages have a better average, so that in the later stages of training, there is no need to worry about the use of weighted calculations affecting the effect of the model, so that the accuracy of detection is further improved, which can prevent problems such as missed detection due to too small parameters and prevent the occurrence of false detection problems.
[0024] Furthermore, step (3) specifically includes:
[0025] (31) The lightweight MobileViTBlock module with attention mechanism is introduced into the second C2f and third C2f modules in the backbone network of the lightweight mobile device target detection model of YOLOv8.
[0026] (32) The improved self-attention calculation referenced in the MobileViTBlock module is optimized to obtain the optimized MVB module.
[0027] The above settings further optimize MobileViT to obtain the optimized MVB module. The reference of MobileViT enables the model to achieve a balance between extracting global feature information and high performance, laying a solid foundation for porting to terminal devices. At the same time, the improved self-attention calculation is referenced in the MobileViTBlock module, thereby further reducing resource consumption and algorithm complexity.
[0028] Furthermore, the improved Mixup algorithm is expressed as:
[0029] .
[0030] .
[0031] In the formula, is the mixed batch sample, is the label corresponding to the mixed batch sample; , There are two batch samples respectively. , are the labels corresponding to the above two batch samples respectively; λ obeys a uniform distribution with parameters (a, b), where a and b are two set constants.
[0032] The above settings are improved through the Mixup algorithm, and the data set corresponding to the uniformly distributed parameters is expanded, so that the entire data set is also close to a uniform distribution, thereby increasing the training data set, making it more accurate during detection, while maintaining a faster detection speed and preventing the data set from being affected by robustness.
[0033] Furthermore, the deviation correction calculation formula of the parameter mean value is:
[0034] .
[0035] Wherein, v′ is the corrected parameter average value, and α is the preset adjustable weighted value.
[0036] The above settings correct the calculated parameter average value through the adjustable weighted weight value and time t, so that the corrected parameter average value can maintain the weight of the shadow at time t, ensuring the accuracy of the training set.
[0037] Furthermore, step (5) specifically includes the performance evaluation indicators including precision, recall, average precision (AP), mean average precision (mAP) and FScore value.
[0038] The above settings make it easy to screen out the optimal target detection model through performance evaluation indicators.
[0039] Furthermore, the expression of the precision Precision is:
[0040] .
[0041] The expression of recall rate Recall is:
[0042] .
[0043] In the formula, TP is the number of positive samples correctly identified as positive samples, FN is the number of positive samples incorrectly identified as negative samples, and FP is the number of negative samples incorrectly identified as positive samples.
[0044] The expressions of the average precision AP, average precision mean mAP and FScore value are:
[0045] .
[0046] .
[0047] .
[0048] In the formula, P is the precision, that is, the precision, and R is the recall. Set B to 1, and we get ; AP is the area under the PR curve; mAP is the average AP value calculated after calculating the AP for each category, and N is the total number of each category.
[0049] The above settings can facilitate the calculation of the performance evaluation indicators of the optimal target detection model for the data set through the above formula.
[0050] Furthermore, the backbone network of YOLOv8 includes a first CBS convolution module, a second CBS convolution module, a first C2f module, a third CBS convolution module, a first MVB module, a fourth CBS convolution module, a second MVB module, a fifth CBS convolution module, a second C2f module and an SPPF module, which are connected in sequence.
[0051] The above settings improve YOLOv8 by replacing the second C2f module and the third C2f module of the original YOLOv8 with the first MVB module and the second MVB module so that MobileViT can be referenced, which enables the model to achieve a balance between extracting global feature information and high performance.
[0052] Furthermore, the MVB module includes a local feature modeling module, a global feature modeling module and a feature fusion module. The local feature modeling module realizes the extraction of local features. The global feature modeling module completes the extraction of global features through Unfold, Transformer and Fold. The feature fusion module splices the feature map through the shortcut branch, and finally obtains the output feature map that integrates the local feature information and the global feature information.
[0053] The above settings, by adding the MVB module to the YOLOv8 backbone network, build a new lightweight mobile device backbone network based on the improved YOLOv8. Compared with the original model, the YOLOv8 lightweight improvement is achieved, the small target detection is optimized, and the end-to-end mobile device industrial deployment requirements are met.
[0054] Furthermore, step (32) specifically includes:
[0055] (321) Construct a local feature modeling module and use a normal convolution 3x3 and a normal convolution 1x1 module to extract local features of the input image.
[0056] (322) Construct a global feature modeling module and introduce Unfold and Fold operations. First, the feature map is reorganized by Unfolding, and the feature map is converted into image blocks of preset size. The pixels at the same position in each image block are reorganized into a sequence. Then, self-attention operation is performed on the pixels of the same color between each image block, and finally, it is folded to the original feature map size.
[0057] (323) Construct a feature fusion module to directly fuse local features with global features.
[0058] The above settings further optimize MobileViT to obtain the optimized MVB module. By solving the problems of model parameter redundancy and high computational complexity, it achieves a balance between extracting global feature information and high performance compared to the original model, laying a solid foundation for transplantation to terminal devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is the work flow chart of the present invention.
[0060] Figure 2 It is a structural diagram of the backbone network of YOLOv8 of the present invention.
[0061] Figure 3 This is a comparison chart of the actual effect detection of scenario 1 of the present invention.
[0062] Figure 4 This is a comparison chart of indicators detected by the algorithm of this embodiment and the YOLOv8 algorithm in scenario 1 of the present invention.
[0063] Figure 5 This is a comparison chart of the actual effect detection of scenario 2 of the present invention.
[0064] Figure 6 This is a comparison chart of indicators detected by the algorithm of this embodiment and the YOLOv8 algorithm in scenario 2 of the present invention.
[0065] Figure 7This is a flow chart of the attention operation of the present invention.
[0066] Figure 8 It is a structural diagram of the MobileViTBlock module in the prior art.
[0067] Fig. 9 This is a structural diagram of the MVB module in the present invention. DETAILED DESCRIPTION
[0068] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0069] like Figure 1 As shown, a lightweight target learning detection method based on improved YOLOv8, the specific steps include:
[0070] (1) The fire and smoke images in the scene are collected by the acquisition device to generate a data set, the acquired fire and smoke image data set is annotated, and the improved Mixup algorithm is used to perform data enhancement preprocessing on the annotated flame data set in a uniformly distributed manner to form a processed data set.
[0071] (2) Divide the processed data set into training set, test set and validation set according to the preset ratio. The preset ratio is preset.
[0072] (3) The YOLO detection model is optimized through the MVB module, and a lightweight mobile device target detection model based on the improved YOLOv8 is constructed.
[0073] Step (3) specifically includes steps (31) to (32);
[0074] (31) Introduce the lightweight MobileViTBlock module with attention mechanism into the second C2f and third C2f modules in the backbone network of the lightweight mobile device target detection model of YOLOv8. Figure 1 As shown, the backbone network of the lightweight mobile device target detection model of YOLOv8 in the present application includes a first CBS convolution module 1, a second CBS convolution module 2, a first C2f module 3, a third CBS convolution module 4, a first MVB module 5, a fourth CBS convolution module 6, a second MVB module 7, a fifth CBS convolution module 8, a second C2f module 9 and an SPPF module 01 connected in sequence, while the first MVB module 5 and the second MVB module 7 are the second C2f and third C2f modules in the existing YOLOv8.
[0075] (32) The improved self-attention calculation in the MobileViTBlock module is optimized to obtain the optimized MVB module. Fig. 9 As shown,
[0076] Step (32) includes steps (321)-(323);
[0077] (321) Construct a local feature modeling module and use a normal convolution 3x3 and a normal convolution 1x1 module to extract local features of the input image.
[0078] (322) Construct a global feature modeling module and introduce Unfold and Fold operations. First, Unfold is used to reorganize the feature map into image blocks of a preset size. The pixels at the same position in each image block are reorganized into a sequence. Then, self-attention operations are performed on the pixels of the same color between each image block, and finally, they are folded back to the original feature map size. Figure 7 As shown, in the process of attention operation, it is necessary to first divide the feature image into multiple image blocks, then reorganize each image block into a sequence on the same channel, and then merge the pixels of the same color between each image block to form a feature map of 1 row, 1 column and C channels, and then fold to form the original feature map size. In this embodiment, the optimization of the MVB module is specifically as follows: an improved self-attention calculation is introduced to reduce resource consumption and algorithm complexity. Taking the number of feature map channels C=1 as an example, the feature map height is H, the width is W, the feature map is divided into several 2*2 image blocks (red border blocks), each image block contains 12 pixels (small blocks of different colors), and the pixels of the same color between each image block are self-attention calculated, with a complexity of O(H*W*C) / 4, while the traditional self-attention is to perform self-attention calculation between each pixel of the entire feature map, with a complexity of O(H*W*C), and the complexity of the improved algorithm is 1 / 4 of the traditional algorithm.
[0079] (323) Construct a feature fusion module to directly fuse local features with global features. Figure 8 As shown, the existing MobileViTBlock module fuses the input global features with the corresponding local features formed by unfolding and folding to form H*W*2C, while in this embodiment, Fig. 9 As shown, the MVB module directly fuses the input global features with the corresponding local features formed by expansion and folding to form an H*W*C feature map, so the existing MobileViTBlock module has a large amount of data and the existing MobileViTBlock module does not add attention operation, which results in a large amount of data and poor data balance.
[0080] (4) The lightweight mobile device target detection model based on the improved YOLOv8 is trained iteratively, and the parameters obtained by training the lightweight mobile device target detection model based on the improved YOLOv8 are subjected to moving exponential average EMA to obtain the parameter average value vt.
[0081] The process of moving average EMA with trained parameters includes the following steps:
[0082] (41) Set the parameter set θ = [θ1, θ2, ..., θ n ].
[0083] (42) Calculate the parameter mean v based on the parameter set t .
[0084] Parameter mean v t The expression is:
[0085] .
[0086] In the formula, v t Represents the average value of the parameters of the previous t times, which is close to the most recent The average value of the parameters; θ t is the parameter value of the tth time; A is the adjustable weight value, which ranges from 0.9 to 0.999.
[0087] (43) Bias correction is performed on the parameter mean value.
[0088] (5) Based on the performance evaluation indicators, the fire detection model is screened out to obtain the optimal target detection model.
[0089] (6) Use the optimal target detection model to detect the images in the test set, output the bounding box with the highest confidence, and complete the detection of fire images.
[0090] The improved Mixup algorithm expression is:
[0091] .
[0092] .
[0093] In the formula, is the mixed batch sample, is the label corresponding to the mixed batch sample; , There are two batch samples respectively. , are the labels corresponding to the above two batch samples respectively; λ obeys a uniform distribution with parameters (a, b), where a and b are two set constants. In this embodiment, a=0.2 and b=0.8.
[0094] The Mixup algorithm is improved to increase the training data set, so that the detection accuracy is higher while maintaining a faster detection speed.
[0095] The deviation correction calculation formula of the parameter average value in step (43) is:
[0096] .
[0097] Wherein, v′ is the corrected parameter average value, and α is the preset adjustable weighted value.
[0098] Step (5) specifically includes the performance evaluation indicators including precision, recall, average precision (AP), mean average precision (mAP) and FScore value.
[0099] Performance evaluation indicators make it easier to screen out the optimal target detection model.
[0100] The expression of the precision Precision is:
[0101] .
[0102] The expression of recall rate Recall is:
[0103] .
[0104] In the formula, TP is the number of positive samples correctly identified as positive samples, FN is the number of positive samples incorrectly identified as negative samples, and FP is the number of negative samples incorrectly identified as positive samples.
[0105] The expressions of the average precision AP, average precision mean mAP and FScore value are:
[0106] .
[0107] .
[0108] .
[0109] In the formula, P is the precision, that is, the precision, and R is the recall. Set B to 1, and we get ; AP is the area under the PR curve; mAP is the average AP value calculated after calculating the AP for each category, and N is the total number of each category.
[0110] The improved model YOLOv8-MVB is first pre-trained on the general dataset CoCo2017. The CoCo2017 dataset includes a training set (118,287 images), a validation set (5,000 images), and a test set (40,670 images), with a total size of 25G.
[0111] The YOLOv8-MVB model trained with the CoCo2017 dataset was used for transfer learning and training on a self-made dataset. The experimental equipment is an Alibaba Cloud DSW server with 8 CPUs, 32 GB of memory, and a GPU of NVIDIA V10016G. The Pytorch framework is used, and the SGD optimizer is used. The learning rate is 0.001, the momentum factor is 0.973, and the number of iterations is 200. The training parameter configuration is shown in Table 1 below.
[0112] Table 1 Training parameter configuration table
[0113]
[0114] In order to further verify the effects of the YOLOv8-MVB method of the present invention and the existing YOLOv8 algorithm, the two algorithms are verified respectively for two application scenarios. In Example 1, step (1) specifically includes scenario 1 such as Figure 3 - Figure 4 The picture shows a complex fire scene. Figure 3 (a) is a manually labeled sample, (b) is the result of the YOLOv8 algorithm, and (c) is the result of the algorithm in this embodiment. The comparison of detection effects shows that: for scene 1 (complex fire scene), the first small target image in (b) is missed by YOLOv8, while the improved algorithm of the present invention correctly detects this key small target; in the fourth image in (c), the detection accuracy of the improved algorithm of the present invention is 0.7, which is much higher than the detection accuracy of YOLOv8 of 0.4. Figure 4 It is a comparison curve diagram of detection indicators between the existing YOLOv8 algorithm and the present algorithm, wherein the white line indicated by 10 is the corresponding curve diagram of the existing algorithm, and the black line indicated by 11 is the comparison curve diagram of detection indicators of the algorithm corresponding to the present embodiment. It can be seen from the figure that the present embodiment has a higher-precision detection effect, especially in the actual detection effect of small targets. The algorithm of the present invention has achieved a great advantage and reduced false detections and missed detections.
[0115] In this embodiment 1, the experimental results of the YOLOv8-MVB algorithm and the existing YOLOv8 algorithm are shown in Table 2 below.
[0116] Table 2 Algorithm Experimental Results Comparison Table (Example 1)
[0117]
[0118] Experiments show that the YOLOv8-MVB algorithm of the present invention achieves better performance in mAP value, F1Score and Precision than the YOLOv8 algorithm in complex fire data detection. In the mAP index comparison, the mAP50-95 index of YOLOv8 is 30.98%, while the mAP50-95 value of the algorithm of the present invention is up to 31.97%, which is 1 percentage point higher than that of YOLOv8. In the F1Score value comparison, the F1Score value of the algorithm in this embodiment reaches 61.33%, which is ahead of YOLOv8's 60.08%. The algorithm accuracy in this embodiment reaches 67.43%, which is 3.6 percentage points higher than that of YOLOv8.
[0119] In another embodiment, scenario 2 is as follows Figure 5 - Figure 6 The following figure shows the target detection in life scenes. Figure 6 (a) is a manually labeled sample, (b) is the result of the YOLOv8 algorithm, and (c) is the result of the improved YOLOv8 algorithm. Figure 6 20 is a curve diagram for comparing the detection indexes of the existing YOLOv8 algorithm and the present algorithm in this embodiment, wherein 20 is a curve diagram corresponding to the existing algorithm, and 30 is a curve diagram for comparing the detection indexes of the corresponding algorithm in this embodiment, Figure 6 The white lines corresponding to 20 in each figure are the corresponding curves of the existing YOLOv8 algorithm, and the black lines corresponding to 30 in each figure are the detection index comparison curves of the corresponding algorithms of this embodiment. The comparison of the detection effects shows that: for scene 2 (life scene), YOLOv8 detects one target as two targets in the first picture in (b), while the improved algorithm of the present invention completely and correctly detects this target; in the second picture in (b), YOLOv8 only detects the cat and misses the long bench below, while the improved algorithm of the present invention completely and correctly detects these two targets; in the third picture in (b), the improved algorithm detection target accuracy is 0.9, which is greater than the detection accuracy of YOLOv8 of 0.8. The experiment once again proves that the method of the present invention has better detection effect than the existing YOLOv8, with higher accuracy and detection accuracy, especially in the actual detection effect of small targets, the algorithm of the present invention has achieved a greater advantage, reducing false detection and missed detection.
[0120] In the second embodiment, the experimental results of the YOLOv8-MVB algorithm of the present invention and the existing YOLOv8 algorithm are shown in Table 3 below.
[0121] Table 3 Algorithm Experimental Results Comparison Table (Example 2)
[0122]
[0123] In the target detection of life scenes by the YOLOv8-MVB algorithm of the present invention, the YOLOv8-MVB algorithm of the present invention has improved all indicators compared with the YOLOv8 algorithm. In the mAP index comparison, the mAP50-95 index of YOLOv8 is 34.75%, while the mAP50-95 value of the algorithm of the present invention is up to 43.75%, which is 9 percentage points higher than that of YOLOv8. In the F1Score value comparison, the F1Score value of the algorithm in this embodiment reaches 61.01%, which is more than 9 percentage points ahead of YOLOv8. The algorithm accuracy in this embodiment reaches 68.89%, which is 9.5 percentage points higher than that of YOLOv8.
[0124] Experiments show that the YOLOv8-MVB detection algorithm of the present invention is superior to the original YOLOv8 detection algorithm in both fire scene and life scene detection, especially in Example 2 (life scene). Since the model of the present invention is pre-trained on the CoCo2017 dataset, the transfer learning effect is obvious, so the detection effect is more superior.
[0125] The beneficial effects of this method are as follows: by adding the MVB module to the backbone network of YOLOv8, a new backbone network for lightweight mobile devices based on improved YOLOv8 is constructed. Compared with the original model, YOLOv8 lightweight improvement is achieved, small target detection is optimized, and the problems of model parameter redundancy and high computational complexity are solved. Compared with the original model, a balance between extracting global feature information and high performance is achieved, laying a solid foundation for transplantation to terminal devices; in terms of data enhancement, the Mixup algorithm is used, and the image fusion method of Mixup is modified to a certain extent. The data set is enlarged using a uniform distribution mode to increase the training data set, and the robustness of the algorithm can also be greatly improved. This allows for higher accuracy in detection while maintaining a faster detection speed. At the same time, the parameters are trained on a lightweight mobile device target detection model based on the improved YOLOv8 to perform a moving average EMA. The exponential moving average EMA can be used to estimate the local mean of the variable, so that the update of the variable is related to the historical value over a period of time. The exponential moving average EMA can be regarded as the average of the values of the variable over a period of time. Compared with direct assignment of values to the variable, the value obtained by the exponential moving average EMA is smoother and has less jitter on the image, and will not cause the exponential moving average to fluctuate greatly due to an abnormal value. Different parameter values are used at different stages of model training to better average the parameters of the model, so that the parameters used at different stages have a better average, so that in the later stages of training, there is no need to worry about the use of weighted calculations affecting the effect of the model, so that the accuracy of detection is further improved, which can prevent problems such as missed detection due to too small parameters and prevent the occurrence of false detection problems.
Claims
1. A lightweight target learning detection method based on improved YOLOv8, characterized by: The specific steps include: (1) The fire smoke images in the scene are collected by the collection device to generate a data set, and the acquired fire smoke image data set is annotated. The improved Mixup algorithm is used to perform data enhancement preprocessing on the annotated flame data set in a uniformly distributed manner to form a processed data set; (2) Divide the processed data set into training set, test set and validation set according to the preset ratio; (3) Optimize the YOLO detection model through the MVB module and build a lightweight mobile device target detection model based on the improved YOLOv8; (31) Introducing the lightweight MobileViTBlock module with attention mechanism into the second C2f and third C2f modules in the backbone network of the lightweight mobile device target detection model of YOLOv8; (32) Optimize the improved self-attention calculation referenced in the MobileViTBlock module to obtain the optimized MVB module; (321) Construct a local feature modeling module and use a normal convolution 3x3 and a normal convolution 1x1 module to extract local features of the input image; (322) Construct a global feature modeling module and introduce Unfold and Fold operations. First, Unfold is used to reorganize the feature map into image blocks of a preset size. The pixels at the same position in each image block are reorganized into a sequence. Then, self-attention operations are performed on the pixels of the same color between each image block, and finally, they are folded back to the original feature map size. (323) Construct a feature fusion module to directly fuse local features with global features; (4) Iterate the training of the lightweight mobile device target detection model based on the improved YOLOv8, perform moving exponential average EMA on the parameters obtained by training the lightweight mobile device target detection model based on the improved YOLOv8, and obtain the parameter average value vt; The process of moving average EMA with trained parameters includes the following steps: (41) Set the parameter set θ = [θ1, θ2, ..., θ n ]; (42) Calculate the parameter mean v based on the parameter set t ; Parameter mean v t The expression is: ; In the formula, v t Represents the average value of the parameters of the previous t times, which is close to the most recent The average value of the parameters; θ t is the parameter value of the tth time; A is the adjustable weighted value; (43) Correct the deviation of the parameter mean value; (5) Screen out the fire detection model based on the performance evaluation index to obtain the optimal target detection model; (6) Use the optimal target detection model to detect the images in the test set, output the bounding box with the highest confidence, and complete the detection of fire images.
2. According to claim 1, a lightweight target learning detection method based on improved YOLOv8 is characterized in that: The improved Mixup algorithm expression is: ; ; In the formula, is the mixed batch sample, is the label corresponding to the mixed batch sample; , There are two batch samples respectively. , are the labels corresponding to the above two batch samples respectively; λ obeys a uniform distribution with parameters (a, b), where a and b are two set constants.
3. According to claim 1, a lightweight target learning detection method based on improved YOLOv8 is characterized in that: The deviation correction calculation formula of the parameter mean value is: ; Wherein, v′ is the corrected parameter average value, and α is the preset adjustable weighted value.
4. According to claim 1, a lightweight target learning detection method based on improved YOLOv8 is characterized in that: Step (5) specifically includes the performance evaluation indicators including precision, recall, average precision (AP), mean average precision (mAP) and FScore value.
5. According to claim 4, a lightweight target learning detection method based on improved YOLOv8 is characterized in that: The expression of the precision Precision is: ; The expression of recall rate Recall is: ; In the formula, TP is the number of positive samples correctly identified as positive samples, FN is the number of positive samples incorrectly identified as negative samples; FP is the number of negative samples incorrectly identified as positive samples The expressions of the average precision AP, average precision mean mAP and FScore value are: ; ; ; Where, is the precision, R is the recall, and B is set to 1, and we get ; AP is the area under the PR curve; mAP is the average value of AP after calculating AP for each category.
6. The method for lightweight target learning detection based on improved YOLOv8 according to claim 1, characterized in that: The backbone network of YOLOv8 includes a first CBS convolution module, a second CBS convolution module, a first C2f module, a third CBS convolution module, a first MVB module, a fourth CBS convolution module, a second MVB module, a fifth CBS convolution module, a second C2f module and an SPPF module, which are connected in sequence.
7. The method for lightweight target learning detection based on improved YOLOv8 according to claim 6, characterized in that: The MVB module includes a local feature modeling module, a global feature modeling module and a feature fusion module. The local feature modeling module realizes the extraction of local features. The global feature modeling module completes the extraction of global features through Unfold, Transformer and Fold. The feature fusion module splices the feature map through the shortcut branch, and finally obtains the output feature map that integrates the local feature information and the global feature information.
