Lightweight saccharomyces cerevisiae detection method based on improved YOLOv8
By improving the YOLOv8 model, combining the multi-scale pyramid pooling layer and efficient feature screening pyramid network, the problems of large parameters and heavy computing burden in Saccharomyces cerevisiae cell detection are solved, and high-precision and lightweight Saccharomyces cerevisiae cell detection are achieved, supporting real-time and mobile device deployment.
Patent Information
- Application Number
- CN202411951982.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2044-12-27
AI Technical Summary
The existing Saccharomyces cerevisiae cell detection methods have problems such as large amounts of parameters, heavy calculation burden, difficulty in real-time detection, and difficulty in deploying to mobile devices.
A lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8 is proposed. By designing an improved multi-scale pyramid pooling layer and efficient feature screening pyramid network, combined with PIoU regression loss function, the network architecture is optimized to improve detection accuracy and reduce parameter amount.
It realizes high-precision identification of Saccharomyces cerevisiae cells, reduces the computing burden, can be deployed on mobile devices, supports real-time fermentation process detection, helps to achieve real-time and automated production monitoring, and improves the intelligence level of the brewing industry.
Smart Images

Figure CN119919716A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a lightweight brewer's yeast detection method based on improved YOLOv8, and belongs to the technical field of image processing. Background Art
[0002] Saccharomyces cerevisiae cells are a kind of eukaryotic single-cell microorganism that has attracted widespread attention. They have shown great research value in the food industry, biology and medicine. In the industrial field, in order to reduce costs and increase production, yeast is often recycled, but as the number of cycles increases, yeast cells will gradually age. In this process, it is necessary to evaluate the vitality and comprehensive performance of the recycled yeast strains to ensure that their 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 faced many difficulties and challenges. Conventional detection methods include absorbance measurement, hemocytometer, plate colony counting, etc., but they are all offline means of evaluation and cannot provide accurate morphological data in real time. Although the plate colony counting method can count the number of cells, the dense cells will lead to inaccurate calculations and consume a lot of time. Although direct observation under a microscope is intuitive, manual operation is slow and long-term operation can easily cause damage to the body. Therefore, there is still a lot of room for improvement in yeast cell detection methods, and a method with low cost, high accuracy, simple operation and fast detection speed is needed. With the development of deep learning, some scholars have used target detection models for yeast cell recognition, but in practical applications, there are still great challenges. Due to the small differences between different types of budding methods, small budding cells, and background containing broken cells, there are still many missed detections and false detections, which require testers to spend a lot of time to review. Although the existing improved models can improve the detection accuracy to a certain extent, the improvements often lead to larger parameters of the model and increased computational burden, making it difficult to achieve real-time fermentation process detection and difficult to deploy on mobile devices. Summary of the invention
[0004] In order to solve the problem of large number of detection model parameters in practical applications, the present invention provides a lightweight brewer's yeast detection method based on improved YOLOv8, and the technical solution is as follows:
[0005] As one aspect of the present invention, a lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8 is provided, comprising:
[0006] Step 1: Prepare the dataset and divide the labeled Saccharomyces cerevisiae cell image dataset into a training set and a validation set;
[0007] Step 2: Build 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. Among them, the 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 YOLO v The fast spatial pyramid pooling structure in 8 is used to extract multi-scale features from Saccharomyces cerevisiae cell images;
[0009] 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 the Saccharomyces cerevisiae cell image;
[0010] Step 5: Use PIoU as the regression loss function, and use the training set prepared in step 1 to train the EHS-YOLO model based on the early stopping operation; the PIoU regression loss function uses 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 brewer's yeast cell images in the validation set into the best model obtained through training for validation and save the best model;
[0012] Step 7: Use the best model to detect the brewer's yeast cell image to be detected, and obtain a visual detection result of the brewer's yeast cell image to be detected.
[0013] Furthermore, 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 designed based on the feature pyramid network structure, with a top-down high feature fusion layer, a medium feature fusion layer, and a low feature fusion layer. A spatial attention module and a channel attention module are introduced in each layer to achieve feature information fusion between feature maps of different sizes.
[0015] The detection head completes the regression and classification tasks respectively through the decoupling head.
[0016] Further, step 3 includes:
[0017] Step 3-1: For input The feature map of is processed in sequence by the first maximum pooling layer with a convolution kernel size of 11×11, the first average pooling layer with a convolution kernel size of 9×9, the second maximum pooling layer with a convolution kernel size of 7×7, and the second average pooling layer with a convolution kernel size of 5×5. The first maximum pooling layer outputs the first feature map F1, and the first feature map F1 will enter the first average pooling layer for feature fusion. The first average pooling layer outputs the second feature map F 12 , and the second feature map F 12 It will enter the second maximum pooling layer for feature fusion, and the second maximum pooling layer outputs the third feature map F 123 , and the third feature map F 123 It will enter the second average pooling layer for feature fusion, and the second average pooling layer outputs the fourth feature map F 1234 ; Where W represents the width of the input feature map, H represents the height of the input feature map, and C in Indicates the number of channels of the input feature map;
[0018] Step 3-2: The first feature map F1 and the second feature map F 12 , the third feature map F 123 And the fourth characteristic graph F 1234 After splicing, a multi-scale fusion feature map is obtained through 1×1 convolution. The expression of the multi-scale fusion feature map is:
[0019]
[0020] in, Represents the concatenation operation of tensors, Conv represents convolution, Among them, 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 Indicates the number of channels of the multi-scale fusion feature map.
[0021] Further, step 4 includes:
[0022] Step 4-1: Convert the high-level initial feature map F H , the initial feature map F in the middle layer M and the low-level initial feature map F L The high-level intermediate feature map, the middle-level intermediate feature map and the low-level intermediate feature map are obtained through the SA module respectively;
[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 subjected to 1×1 convolution to obtain the corresponding high-level first feature map F′ H , the first feature map F′ in the middle layer M and the first feature map F′ of the lower layer L ;
[0024] Step 4-3: The high-level first feature map F′H The second feature map F in the middle layer is obtained by upsampling to the same dimension as the first feature map in the middle layer through the deconvolution operation. MC , and the second feature map F in the middle layer MC The second feature map F of the lower layer is obtained by upsampling it to the same dimension as the first feature map of the lower layer through the deconvolution operation. LC ;
[0025] Step 4-4: The second feature map F in the middle layer MC And the second feature map F LC The channel features are weighted by the CA module to obtain the third feature map F′ in the middle layer. MC and the third feature map F′ LC ;
[0026] Step 4-5: The third feature map F′ in the middle layer MC and the first feature map F′ in the middle layer M Multiply the corresponding pixels to obtain the middle-level output feature map The third feature map F′ of the lower layer LC and the first feature map F′ of the lower layer L Multiply the corresponding pixels to obtain the low-level output feature map Middle layer output feature map And the low-level output feature map The expressions are:
[0027]
[0028] in, Represents the dot product operation;
[0029] Step 4-6: Output feature map of the middle layer and the second feature map F in the middle layer MC Add the elements at the corresponding pixel points to obtain the middle-level fusion feature map F OM , the low-level output feature map And the second feature map F LC Add the elements at the corresponding pixels to obtain the low-level fusion feature map F OL , the middle-level fusion feature map F OM And the low-level fusion feature map F OL The expressions are:
[0030]
[0031] Among them, + means adding the elements on the corresponding channel, so as to achieve the full integration of high-level, middle-level and low-level features;
[0032] Step 4-7: The high-level first feature map F′ H, middle-level fusion feature map F OM And the low-level fusion feature map F OL After network optimization through the cross-stage feature fusion module, they are input into the Detect layer to output the detection results.
[0033] Furthermore, the expression of the PIoU regression loss function is:
[0034]
[0035] Among them, L IoU represents the gradient adjustment function loss function, Δw1, Δw2, Δh1, Δh2 represent the absolute value of the distance between the corresponding edge of the prediction box and the target, respectively, w gt and h gt denote the width and height of the target box respectively, and P denotes the penalty factor, which is used to enhance the medium-quality anchor box in the regression process of each anchor box.
[0036] Furthermore, attention is introduced into the PIoU regression loss function, and the penalty factor P is replaced by q to obtain the PIoU2 regression loss function. The expression of the PIoU2 regression loss function is:
[0037]
[0038] q=e -p ,q∈(0,1]
[0039]
[0040] Among them, r(λx) represents the attention function, which is used to control different attention behaviors through different λ values.
[0041] As another aspect of the present invention, a target detection method is provided. The method uses the above-mentioned lightweight brewer's yeast detection method based on improved YOLOv8 to detect an image to be detected, and the image to be detected is an image within the field of cell detection.
[0042] As another aspect of the present invention, a computer device is provided, the computer device comprising a processor and a memory, the memory is used to store computer instructions, the computer instructions are loaded and executed by the processor to implement the above-mentioned method based on the improved YOLO v 8. A lightweight method for detecting Saccharomyces cerevisiae.
[0043] The present invention provides a method based on improved YOLO v8 is a lightweight brewer’s yeast detection method. A lightweight EHS-YOLO network model is proposed. This model enhances the feature extraction and fusion capabilities by designing and improving the multi-scale pyramid pooling layer and the efficient feature screening pyramid network, optimizes the network architecture, and improves 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, and is conducive to real-time fermentation process detection. It can also be deployed on mobile devices for efficient detection, which helps to realize real-time and automated production monitoring and improve the intelligence level of the entire brewing industry. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 An improved YOLO based on the embodiment of the present invention is provided v 8. Overall flow chart of the lightweight Saccharomyces cerevisiae detection method;
[0046] Figure 2 The overall structure diagram of the EHS-YOLO model provided by the embodiment of the present invention;
[0047] Figure 3 A schematic diagram of an improved multi-scale pyramid pooling layer EMSPPM provided in an embodiment of the present invention;
[0048] Figure 4 A schematic diagram of an efficient feature screening pyramid network EHS-FPN provided in an embodiment of the present invention;
[0049] Figure 5 A structural diagram of a spatial attention module SA provided in an embodiment of the present invention;
[0050] Figure 6 Structural diagram of the channel attention module CA provided in an embodiment of the present invention
[0051] Figure 7 A calculation principle diagram of the PIoU loss function provided in an embodiment of the present invention;
[0052] Figure 8 A visualization diagram of the detection results provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0054] Embodiment 1:
[0055] This embodiment provides a lightweight Saccharomyces cerevisiae cell detection method based on YOLOv8 improvement. Figure 1 As shown, including:
[0056] Step 1: Prepare the dataset and divide the labeled Saccharomyces cerevisiae cell image dataset into a training set and a validation set;
[0057] Step 2: Build an EHS-YOLO (Enhanced High-level Screening-YOLO) model based on YOLOv8 with enhanced feature fusion characteristics, including the backbone feature extraction network Backbone, feature fusion network Neck and detection head Head, and select the improved CSPDarkNet53 as the backbone feature extraction network;
[0058] Step 3: After the backbone feature extraction network, an Enhanced Multi-scale Pooling Pyramid Module (EMSPPM) is designed to replace the Spatial Pyramid Pooling Fast (SPPF) in YOLOv8 to perform multi-scale feature extraction on Saccharomyces cerevisiae cell images;
[0059] Specifically, EMSPPM is used to replace the SPPF structure, and the maximum pooling layer and average pooling layer with different kernel sizes are used to process the input extracted features. The output features of each pooling layer are passed 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 model's ability to process cells with similar morphology, and suppresses detection interference caused by background broken cells.
[0060] Step 4: In the feature fusion network, an efficient high-level screening-feature pyramid network (EHS-FPN) is designed to replace the original neck structure to combine the low-level detail information and high-level semantic information of the Saccharomyces cerevisiae cell image;
[0061] Specifically, EHS-FPN extracts features from the three layers of the backbone network, namely, the high, medium and low layers. First, the initial feature map of each layer is rearranged through the spatial attention module SA (Spatial Attention) and the convolution module to rearrange the elements of the channel dimension of the feature map, extract the spatial position information between different layers, and obtain the high-level first feature map, the middle-level first feature map and the low-level first feature map. Then, the high-level first feature map is upsampled to the same resolution as the middle-level feature map through the deconvolution operation, and the result of the high-level feature upsampling through the deconvolution operation is further deconvolved and upsampled to the same resolution as the low-level feature map. After deconvolution, the channel attention module CA (Channel Attention Module) is used to resample the high-level first feature map to the same resolution as the low-level feature map. Attention) obtains the first channel attention map and the second channel attention map, and then multiplies the first channel attention map with the first feature map of the middle layer obtained after convolution of the middle layer channel by channel, and then weights it to obtain the second feature map of the low layer. The second channel attention map and the first feature map of the low layer obtained after convolution of the low layer are multiplied channel by channel, and then weighted to obtain the second feature map of the middle layer, highlighting the important channel information, and adding the features obtained by deconvolution of the high-level first feature map for the middle layer to the second feature map of the middle layer, and adding the features obtained by deconvolution of the high-level first feature map for the low layer to the second feature map of the low layer. Since the deconvolution structure can update parameters during training, this enables the model to effectively combine the underlying detail information with the high-level semantic information, and improve the model feature fusion capability. While reducing the number of model parameters, it can alleviate the challenges brought by dense cell distribution.
[0062] Step 5: Use PIoU as the regression loss function, and use the training set prepared in step 1 to train the EHS-YOLO model based on the early stopping operation; the PIoU regression loss function uses 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, allowing the model to 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, it avoids the problem of anchor box enlargement, prompting the model to pay more attention to individual cells.
[0064] The embodiment of the present invention provides an early stop button, and the training is terminated when the model mAP value does not improve in 100 rounds of training.
[0065] Step 6: Input the brewer's yeast cell images in the validation set into the best model obtained through training for validation and save the best model;
[0066] Step 7: Use the best model to detect the brewer's yeast cell image to be detected, and obtain a visual detection result of the brewer's yeast cell image to be detected.
[0067] The embodiment of the present invention provides a lightweight brewer's yeast detection method based on improved YOLOv8, and proposes a lightweight EHS-YOLO network model. The model enhances the feature extraction and fusion capabilities by designing and improving the multi-scale pyramid pooling layer and the efficient feature screening pyramid network, optimizes the network architecture, improves the recognition accuracy of cells in each life cycle, and can focus more on medium-quality anchor frames when processing complex images, thereby improving the recognition accuracy of brewer's yeast cells. With a smaller number of model parameters, a better recognition accuracy of brewer's yeast cells can be achieved, and lightweight brewer's yeast cell detection is realized, which greatly reduces the computational burden, is conducive to the realization of real-time fermentation process detection, and can be deployed on mobile devices for efficient detection, which helps to realize real-time and automated production monitoring and improve the intelligence level of the entire brewing industry.
[0068] Embodiment 2:
[0069] This embodiment provides a lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8. Figure 1 The overall flow chart shown in the figure first builds the YOLOv8 target detection network, and uses the EMSPPM module, EHS-FPN module and PIoU loss function to improve it; then makes a homemade brewer's yeast cell dataset, inputs the training set images into the improved YOLOv8 network training, and uses the validation set to optimize the network parameters; finally, saves the best model weights, and sends the validation set images into the network for detection. Including:
[0070] Step 1: Create a data set, manually annotate the collected brewer's yeast cell image data set, and divide it into a training set and a validation set. The specific contents of constructing the data set are as follows:
[0071] 1-1: 1640 brewer’s yeast cell images were collected from the School of Bioengineering of a certain university. The size of each image was 1000×664, and they were 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: Construct an EHS-YOLO model with enhanced feature fusion characteristics, including the backbone feature extraction network Backbone, the feature fusion network Neck and the detection head Head, among which 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, namely the lightweight target detection model EHS-YOLO model, such as Figure 2 As shown, including:
[0075] Step 2-1: Backbone uses the improved CSPDarknet-53 for feature extraction. By introducing the C2f structure, shallow information is combined with deep information to avoid the gradient vanishing problem while also enhancing the feature extraction capability.
[0076] Step 2-2: The Neck part uses the FPN structure and has a top-down feature fusion path. It realizes the fusion of feature information between feature maps of different sizes through its hierarchical structure as well as SA and CA.
[0077] Step 2-3: The Head part completes the regression and classification tasks separately by decoupling the head, 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 follows Figure 3 As shown in the figure, EMSPPM is used to replace the SPPF structure. First, the maximum pooling layer and average pooling layer with different kernel sizes are used in the SPPF module to replace the maximum pooling layer with a single kernel size to extract multi-scale features; then the output results of each pooling layer are input to the next pooling layer for feature extraction, and are superimposed along the channel with the input feature map of the corresponding next pooling layer, and then the number of channels is adjusted through 1×1 convolution, and finally the output features of all pooling layers are spliced to obtain the output feature map. This design enhances the model's feature extraction capability, enables the model to effectively extract cell feature information, significantly reduces the loss of feature information, improves the model's ability to process cells with similar morphology, and suppresses detection interference caused by background broken cells.
[0080] Specifically, step 3 includes:
[0081] Step 3-1: For input The feature map is processed by the first maximum pooling layer F1 with a convolution kernel size of 11×11, the first average pooling layer with a convolution kernel size of 9×9, the second maximum pooling layer with a convolution kernel size of 7×7, and the second average pooling layer with a convolution kernel size of 5×5. The first maximum pooling layer outputs the first feature map, and the first feature map F 1 will enter the first average pooling layer for feature fusion, and the first average pooling layer outputs the second feature map F 12 , and the second feature map F 12 It will enter the second maximum pooling layer for feature fusion, and the second maximum pooling layer outputs the third feature map F 123 , and the third feature map F 123 It will enter the second average pooling layer for feature fusion, and the second average pooling layer outputs the fourth feature map F 1234 ; Where W represents the width of the input feature map, H represents the height of the input feature map, and C in Indicates the number of channels of the input feature map;
[0082] Step 3-2: After concatenating the above four feature maps, a multi-scale fusion feature map is obtained through 1×1 convolution. The specific expression is shown in the following formula (1):
[0083]
[0084] in, represents the concatenation operation of tensors, Conv represents convolution, then Among them, 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 Indicates the number of channels of the multi-scale fusion feature map.
[0085] Compared with the SPPF structure, EMSPPM introduces more large-scale maximum and average pooling layers and allows them to interact with each other. By reducing channel information loss and amplifying global features, the model's ability to extract feature details and expand the receptive field. This design enables the model to effectively extract cell feature information, significantly reduces the loss of feature information, improves the model's ability to process cells with similar morphology, and suppresses detection interference caused by background fragmented cells.
[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 invention is designed to replace the neck structure with EHS-FPN, so that the model can effectively combine the underlying detail information with the high-level semantic information, thereby improving the model feature fusion capability.
[0088] Specifically, EHS-FPN extracts features from the high, medium and low layers of the backbone network respectively. First, the SA structure is used to rearrange the elements in the channel dimension of the feature map to extract the spatial position information between different layers. The high-level features are then upsampled to the same resolution as the middle-level feature map through deconvolution operations. The result of the first deconvolution upsampling is further deconvolved and upsampled to the same resolution as the low-level feature map. After deconvolution, the CA structure is used to multiply the channel attention map with the middle and low-level input feature maps channel by channel, weight the feature maps to highlight important channel information, and add the deconvolved features to the weighted feature maps of the middle and bottom layers. Since deconvolution can update parameters, the model can effectively combine the bottom-level detail information with the high-level semantic information, thereby improving the model's feature fusion capabilities.
[0089] like Figure 4 As shown, step 4 specifically includes:
[0090] Step 4-1: Convert the high-level initial feature map F H , the initial feature map F in the middle layer M and the low-level initial feature map F L The high-level intermediate feature map, the middle-level intermediate feature map and the low-level intermediate feature map are obtained through the SA module respectively. It should be understood that the high-level initial feature map F H That is, the above F out ;
[0091] 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 1×1 convolution to obtain the corresponding high-level first feature map F′ H , the first feature map F′ in the middle layer M and the first feature map F′ of the lower layer L ;
[0092] Step 4-3: The high-level first feature map F′ H The second feature map F in the middle layer is obtained by upsampling to the same dimension as the first feature map in the middle layer through the deconvolution operation. MC , and the second feature map F in the middle layer MC The second feature map F of the lower layer is obtained by upsampling it to the same dimension as the first feature map of the lower layer through the deconvolution operation. LC ;
[0093] Step 4-4: The second feature map F in the middle layer MC And the second feature map F LC The channel features are weighted by the CA module to obtain the third feature map F′ in the middle layer. MC and the third feature map F′ LC , SA and CA structures are as follows Figure 5 and Figure 6 As shown;
[0094] Step 4-5: The third feature map F′ in the middle layer MC and the first feature map F′ in the middle layer M Multiply the corresponding pixels to obtain the middle-level output feature map The third feature map F′ of the lower layer LC and the first feature map F′ of the lower layer L Multiply the corresponding pixels to obtain the low-level output feature map Middle layer output feature map And the low-level output feature map The expressions of are shown in the following formulas (2) and (3):
[0095]
[0096] in, Represents the dot product operation.
[0097] Step 4-6: Output feature map of the middle layer and the second feature map F in the middle layer MC Add the elements at the corresponding pixel points to obtain the middle-level fusion feature map F OM , the low-level output feature map And the second feature map F LC Add the elements at the corresponding pixels to obtain the low-level fusion feature map F OL , the middle-level fusion feature map F OM And the low-level fusion feature map F OL The expressions of are shown in the following formulas (4) and (5):
[0098]
[0099] Among them, + means adding the elements on the corresponding channel, so as to achieve the full integration of high-level, middle-level and low-level features.
[0100] Step 4-7: Finally, the high-level first feature map F′ H , middle-level fusion feature map F OM And the low-level fusion feature map F OL After network optimization through the Cross Stage Feature Fusion (C2f) module, they are input into the Detect layer to output the detection results.
[0101] In YOLOv8, although the FPN+PANet structure can extract detail features through bottom-up and top-down structures when processing multi-scale features, its structure is relatively lengthy when fusing features. When deep image information and underlying image information are subjected to ordinary upsampling operations, some image feature information will be lost, and information cannot be directly and effectively exchanged from the bottom layer to the highest layer, and high-level and low-level information cannot be effectively fused. In contrast, the EHS-FPN in the embodiment of the present invention extracts features from the three layers of the backbone network, firstly rearranges the elements on the channel dimension of the initial feature map through the SA structure and 1×1 convolution, extracts the spatial position information between different layers, then upsamples the obtained high-level first feature map to the same resolution as the middle-level first feature map through a deconvolution operation, and then further deconvolutes the result of the first deconvolution upsampling to the same resolution as the low-level first feature map, and after deconvolution, multiplies the channel attention map with the first feature maps of the middle and low layers channel by channel through the CA structure for weighting, highlights important channel information, and adds the deconvolved features to the weighted output feature maps of the middle and low layers. Since deconvolution can update parameters, this enables the model to effectively combine underlying detail information with high-level semantic information, thereby improving the model feature fusion capability. Through its hierarchical design, EHS-FPN can screen high-level and low-level features and more effectively fuse features of different scales. The SA and CA attention mechanisms can help the model obtain long-distance dependency information and inter-channel feature information, allowing the model to pay more attention to cell edges, thereby alleviating the challenges brought by dense cell distribution.
[0102] Step 5: Use PIoU as the regression loss function, and use the training set prepared in step 1 to train the EHS-YOLO model based on the early stopping operation; the PIoU regression loss function uses 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] The embodiment of the present invention uses PIoU as the regression loss function and the side length of the target box as the denominator, which effectively avoids the problem of increasing the anchor box 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 follows Figure 7 As shown, the specific implementation is:
[0105] Step 5-1: The model combines the target size adaptive penalty factor and the gradient adjustment function based on the quality of the anchor box. In YOLOv8, the loss function L based on the bounding box is IoU The expression of 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 limitations of the existing IoU-based loss function, a penalty factor P that adapts to the target size is introduced, as shown in formulas (7) and (8):
[0108]
[0109] Among them, Δw1, Δw2, Δh1, Δh2 refer to the absolute value of the distance between the predicted box and the corresponding edge of the target, w gt and h gt They refer to the width and height of the target box respectively, and e represents the natural base;
[0110] The penalty factor P adapted to the target size 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 formulas (9) to (11):
[0112] q=e -p ,q∈(0,1] (9)
[0113]
[0114] Among them, r(λx) represents the attention function, and different attention behaviors are controlled by different λ values. Here, the penalty factor P is further replaced by q. When P = 1, it means q = 0, indicating that the anchor box and the target box are perfectly aligned. When P gradually increases, q gradually decreases, indicating that the quality of the anchor box is lower. The attention function is introduced. When q is around 0.5, the attention function is the largest, 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 is affected by unreasonable penalty factors. YOLOv8n uses the CIoU loss function, which will cause the anchor box to expand during 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 anchor box quality, such as Figure 7As shown in the figure, PIoU guides the anchor box to regress along the effective path, thereby converging faster than some existing loss functions and effectively improving the model accuracy. In the regression analysis, the four boundaries of the anchor box are regarded as a whole, which effectively solves the regression problem of the target box and the prediction 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 adapted to the target size is introduced, which enhances the medium-quality anchor box in the regression process of each anchor box, improves the model training accuracy, and prompts the model to pay more attention to individual cells, thereby improving the detection performance.
[0116] Step 5-3: The embodiment of the present invention trains the improved YOLOv8 network, sets an early stop button, and terminates the training when the model mAP value does not improve in 100 rounds of training.
[0117] Step 6: Input the brewer's yeast cell images in the validation set into the best model trained for validation and save the best model;
[0118] Step 7: Use the best model to detect the brewer's yeast cell image to be detected, and obtain a visual detection result of the brewer's yeast cell image to be detected.
[0119] In the embodiment of the present 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 image is sent to the model for training, it will be compressed to a size of 640×640. During the training process, the initial learning rate is set to 0.01, the learning rate decay coefficient is 0.0005, the SGD optimizer training parameters are used, the momentum value is set to 0.937, and the BatchSize is set to 32. A total of 400 Epochs are trained, and the workers are set to 8 to speed up the training. Early stopping is also set. If the model mAP value does not increase after 100 Epochs, the training will automatically stop, saving training time.
[0124] The present invention uses accuracy (Precision), recall (Recall), mean Average Precision (mAP), model parameters (Parmas) and frames per second (Frames Per Second, FPS) to evaluate the performance of the method. Precision represents the proportion of the number of positive samples (TP) predicted correctly by the model to the total number of positive samples predicted by the model (TP+FP), reflecting the false detection rate of brewer's yeast cells; Recall represents the proportion of the number of positive samples predicted correctly to the total number of labels (TP+FN), reflecting the missed detection rate of brewer's yeast cells; mean average precision mAP reflects the performance of the proposed method, which comprehensively considers the accuracy Precision and recall Recall, with the recall as the horizontal axis and the accuracy as the vertical axis, integrates the formed PR curve to obtain the AP value, then adds up the AP values of each category, and finally divides by the total number of categories k to obtain mAP. The calculation methods of the above indicators 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 with a small number of parameters and enhance the recognition ability of Saccharomyces cerevisiae cells, the embodiment of the present invention conducts ablation experiments on different modules and objectively compares and analyzes different modules according to evaluation indicators. The experiment arranges and combines the three modules into 6 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 module used.
[0127] Table 2 Ablation experiment results
[0128]
[0129]
[0130] As shown in Table 2, the EMSPPM structure reduces the interference of image compression, broken bubbles and background impurity information on model training through the maximum pooling and average pooling layers with different kernel sizes. Compared with YOLOv8n, its precision, recall rate and mAP@0.5 are improved by 2.6%, 3.7% and 2.0% respectively. The EHS-FPN structure can make the model pay more attention to cell boundaries by fusing the underlying detail information with the high-level semantic information, and then combine the deconvolution and SA and CA attention mechanisms, thereby alleviating the challenges brought by the dense distribution of cells. Compared with the YOLOv8n model, its precision recall rate and mAP@0.5 values are improved by 4.2%, 6.4% and 3.1% respectively. Finally, the PIoU loss function introduced is designed with a penalty factor to optimize the regression process of the anchor box due to the imbalance of samples in the data set. This strategy effectively avoids the unlimited expansion of anchor boxes during regression, and at the same time encourages the model to focus more on medium-quality anchor boxes, so that the model can pay more attention to medium-quality category samples, thereby achieving a more balanced detection performance in an unbalanced data set. Compared with the YOLOv8n model, its precision, recall rate and mAP@0.5 value are increased by 0.8%, 3.5% and 1.2% respectively. For the designed EHS-YOLO model, compared with YOLOv8n, its precision, recall rate and mAP@0.5 value 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 was saved after verification using the same brewing cell dataset, and EHS-YOLO was compared with the current mainstream single-stage target detection algorithms such as YOLOv5, YOLOv6 and YOLOv10 in terms of detection accuracy, etc. The detection results are shown in Table 3, and the bold font in the table represents the optimal result of a single indicator. As can be seen from Table 3, EHS-YOLO has achieved the best values in terms of average precision and recall rate, parameter amount and accuracy, which shows that the EMSPPM and EHS-FPN modules enhance the feature extraction and feature fusion capabilities of the network and improve the effect of brewing yeast cell recognition. The number of parameters of EHS-YOLO is reduced by 28.5% compared with YOLOv8n, and the floating point operation amount is reduced by 12.4%. Compared with several other models, the method provided in the embodiment of the present invention also has great advantages. The parameter amount of brewing yeast cells used by EHS-YOLO provided in the embodiment of the present invention is only 2.15MB, but at the same time it has a higher FPS value, which achieves lightweight, so that the model can be deployed on limited hardware devices.
[0132] Table 3 Comparative experimental results
[0133]
[0134]
[0135] Figure 8 The visualization result of brewer's yeast cell image detection is shown in Figure 2. The method proposed in the present invention has stronger feature fusion and multi-scale feature extraction capabilities. Compared with the YOLOv5n and YOLOv8n networks, it can improve the accuracy of brewer's yeast cell detection results in scenes such as complex backgrounds, image boundaries, and overlapping cells while greatly reducing the number of parameters.
[0136] Some steps in the embodiments of the present invention may be implemented using software, and the corresponding software program may be stored in a readable storage medium, such as a CD or a hard disk.
[0137] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A lightweight Saccharomyces cerevisiae detection method based on improved YOLOv8, characterized in that: include: Step 1: Prepare the dataset and divide the labeled Saccharomyces cerevisiae cell image dataset into a training set and a validation set; Step 2: Build 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. Among them, the improved CSPDarkNet53 is selected as the backbone feature extraction network; 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 YOLOv8 to perform multi-scale feature extraction on 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 the Saccharomyces cerevisiae cell image; Step 5: Use PIoU as the regression loss function, and use the training set prepared in step 1 to train the EHS-YOLO model based on the early stopping operation; the PIoU regression loss function uses 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: Input the brewer's yeast cell images in the validation set into the best model obtained through training for validation and save the best model; Step 7: Use the best model to detect the brewer's yeast cell image to be detected, and obtain a visual detection result of the brewer's yeast cell image to be detected.
2. The method according to claim 1, characterized in that The backbone feature extraction network uses an improved CSPDarknet-53 for feature extraction, and introduces the improved multi-scale pyramid pooling layer module into the last layer of the backbone feature extraction network; The feature fusion network is designed based on a feature pyramid structure network to design a top-down high feature fusion layer, a medium feature fusion layer and a low feature fusion layer, and introduces a spatial attention module and a channel attention module in each layer to realize feature information fusion between feature maps of different sizes; The detection head completes the regression and classification tasks respectively through the decoupling head.
3. The method according to claim 2, characterized in that The step 3 comprises: Step 3-1: For input The feature map of is processed in sequence by the first maximum pooling layer with a convolution kernel size of 11×11, the first average pooling layer with a convolution kernel size of 9×9, the second maximum pooling layer with a convolution kernel size of 7×7, and the second average pooling layer with a convolution kernel size of 5×5. The first maximum pooling layer outputs the first feature map F1, and the first feature map F1 will enter the first average pooling layer for feature fusion. The first average pooling layer outputs the second feature map F 12 , and the second feature map F 12 It will enter the second maximum pooling layer for feature fusion, and the second maximum pooling layer outputs the third feature map F 123 , and the third feature map F 123 It will enter the second average pooling layer for feature fusion, and the second average pooling layer outputs the fourth feature map F 1234 ; Where W represents the width of the input feature map, H represents the height of the input feature map, and C in Indicates the number of channels of the input feature map; Step 3-2: The first feature map F1 and the second feature map F 12 , the third feature map F 123 And the fourth characteristic graph F 1234 After splicing, a multi-scale fusion feature map is obtained through 1×1 convolution. The expression of the multi-scale fusion feature map is: in, Represents the concatenation operation of tensors, Conv represents convolution, Among them, 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 Indicates the number of channels of the multi-scale fusion feature map.
4. The method according to claim 3, characterized in that The step 4 comprises: Step 4-1: Convert the high-level initial feature map F H , the initial feature map F in the middle layer M and the low-level initial feature map F L The high-level intermediate feature map, the middle-level intermediate feature map and the low-level intermediate feature map are obtained through the SA module 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 1×1 convolution to obtain the corresponding high-level first feature map F′ H , the first feature map F′ in the middle layer M and the first feature map F′ of the lower layer L ; Step 4-3: The high-level first feature map F′ H The second feature map F in the middle layer is obtained by upsampling to the same dimension as the first feature map in the middle layer through the deconvolution operation. MC , and the second feature map F in the middle layer MC The second feature map F of the lower layer is obtained by upsampling it to the same dimension as the first feature map of the lower layer through the deconvolution operation. LC ; Step 4-4: The second feature map F in the middle layer MC And the second feature map F LC The channel features are weighted by the CA module to obtain the third feature map F′ in the middle layer. MC and the third feature map F′ LC ; Step 4-5: The third feature map F′ in the middle layer MC and the first feature map F′ in the middle layer M Multiply the corresponding pixels to obtain the middle-level output feature map The third feature map F′ of the lower layer LC and the first feature map F′ of the lower layer L Multiply the corresponding pixels to obtain the low-level output feature map Middle layer output feature map And the low-level output feature map The expressions are: in, Represents the dot product operation; Step 4-6: Output feature map of the middle layer and the second feature map F in the middle layer MC Add the elements at the corresponding pixel points to obtain the middle-level fusion feature map F OM , the low-level output feature map And the second feature map F LC Add the elements at the corresponding pixels to obtain the low-level fusion feature map F OL , the middle-level fusion feature map F OM And the low-level fusion feature map F OL The expressions are: Among them, + means adding the elements on the corresponding channel, so as to achieve the full integration of high-level, middle-level and low-level features; Step 4-7: The high-level first feature map F′ H , middle-level fusion feature map F OM And the low-level fusion feature map F OL After network optimization through the cross-stage feature fusion module, they are input into the Detect layer to output the detection results.
5. The method according to claim 4, characterized in that The expression of the PIoU regression loss function is: Among them, L IoU represents the gradient adjustment function loss function, Δw1, Δw2, Δh1, Δh2 represent the absolute value of the distance between the corresponding edge of the prediction box and the target, respectively, w gt and h gt denote the width and height of the target box respectively, and P denotes the penalty factor, which is used to enhance the medium-quality anchor box in the regression process of each anchor box.
6. The method according to claim 5, characterized in that Attention is introduced into the PIoU regression loss function, and the penalty factor P is replaced by q to obtain the PIoU2 regression loss function. The expression of the PIoU2 regression loss function is: q=e -p ,q∈(0,1] Among them, r(λx) represents the attention function, which is used to control different attention behaviors through different λ values.
7. A target detection method, characterized in that: The method adopts the method described in any one of claims 1 to 6 to detect the image to be detected, and the image to be detected is an image within the field of cell detection.
8. A computer device, characterized in that: The computer device includes a processor and a memory, the memory is used to store computer instructions, and the computer instructions are loaded and executed by the processor to implement a lightweight brewer's yeast detection method based on improved YOLOv8 as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Pest detection method and system based on YOLOv5
CN117649610A
Sputum specimen bacterium detection method based on YOLOV8
CN119007200A
Model training method and intelligent construction site safety equipment detection method
CN119131349A