A lightweight saccharomyces cerevisiae detection method based on improved YOLOv8
By improving the multi-scale pyramid pooling layer and efficient feature screening pyramid network of the YOLOv8 model, and combining it with the PIOU regression loss function, the detection method for brewing yeast was optimized. This solved the problems of large number of detection parameters and heavy computational burden in brewing yeast cell detection, achieving lightweight and real-time detection and improving the level of intelligence in the brewing industry.
Patent Information
- Application Number
- CN202411951982.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-12-27
AI Technical Summary
Existing methods for detecting brewer's yeast cells have a large number of parameters and a heavy computational burden, making it difficult to achieve real-time detection. They also have low accuracy in complex backgrounds and are difficult to deploy on mobile devices.
An improved YOLOv8 model was adopted. By designing an improved multi-scale pyramid pooling layer and an efficient feature screening pyramid network, combined with the PIOU regression loss function, the network architecture was optimized, the feature extraction and fusion capabilities were enhanced, the number of model parameters was reduced, and the recognition accuracy of Saccharomyces cerevisiae cells was improved.
It achieves lightweight detection of brewing yeast cells, enabling efficient real-time detection on mobile devices, improving the level of intelligence in the brewing industry, reducing the computational burden, and increasing the accuracy of brewing yeast cell identification.
Smart Images

Figure CN119919716B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8, belonging to the technical field of image processing. BACKGROUND
[0002] Saccharomyces cerevisiae cells are a kind of eukaryotic single-cell microorganisms that have attracted widespread attention, and they have shown great research value in the food industry, biological field and medical field. In the industrial field, in order to reduce costs and increase production, yeast is often recycled, but as the number of cycles increases, the yeast cells will gradually age. During this process, the viability and comprehensive performance of the recycled yeast strain need to be evaluated to ensure that its quality meets the requirements of the production process. Therefore, identifying and locating cell morphological differences is of great significance for understanding the physiological functions and reaction mechanisms of yeast.
[0003] Early yeast cell morphology detection faces many difficulties and challenges. Conventional detection methods include absorbance measurement, hemocytometer method, and plate colony counting method, but these methods are offline methods for evaluation and cannot provide accurate morphological data in real time. Plate colony counting method can count the number of cells, but cell density can lead to inaccurate calculation and consume a lot of time. Direct observation under a microscope is intuitive, but manual operation is slow and long-term operation can cause physical damage. Therefore, there is still much room for improvement in yeast cell detection methods, and a low-cost, high-accuracy, simple-to-operate, and fast-detection method is needed. With the development of deep learning, some scholars have used object detection models for yeast cell recognition, but in practical applications, there are still many challenges. Due to the small differences between different types of budding, the small size of budding cells, and the presence of broken cells in the background, there are still many missed and false detections, which require detection personnel to spend a lot of time reviewing. Although existing improved models can improve detection accuracy to some extent, the improvements often result in an increase in the number of model parameters and an increase in computational burden, making it difficult to achieve real-time fermentation process detection and deploy the model on mobile devices. SUMMARY
[0004] To solve the problem of large number of parameters in the detection model in practical applications, the present application provides a lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8, and the technical solution is as follows:
[0005] As one aspect of the present application, a lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8 is provided, comprising:
[0006] Step 1: Prepare the data set, divide the labeled Saccharomyces cerevisiae cell image data set into training set and validation set;
[0007] Step 2: Construct an EHS-YOLO model based on YOLOv8 with enhanced feature fusion characteristics, including a backbone feature extraction network, a feature fusion network, and a detection head, wherein an improved CSPDarkNet53 is selected as the backbone feature extraction network;
[0008] Step 3: Design an improved multi-scale pyramid pooling layer after the backbone feature extraction network to replace the fast spatial pyramid pooling structure in YOLO v 8 to perform multi-scale feature extraction on the Saccharomyces cerevisiae cell images;
[0009] Step 4: In the feature fusion network, design an efficient feature screening pyramid network to replace the original neck structure to combine the low-level detail information and high-level semantic information of the Saccharomyces cerevisiae cell images;
[0010] Step 5: Use PIoU as the regression loss function, use the training set prepared in step 1, and train the EHS-YOLO model based on early stopping operation; the PIoU regression loss function takes the side length of the target box as the denominator and introduces a penalty function to dynamically adjust the gradient according to the quality of the anchor box;
[0011] Step 6: Input the Saccharomyces cerevisiae cell images in the validation set into the best model obtained by training to verify and save the best model;
[0012] Step 7: Use the best model to detect the Saccharomyces cerevisiae cell images to be detected and obtain the visual detection results of the Saccharomyces cerevisiae cell images to be detected.
[0013] Further, the backbone feature extraction network uses an improved CSPDarknet-53 for feature extraction, and an improved multi-scale pyramid pooling layer module is introduced in the last layer of the backbone feature extraction network;
[0014] The feature fusion network is based on the feature pyramid network structure and designs top-down high feature fusion layers, medium feature fusion layers, and low feature fusion layers, and introduces spatial attention modules and channel attention modules at each layer to realize feature information fusion between feature maps of different sizes;
[0015] The detection head completes the regression and classification tasks through the decoupling head.
[0016] Further, step 3 includes:
[0017] Step 3-1: For the input , and the first feature map F1 will enter the first average pooling layer for feature fusion, and the first average pooling layer outputs a second feature map F 12 , and the second feature map F 12 will enter the second maximum pooling layer for feature fusion, and the second maximum pooling layer outputs a third feature map F 123 , and the third feature map F 123 will enter the second average pooling layer for feature fusion, and the second average pooling layer outputs a fourth feature map F 1234 ; wherein W represents the width of the input feature map, H represents the height of the input feature map, and C in represents the number of channels of the input feature map.
[0018] Step 3-2: After the first feature map F1, the second feature map F 12 , the third feature map F 123 and the fourth feature map F 1234 are spliced, a multi-scale fusion feature map is obtained through 1x1 convolution, and the expression of the multi-scale fusion feature map is:
[0019]
[0020] wherein, represents the splicing operation of the tensor, Conv represents convolution, wherein W represents the width of the multi-scale fusion feature map, H represents the height of the multi-scale fusion feature map, and C out represents the number of channels of the multi-scale fusion feature map.
[0021] Further, step 4 includes:
[0022] Step 4-1: The high-level initial feature map F H , the middle-level initial feature map F M and the low-level initial feature map F L are respectively processed through the SA module to obtain a high-level intermediate feature map, a middle-level intermediate feature map and a low-level intermediate feature map;
[0023] Step 4-2: The high-level intermediate feature map, the middle-level intermediate feature map and the low-level intermediate feature map are respectively processed through 1x1 convolution to obtain corresponding high-level first feature map F′ H , middle-level first feature map F′ M and low-level first feature map F′ L ;
[0024] Step 4-3: The high-level first feature map F′H The middle layer second feature map F MC is obtained by upsampling to the same dimension as the low layer first feature map through a deconvolution operation. MC LC ;
[0025] Step 4-4: The middle layer second feature map F MC and the low layer second feature map F LC respectively pass through the CA module for channel feature weighting to obtain the middle layer third feature map F' MC and the low layer third feature map F' LC ;
[0026] Step 4-5: The middle layer third feature map F' MC and the middle layer first feature map F' M are multiplied at the corresponding pixel points to obtain the middle layer output feature map F The low layer third feature map F' LC and the low layer first feature map F' L are multiplied at the corresponding pixel points to obtain the low layer output feature map F The expressions of the middle layer output feature map F and the low layer output feature map F are respectively:
[0027]
[0028] Wherein, represents the dot product operation;
[0029] Step 4-6: The middle layer output feature map F and the middle layer second feature map F MC are added at the corresponding pixel points to obtain the middle layer fusion feature map F OM The low layer output feature map F and the low layer second feature map F LC are added at the corresponding pixel points to obtain the low layer fusion feature map F OL The expressions of the middle layer fusion feature map F OM and the low layer fusion feature map F OL are respectively:
[0030]
[0031] Wherein, + represents the element addition in the corresponding channel, so as to realize the full fusion of the high layer, the middle layer and the low layer features;
[0032] Step 4-7: The high layer first feature map F' H The middle layer fusion feature map F OM and the low layer fusion feature map F OL After network optimization by the cross-stage feature fusion module respectively, the detection results are output by the Detect layer respectively.
[0033] Further, the expression of the PIoU regression loss function is:
[0034]
[0035] wherein L IoU represents a gradient adjustment function loss function, and Δw1, Δw2, Δh1 and Δh2 respectively represent the absolute values of the distances between the corresponding edges of the predicted frame and the target, w gt and h gt respectively represent the width and height of the target frame, and P represents a penalty factor, which is used to enhance the medium quality anchor frame in the regression process of each anchor box.
[0036] Further, the attention is introduced into the PIoU regression loss function, and the penalty factor P is replaced by q to obtain a PIoU2 regression loss function, and the expression of the PIoU2 regression loss function is:
[0037]
[0038] q = e -p , q element of (0, 1]
[0039]
[0040] wherein r(λx) represents an attention function, which is used to control different attention behaviors by different λ values.
[0041] As another aspect of the present application, a target detection method is provided, which adopts the above-mentioned lightweight Saccharomyces cerevisiae detection method based on the improved YOLOv8 to detect a to-be-detected image, and the to-be-detected image is an image in the field of cell detection.
[0042] As another aspect of the present application, a computer device is provided, which comprises a processor and a memory, the memory is used to store computer instructions, the computer instructions are loaded and executed by the processor to realize the above-mentioned lightweight Saccharomyces cerevisiae detection method based on the improved YOLO v 8.
[0043] The present application provides a lightweight Saccharomyces cerevisiae detection method based on the improved YOLO vThe lightweight Saccharomyces cerevisiae detection method of claim 8 proposes a lightweight EHS-YOLO network model, which enhances the feature extraction and fusion capability by designing an improved multi-scale pyramid pooling layer and an efficient feature screening pyramid network, optimizes the network architecture, improves the recognition accuracy of cells in each life cycle, and can focus more on the medium quality anchor frame when processing complex images, thereby improving the recognition accuracy of Saccharomyces cerevisiae cells. With fewer model parameter amounts, the Saccharomyces cerevisiae cell recognition accuracy can be optimized, the lightweight Saccharomyces cerevisiae cell detection is realized, the computing burden is greatly reduced, which is conducive to realizing real-time fermentation process detection and deploying to mobile devices for efficient detection, helping to realize real-time and automatic production monitoring and improving the intelligent level of the entire brewing industry. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0045] Figure 1 An improved YOLO-based Saccharomyces cerevisiae detection method is provided for the embodiments of the present application. v The overall flowchart of the lightweight Saccharomyces cerevisiae detection method of claim 8 is shown in the figure.
[0046] Figure 2 The overall structure diagram of the EHS-YOLO model provided for the embodiments of the present application is shown in the figure.
[0047] Figure 3 The principle diagram of the improved multi-scale pyramid pooling layer EMSPPM provided for the embodiments of the present application is shown in the figure.
[0048] Figure 4 The principle diagram of the efficient feature screening pyramid network EHS-FPN provided for the embodiments of the present application is shown in the figure.
[0049] Figure 5 The structure diagram of the spatial attention module SA provided for the embodiments of the present application is shown in the figure.
[0050] Figure 6 The structure diagram of the channel attention module CA provided for the embodiments of the present application is shown in the figure
[0051] Figure 7 The calculation principle diagram of the PIoU loss function provided for the embodiments of the present application is shown in the figure.
[0052] Figure 8 The detection result visualization diagram provided for the embodiments of the present application is shown in the figure. DETAILED DESCRIPTION
[0053] In order to make the purposes, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.
[0054] Embodiment one:
[0055] The present embodiment provides a lightweight Saccharomyces cerevisiae cell detection method based on YOLOv8 improvement, as shown in the following formula (I): Figure 1 The formula (I) comprises the following steps:
[0056] Step 1: Prepare the data set, divide the labeled Saccharomyces cerevisiae cell image data set into a training set and a validation set;
[0057] Step 2: Build an EHS-YOLO (Enhanced High-level Screening-YOLO) model with enhanced feature fusion characteristics based on YOLOv8, including a backbone feature extraction network Backbone, a feature fusion network Neck and a detection head Head, and select an improved CSPDarkNet53 as the backbone feature extraction network;
[0058] Step 3: Design an improved multi-scale pyramid pooling layer (Enhanced Multi-scale Pooling Pyramid Module, EMSPPM) after the backbone feature extraction network to replace the spatial pyramid pooling fast structure (Spatial Pyramid Pooling Fast, SPPF) in YOLOv8 for multi-scale feature extraction of Saccharomyces cerevisiae cell images;
[0059] Specifically, the EMSPPM is used to replace the SPPF structure, and the maximum pooling layer and the average pooling layer with different kernel sizes are used to process the input extracted features. The output features of each pooling layer are transmitted to the next pooling layer for further feature fusion, and finally the output features of all pooling layers are spliced. This design enables the model to effectively extract cell feature information, significantly reduces the loss of feature information, improves the ability of the model to process similar cells, and suppresses the detection interference caused by broken cells in the background.
[0060] Step 4: In the feature fusion network, design an efficient feature screening pyramid network (Efficient High-level Screening-feature Feature Pyramid Network, EHS-FPN) to replace the original neck structure to combine the low-level detail information and high-level semantic information of Saccharomyces cerevisiae cell images;
[0061] Specifically, the EHS-FPN extracts the features of the high, medium and low three layers of the backbone network respectively. Firstly, the initial feature map of each layer is rearranged in the channel dimension of the feature map by the spatial attention module SA (Spatial Attention) and the convolution module, the spatial position information between different layers is extracted, the high layer first feature map, the medium layer first feature map and the low layer first feature map are obtained, then the high layer first feature map is up-sampled to the same resolution as the medium layer feature map by the deconvolution operation, and the high layer feature is further up-sampled to the same resolution as the low layer feature map by the deconvolution operation, and after the deconvolution, the first channel attention map and the second channel attention map are obtained by the channel attention module CA (Channel Attention), then the first channel attention map is multiplied with the medium layer first feature map obtained after convolution in each channel to obtain the low layer second feature map, and the second channel attention map is multiplied with the low layer first feature map obtained after convolution in each channel to obtain the medium layer second feature map, the important channel information is highlighted, and the features obtained by the deconvolution of the high layer first feature map for the medium layer are added to the medium layer second feature map, and the features obtained by the deconvolution of the high layer first feature map for the low layer are added to the low layer second feature map. Since the deconvolution structure can update parameters during training, this enables the model to effectively combine the bottom layer detail information and the high layer semantic information, and improve the feature fusion capability of the model. While reducing the parameter amount of the model, the challenge brought by the dense distribution of cells can be alleviated.
[0062] Step 5: using PIoU as the regression loss function, training the EHS-YOLO model based on the training set prepared in step 1 and the early stopping operation; the PIoU regression loss function takes the side length of the target box as the denominator, and introduces a penalty function to dynamically adjust the gradient according to the quality of the anchor box;
[0063] Using PIoU as the regression loss function and taking the side length of the target box as the denominator can effectively avoid the problem of anchor box enlargement, so that the model can better adapt to cell targets of different sizes, the introduced penalty function can dynamically adjust the gradient according to the quality of the anchor box, focus on anchor boxes with moderate quality, and improve the training efficiency of the model; while accelerating the convergence speed of the model, the problem of anchor box enlargement is avoided, and the model pays more attention to individual cells.
[0064] The early stop button is set in the embodiment of the application, and the training is ended when the model mAP value does not improve in 100 rounds of training.
[0065] Step 6: input the Saccharomyces cerevisiae cell image in the verification set into the best model obtained by training to verify and save the best model;
[0066] Step 7: Use the optimal model to detect the Saccharomyces cerevisiae cell image to be detected, and obtain a visual detection result of the Saccharomyces cerevisiae cell image to be detected.
[0067] The embodiment of the present invention provides a lightweight brewer's yeast detection method based on an improved YOLOv8, and proposes a lightweight EHS-YOLO network model. This model enhances feature extraction and fusion capabilities by designing and improving multi-scale pyramid pooling layers and an efficient feature screening pyramid network, optimizing the network architecture, and improving the recognition accuracy of cells in each life cycle. When processing complex images, it can focus more on medium-quality anchor frames, thereby improving the recognition accuracy of brewer's yeast cells. With a smaller number of model parameters, it can achieve better recognition accuracy of brewer's yeast cells, realize lightweight brewer's yeast cell detection, greatly reduce the computational burden, facilitate real-time fermentation process detection, and can be deployed on mobile devices for efficient detection, helping to achieve real-time, automated production monitoring and enhance the intelligence level of the entire brewing industry.
[0068] Example 2:
[0069] This embodiment provides a lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8. Figure 1 The overall flow chart shown above first builds a YOLOv8 object detection network and improves it using the EMSPPM module, EHS-FPN module, and PIoU loss function. Then, a custom brewer's yeast cell dataset is created, and images from the training set are fed into the improved YOLOv8 network for training. The network parameters are then optimized using the validation set. Finally, the best model weights are saved and the images from the validation set are fed into the network for detection. This includes:
[0070] Step 1: Create a dataset, manually annotate the collected Saccharomyces cerevisiae cell image dataset, and divide it into a training set and a validation set. The specific contents of constructing the dataset are as follows:
[0071] 1-1: 1640 images of Saccharomyces cerevisiae cells were collected from the School of Bioengineering of a university. The size of each image is 1000×664, and they are divided into training set and validation set in a ratio of 8:2.
[0072] 1-2: Under the guidance of experts, the LabelImg annotation software was used to manually annotate the six major categories of Saccharomyces cerevisiae cells contained in the dataset, including single cells, one-end budding, two-end budding, multilateral budding, polar budding and bud chain. The labels were named NB, OB, TB, MB, PB, and BC respectively.
[0073] Step 2: Constructing an EHS-YOLO model with enhanced feature fusion characteristics, including a backbone feature extraction network Backbone, a feature fusion network Neck, and a detection head Head, wherein CSPDarkNet53 is selected as the backbone feature extraction network;
[0074] Specifically, the YOLOv8 model is selected as the baseline network and improved to form a target detection model with enhanced feature extraction and feature fusion characteristics, i.e., a lightweight target detection model EHS-YOLO model, as shown in Figure 2 , which includes:
[0075] Step 2-1: Backbone uses the improved CSPDarknet-53 for feature extraction, which combines shallow information with deep information by introducing C2f structure, avoiding gradient vanishing problem while enhancing feature extraction capability.
[0076] Step 2-2: The Neck part uses FPN structure, which has a top-down feature fusion path, and realizes feature information fusion between different size feature maps through its hierarchical structure and SA and CA.
[0077] Step 2-3: The Head part completes the regression and classification tasks through decoupled heads, which can directly predict the center point or boundary point of the target to simplify the model training process.
[0078] Step 3: Design an improved multi-scale pyramid pooling layer module EMSPPM after the backbone feature extraction network to replace the fast spatial pyramid pooling structure in YOLOv8;
[0079] Specifically, the structure of the improved multi-scale pyramid pooling layer module EMSPPM is as shown in Figure 3 , which uses EMSPPM to replace SPPF structure. First, use maximum pooling layers and average pooling layers with different kernel sizes in the SPPF module to replace the single kernel size maximum pooling layer to extract multi-scale features; then input the output results of each pooling layer to the next pooling layer for feature extraction, and stack the features along the channel with the input features of the corresponding next pooling layer, then adjust the channel number through 1x1 convolution, and finally concatenate the output features of all pooling layers to obtain the output feature map. This design enhances the model's feature extraction capability, effectively extracts cell feature information, significantly reduces feature information loss, improves the model's ability to process similar cells, and suppresses background broken cells that interfere with detection.
[0080] Specifically, step 3 includes:
[0081] Step 3-1: For input characteristics map, sequentially passing through a first maximum pooling layer F1 with a convolution kernel size of 11*11, a first average pooling layer processing with a convolution kernel size of 9*9, a second maximum pooling layer with a convolution kernel size of 7*7 and a second average pooling layer with a convolution kernel size of 5*5, the first maximum pooling layer outputs a first characteristic map, and the first characteristic map F 1 will enter the first average pooling layer for feature fusion, and the first average pooling layer outputs a second characteristic map F 12 2, and the second characteristic map F 12 2 will enter the second maximum pooling layer for feature fusion, and the second maximum pooling layer outputs a third characteristic map F 123 3, and the third characteristic map F 123 3 will enter the second average pooling layer for feature fusion, and the second average pooling layer outputs a fourth characteristic map F 1234 4; wherein W represents the width of the input characteristic map, H represents the height of the input characteristic map, and C in represents the number of channels of the input characteristic map;
[0082] Step 3-2: The above four characteristic maps are spliced and then pass through a 1*1 convolution to obtain a multi-scale fusion characteristic map, and the specific expression is shown in the following formula (1):
[0083]
[0084] wherein, represents the splicing operation of the tensor, and Conv represents the convolution, so wherein W represents the width of the multi-scale fusion characteristic map, H represents the height of the multi-scale fusion characteristic map, and C out represents the number of channels of the multi-scale fusion characteristic map.
[0085] Compared with the SPPF structure, the EMSPPM introduces more scale maximum and average pooling layers, and makes them interact with each other, reduces the loss of channel information and expands the global features, thereby improving the extraction ability of the model to feature details and expanding the receptive field. This design enables the model to effectively extract cell feature information, significantly reduces the loss of feature information, improves the ability of the model to process cells with similar shapes, and suppresses the detection interference caused by broken cells in the background.
[0086] Step 4: In the feature fusion network, an efficient feature screening pyramid network EHS-FPN is designed to replace the original splicing operation;
[0087] The embodiment of the present application replaces the neck structure with EHS-FPN, so that the model can effectively combine the bottom layer detail information and the high layer semantic information, and improve the feature fusion ability of the model.
[0088] Specifically, the EHS-FPN extracts the features of the high, medium and low three layers of the backbone network respectively. First, the SA structure is used to rearrange the elements in the channel dimension of the feature map, extract the spatial position information between different layers, and then upsample the high layer features to the same resolution as the medium layer feature map through the deconvolution operation. The result of the first deconvolution upsampling is further deconvolved and upsampled to the same resolution as the low layer feature map. After deconvolution, the channel attention map is multiplied with the medium and low layer input feature maps respectively through the CA structure, and the feature map is weighted to highlight important channel information. The deconvolved features are added to the weighted feature maps of the medium and low layers. Since the deconvolution can update the parameters, this enables the model to effectively combine the low-level detail information and high-level semantic information, and improve the feature fusion capability of the model.
[0089] As shown in Figure 4 , step 4 specifically includes:
[0090] Step 4-1: passing the high layer initial feature map F H , the medium layer initial feature map F M and the low layer initial feature map F L through the SA module to obtain the high layer intermediate feature map, the medium layer intermediate feature map and the low layer intermediate feature map, respectively. It should be understood that the high layer initial feature map F H here is the F out mentioned above;
[0091] Step 4-2: passing the high layer intermediate feature map, the medium layer intermediate feature map and the low layer intermediate feature map through a 1x1 convolution to obtain the corresponding high layer first feature map F' H , the medium layer first feature map F' M and the low layer first feature map F' L ;
[0092] Step 4-3: upsample the high layer first feature map F' H to the same dimension as the medium layer first feature map through the deconvolution operation to obtain the medium layer second feature map F MC , and upsample the medium layer second feature map F MC to the same dimension as the low layer first feature map through the deconvolution operation to obtain the low layer second feature map F LC ;
[0093] Step 4-4: passing the medium layer second feature map F MC and the low layer second feature map F LC through the CA module for channel feature weighting to obtain the medium layer third feature map F' MC and the low layer third feature map F' LC , and the SA and CA structures are shown in Figure 5 and Figure 6 , respectively;
[0094] Step 4-5: the middle layer third feature map F MC and the middle layer first feature map F M The multiplication calculation is performed on the corresponding pixel points to obtain the middle layer output feature map F The low layer third feature map F LC and the low layer first feature map F L The multiplication calculation is performed on the corresponding pixel points to obtain the low layer output feature map F The middle layer output feature map F and the low layer output feature map F The expressions of the middle layer output feature map F
[0095]
[0096] wherein, represents the dot product operation.
[0097] Step 4-6: the middle layer output feature map F and the middle layer second feature map F MC The element addition is performed on the corresponding pixel points to obtain the middle layer fusion feature map F OM The low layer output feature map F and the low layer second feature map F LC The element addition is performed on the corresponding pixel points to obtain the low layer fusion feature map F OL The expression of the middle layer fusion feature map F OM and the low layer fusion feature map F OL The expressions of the middle layer fusion feature map F
[0098]
[0099] wherein, + represents the element addition in the corresponding channel, so as to realize the full fusion of the high layer, the middle layer and the low layer features.
[0100] Step 4-7: finally, the high layer first feature map F H , the middle layer fusion feature map F OM and the low layer fusion feature map F OL are respectively input into the Detect layer to output the detection results after network optimization by the cross stage feature fusion module (C2f).
[0101] In YOLOv8, the structure of FPN+PANet in processing multi-scale features can extract detailed features through bottom-up and top-down structure, but the structure is relatively long in feature fusion. When deep image information and bottom image information pass through ordinary upsampling operation, part of the image feature information will be lost, and the information cannot be directly and effectively exchanged from the bottom to the highest layer. The high and low layer information cannot be effectively fused. In contrast, the EHS-FPN in the embodiment of the present application extracts the features of the middle, high and low three layers of the backbone network. First, the elements in the channel dimension of the initial feature map are rearranged through the SA structure and the 1x1 convolution to extract the spatial position information between different layers. Then, the obtained high layer first feature map is upsampled to the same resolution as the middle layer first feature map through the deconvolution operation. The result of the first deconvolution upsampling is further deconvolved and upsampled to the same resolution as the low layer first feature map. After deconvolution, the channel attention map is multiplied with the first feature map of the middle and low layers to highlight important channel information. The deconvolved features and the weighted output feature maps of the middle and low layers are added. Since the deconvolution can update the parameters, it enables the model to effectively combine the bottom layer detail information and the high layer semantic information, and improves the feature fusion capability of the model. Through the hierarchical design of EHS-FPN, the features of the high and low layers are screened, and different scale features can be more effectively fused. The SA and CA attention mechanisms can help the model obtain long-distance dependency information and channel feature information, so that the model pays more attention to the cell edge, thereby alleviating the challenge brought by the dense distribution of cells.
[0102] Step 5: using PIoU as the regression loss function, training the EHS-YOLO model based on the training set prepared in step 1 and the early stopping operation; the PIoU regression loss function takes the side length of the target box as the denominator and introduces a penalty function to dynamically adjust the gradient according to the quality of the anchor box;
[0103] In the embodiment of the present application, PIoU is used as the regression loss function, and the side length of the target box is taken as the denominator, which effectively avoids the problem of anchor box enlargement, so that the model can better adapt to cell targets of different sizes. A penalty function is introduced to dynamically adjust the gradient according to the quality of the anchor box, focus on anchor boxes with moderate quality, and improve the training efficiency of the model.
[0104] Specifically, the PIoU loss function calculation principle diagram is as shown in Figure 7 The specific implementation is as follows:
[0105] Step 5-1: the model combines a target size adaptive penalty factor and a gradient adjustment function based on the quality of the anchor box. In YOLOv8, the expression of the loss function L IoU based on the boundary box is as follows:
[0106] L IoU = 1 - IoU, 0 < L IoU ≤ 1 (6)
[0107] In the regression analysis, the four boundaries of the anchor box are regarded as a whole, in order to solve the problem of anchor box expansion and the limitation of existing IoU-based loss function, a target size adaptive penalty factor P is introduced, as shown in formula (7) and formula (8):
[0108]
[0109] Where, Δw1, Δw2, Δh1, Δh2 refer to the absolute value of the distance between the corresponding edges of the predicted box and the target, w gt and h gt respectively refer to the width and height of the target box, and e represents the natural base;
[0110] The target size adaptive penalty factor P can avoid the unlimited expansion of the anchor box in the regression process and improve the training efficiency.
[0111] Step 5-2: A non-monotonic attention function is proposed in combination with the penalty factor to construct PIoU2 controlled by a single hyperparameter, as shown in formula (9) to (11):
[0112] q = e -p , q ∈ (0, 1] (9)
[0113]
[0114] Where, r(λx) represents the attention function, which controls different attention behaviors by different λ values. Here, the penalty factor P is replaced by q, and when P = 1, it means q = 0, indicating that the anchor box and the target box are perfectly aligned, and when P gradually increases, q gradually decreases, representing lower quality anchor boxes. Introducing the attention function, when q = 0.5 around the value, the attention function is maximum, indicating that its Loss value is higher, so it pays more attention to the medium quality anchor box, thereby enhancing the medium quality anchor box in the regression process of each anchor box.
[0115] The existing IoU-based loss function will be affected by unreasonable penalty factors, and YOLOv8n uses CIoU loss function, which will cause the anchor box to expand in the regression process and significantly slow down the convergence speed. Therefore, the PIoU loss function is introduced, which combines the target size adaptive penalty factor and the gradient adjustment function based on the quality of the anchor box, as Figure 7As shown, PIoU will guide the anchor box to regress along the effective path, thus converging faster than the existing partial loss function and effectively improving model accuracy. In the regression analysis, the four boundaries of the anchor box are considered as a whole, which effectively solves the regression problem of the target box and the predicted box. In order to solve the problem of anchor box expansion and the limitations of the existing IoU-based loss function, a penalty factor P that adapts to the target size is introduced, which enhances the medium quality anchor box in each anchor box regression process, improves the model training accuracy, and makes the model pay more attention to the cell individuals, and improves the detection performance.
[0116] Step 5-3: The improved YOLOv8 network is trained in the embodiment of the application, and a early stop button is set. When the model mAP value does not improve in 100 rounds of training, the training is ended.
[0117] Step 6: The best model is saved after the best model is verified by inputting the Saccharomyces cerevisiae cell image in the verification set into the best model.
[0118] Step 7: The best model is used to detect the Saccharomyces cerevisiae cell image to be detected, and the visualization detection result of the Saccharomyces cerevisiae cell image to be detected is obtained.
[0119] In the embodiment of the application, all experiments are performed on the same computer, and the experimental environment configuration is shown in Table 1:
[0120] Table 1 Experimental environment configuration
[0121]
[0122]
[0123] When the picture is input into the model training, it will be compressed to 640x640. In the training process, the initial learning rate is set to 0.01, the learning rate decay coefficient is set to 0.0005, the SGD optimizer training parameter is used, the momentum value is set to 0.937, and the BatchSize is set to 32. A total of 400 Epochs are trained, the workers are set to 8 to speed up the training. Early stopping is set, and the model mAP value does not improve after 100 Epochs, and the training is automatically stopped, saving the training time.
[0124] In the present application, precision, recall, mean average precision (mAP), model parameters (Parmas) and frames per second (FPS) are used to evaluate the performance of the method. Among them, precision represents the proportion of the number of correctly predicted positive samples (TP) in the total number of positive samples predicted by the model (TP+FP), reflecting the false detection rate of Saccharomyces cerevisiae cells; Recall represents the proportion of the number of correctly predicted positive samples in the total number of labels (TP+FN), reflecting the missed detection rate of Saccharomyces cerevisiae cells; The average precision mAP reflects the performance of the method, which considers the accuracy Precision and recall Recall, takes recall as the abscissa and accuracy as the ordinate, integrates the PR curve to get the AP value, then accumulates the AP value of each class, and finally divides by the total number of classes k, to get mAP. The calculation methods of the above indexes are shown in formulas (12) to (15) respectively:
[0125]
[0126] In order to verify whether the EMSPPM, EHS-FPN modules and PIoU loss function in the EHS-YOLO network can effectively improve the detection accuracy of the model and enhance the recognition ability of Saccharomyces cerevisiae cells with small parameter amount, the present application embodiment carries out ablation experiment on different modules, and objectively compares and analyzes different modules according to evaluation indexes. The experiment arranges and combines three modules into six groups: EMSPPM, EHS-FPN, PIoU, EMSPPM+PIoU, EMSPPM+EHS-FPN+PIoU, the mAP@0.5, Recall and Precision results obtained by the ablation experiment are shown in Table 2, and the mark represents the used module.
[0127] Table 2 Ablation experiment results
[0128]
[0129]
[0130] As shown in Table 2, the EMSPPM structure reduces the interference of image compression and broken bubbles and background impurity information on model training through maximum pooling and average pooling layers of different core sizes. Compared with YOLOv8n, the precision, recall rate and mAP@0.5 are increased by 2.6%, 3.7% and 2.0% respectively. The EHS-FPN structure can fuse low-level detail information and high-level semantic information, and combine deconvolution, SA and CA attention mechanism, so that the model pays more attention to cell boundaries, thereby relieving the challenge of dense cell distribution. Compared with the YOLOv8n model, the precision, recall rate and mAP@0.5 values are increased by 4.2%, 6.4% and 3.1% respectively. Finally, the PIoU loss function is introduced. Due to the unbalanced sample in the data set, a penalty factor is designed to optimize the regression process of the anchor box. This strategy effectively avoids the unlimited expansion of the anchor box during regression, and at the same time promotes the model to focus more on the anchor box of medium quality, so that the model can pay more attention to the medium quality class samples, thereby achieving more balanced detection performance in the unbalanced data set. Compared with the YOLOv8n model, the precision, recall rate and mAP@0.5 values are increased by 0.8%, 3.5% and 1.2% respectively. For the designed EHS-YOLO model, compared with YOLOv8n, the precision, recall rate and mAP@0.5 values are increased by 4.8%, 6.6% and 3.3% respectively.
[0131] In order to further explore the detection performance of EHS-YOLO, the best model is saved after verification using the same wine yeast cell data set, and EHS-YOLO is compared with the current mainstream single-stage target detection algorithm such as YOLOv5, YOLOv6 and YOLOv10 in terms of detection accuracy, and the detection results are shown in Table 3. The bold font in the table indicates the optimal result of a single indicator. As shown in Table 3, EHS-YOLO achieves the best value in terms of average precision, recall rate, parameter quantity and precision, which indicates that the EMSPPM and EHS-FPN modules enhance the feature extraction and feature fusion capability of the network, and improve the recognition effect of the wine yeast cells. The parameter quantity of EHS-YOLO is reduced by 28.5% compared with YOLOv8n, and the floating point operation quantity is reduced by 12.4%. Compared with other models, the method provided by the embodiment of the present application also has great superiority. The parameter quantity of the wine yeast cells used by the EHS-YOLO provided by the embodiment of the present application is only 2.15MB, but at the same time, it has a high FPS value, realizes lightweight, and enables the model to be deployed on a limited hardware device.
[0132] Table 3 comparison of experimental results
[0133]
[0134]
[0135] Figure 8 For the visualization result of the image detection of the Saccharomyces cerevisiae cells, the method has stronger feature fusion and multi-scale feature extraction capability, compared with the YOLOv5n and YOLOv8n networks, the accuracy of the Saccharomyces cerevisiae cell detection result in complex background, image boundary, overlapping cells and other scenes can be improved under the condition of greatly reducing the parameter amount.
[0136] Part of the steps in the embodiments of the present application can be realized by software, and the corresponding software program can be stored in a readable storage medium, such as an optical disc or a hard disk.
[0137] The above description is only the preferred embodiment of the present application, and is not intended to limit the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8, characterized by, The method comprises the following steps: Step 1: preparing a data set, dividing the labeled Saccharomyces cerevisiae cell image data set into a training set and a validation set; Step 2: constructing an EHS-YOLO model based on YOLOv8 with enhanced feature fusion characteristics, including a backbone feature extraction network, a feature fusion network, and a detection head, wherein an improved CSPDarkNet53 is selected as the backbone feature extraction network; Step 3: designing an improved multi-scale pyramid pooling layer after the backbone feature extraction network to replace the fast spatial pyramid pooling structure in YOLOv8 for multi-scale feature extraction of Saccharomyces cerevisiae cell images; Step 4: in the feature fusion network, an efficient feature screening pyramid network is designed to replace the original neck structure to combine the low-level detail information and high-level semantic information of Saccharomyces cerevisiae cell images; Step 5: using PIoU as the regression loss function, training the EHS-YOLO model using the training set prepared in step 1 and based on early stopping operation; the PIoU regression loss function takes the side length of the target box as the denominator and introduces a penalty function to dynamically adjust the gradient according to the quality of the anchor box; Step 6: inputting the Saccharomyces cerevisiae cell images in the validation set into the best model obtained by training to verify and save the best model; Step 7: using the best model to detect the Saccharomyces cerevisiae cell images to be detected and obtaining the visual detection results of the Saccharomyces cerevisiae cell images to be detected; The step 3 comprises: Step 3-1: for the input feature map of , sequentially passing through a first max-pooling layer with a convolution kernel size of 11x11, a first average-pooling layer with a convolution kernel size of 9x9, a second max-pooling layer with a convolution kernel size of 7x7, and a second average-pooling layer with a convolution kernel size of 5x5, the first max-pooling layer outputs a first feature map , and the first feature map will enter the first average-pooling layer for feature fusion, the first average-pooling layer outputs a second feature map , and the second feature map will enter the second max-pooling layer for feature fusion, the second max-pooling layer outputs a third feature map , and the third feature map will enter the second average-pooling layer for feature fusion, the second average-pooling layer outputs a fourth feature map ; wherein, represents the width of the input feature map, represents the height of the input feature map, represents the channel number of the input feature map; Step 3-2: the first feature map , the second feature map , the third feature map and the fourth feature map are spliced to obtain a multi-scale fusion feature map through 1x1 convolution, and an expression of the multi-scale fusion feature map is: wherein, denotes a concatenation operation of tensors, Conv denotes a convolution, wherein, denotes a width of the multi-scale fusion feature map, denotes a height of the multi-scale fusion feature map, denotes a number of channels of the multi-scale fusion feature map; The step 4 comprises: Step 4-1: passing the high-level initial feature map, the middle-level initial feature map and the low-level initial feature map through SA modules respectively to obtain a high-level intermediate feature map, a middle-level intermediate feature map and a low-level intermediate feature map respectively Step 4-2: the high-level intermediate feature map, the middle-level intermediate feature map and the low-level intermediate feature map are respectively subjected to 1x1 convolution to obtain corresponding high-level first feature map , middle-level first feature map and low-level first feature map ; Step 4-3: up-sampling the high layer first feature map by a de-convolution operation to the same dimension as the middle layer first feature map, obtaining a middle layer second feature map , and the middle layer second feature map by a de-convolution operation to the same dimension as the low layer first feature map, obtaining a low layer second feature map ; Step 4-4: the middle layer second feature map and the low layer second feature map respectively pass through the CA module for channel feature weighting to obtain the middle layer third feature map and the low layer third feature map ; Step 4-5: multiply the middle layer third feature map with the middle layer first feature map to obtain the middle layer output feature map Step 4-6: multiply the low layer third feature map with the low layer first feature map to obtain the low layer output feature map Step 4-7: the expression of the middle layer output feature map and the low layer output feature map is respectively wherein, denotes a dot product operation; Step 4-6: the middle layer output feature map and the middle layer second feature map Element addition is performed on the corresponding pixel points to obtain a middle layer fusion feature map , the low layer output feature map and the low layer second feature map Element addition is performed on the corresponding pixel points to obtain a low layer fusion feature map , the middle layer fusion feature map and the low layer fusion feature map The expressions are as follows: wherein, represents the addition of elements on the corresponding channel, so as to realize the full integration of high, medium and low layer features; Step 4-7: the high layer first feature map , the middle layer fusion feature map , and the low layer fusion feature map respectively input into the Detect layer to output detection results after network optimization by the cross-stage feature fusion module.
2. The method of claim 1, wherein, The backbone feature extraction network uses an improved CSPDarknet-53 for feature extraction, and the improved multi-scale pyramid pooling layer module is introduced in the last layer of the backbone feature extraction network; The feature fusion network is based on a feature pyramid structure network and designs top-down high feature fusion layers, middle feature fusion layers, and low feature fusion layers, and introduces a spatial attention module and a channel attention module at each layer to realize feature information fusion between feature maps of different sizes; The detection head completes the regression and classification tasks through a decoupling head.
3. The method of claim 2, wherein, The expression of the PIoU regression loss function is: wherein, denotes a gradient adjustment function loss function, , , , denote the absolute value of the distance between the corresponding edges of the prediction box and the target, and denote the width and height of the target box, respectively, denotes a penalty factor for enhancing the medium quality anchor frame in each anchor box regression process.
4. The method of claim 3, wherein, In the PIoU regression loss function, attention is introduced, and a penalty factor is replaced by , obtaining a regression loss function, the expression of the regression loss function is: wherein, denotes an attention function, which is used to control different attention behaviors by different values.
5. A target detection method characterized by, The method detects the image to be detected in the cell detection field using the method of any one of claims 1-4.
6. A computer device, comprising: The computer device comprises a processor and a memory, the memory is used to store computer instructions, the computer instructions are loaded and executed by the processor to realize the lightweight Saccharomyces cerevisiae detection method based on the improved YOLOv8 of any one of claims 1 to 4.