Improved YOLO v8-based mushroom stick cultivation mushroom grading method and system

By replacing the C2f module with the C2f_Faster_CGLU module in the YOLO v8 model and building a small-objective feature pyramid structure SOEP, combined with shared convolutional blocks, the problems of low efficiency and insufficient accuracy of traditional mushroom detection methods are solved, and efficient and accurate mushroom grading detection is achieved. .

CN119206711APending Publication Date: 2024-12-27SHANDONG ACADEMY OF AGRICULTURAL SCIENCES +1
View PDF 0 Cites 8 Cited by

Patent Information

Application Number
CN202411300987.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The traditional shiitake image detection method relies on manual feature extraction, is inefficient and sensitive to noise and light changes. YOLO v8 has low detection accuracy in shiitake mushroom grading, especially insufficient detection performance for small targets and large model parameters affect efficiency.

Method used

By replacing the C2f module in the backbone network of the YOLO v8 model as the C2f_Faster_CGLU module, a small-target feature pyramid structure SOEP is built, and a shared convolution block is introduced into the detection head, optimizing the model structure to improve detection accuracy and efficiency and reduce the amount of parameters.

Benefits of technology

The feature extraction ability and detection accuracy in the mushroom grading process are significantly improved, the detection ability of small targets is enhanced, the amount of model parameters is reduced, and efficient operation is achieved in resource-constrained environments, reducing the impact on light changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119206711A_ABST
    Figure CN119206711A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of image processing, and particularly relates to a mushroom stick cultivation mushroom grading method based on improved YOLO v8. The method comprises the following steps: inputting an obtained shiitake mushroom image into a trained improved YOLO v8 model to obtain the category and maturity of each detection target in the shiitake mushroom image; the method comprises the following steps: replacing a C2f module in a backbone network of an original YOLO v8 model with a C2fFaster CGLU module, constructing a small target feature pyramid structure SOEP in a neck network, and introducing a shared convolution block into a detection head to obtain an improved YOLO v8 model; according to the method, the small target feature pyramid structure SOEP is constructed, and the detection capability of the model on small-size shiitake mushrooms during grading is enhanced by introducing the SPDConv and CSPOmniKernel modules, so that the overall detection precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image processing, and in particular relates to a mushroom grading method for mushrooms cultivated on mushroom sticks based on improved YOLO v8. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.

[0003] With the significant growth in global demand for shiitake mushrooms in recent years, quality inspection and grading of shiitake mushrooms have become crucial to the development of the industry. Flower shiitake mushrooms are widely favored due to their high economic value, while ordinary shiitake mushrooms have a relatively low market value. In order to ensure the accuracy of shiitake mushroom quality and price grading and improve picking efficiency, it is particularly necessary to grade shiitake mushrooms grown on mushroom sticks, which not only helps to improve economic benefits, but also optimizes the production process.

[0004] Picking fresh shiitake mushrooms is a key link in production. Currently, it still relies mainly on manual operation, which is inefficient and costly. The introduction of picking robots can significantly improve production efficiency and reduce costs. However, the premise of realizing automated picking by robots is to be able to quickly and accurately detect fresh shiitake mushrooms. Although traditional computer vision technology has made some progress in non-destructive testing and quality grading of shiitake mushrooms, feature extraction and defect detection still rely on manual design, with obvious limitations and insufficient automation.

[0005] In addition, traditional methods are easily affected by noise and illumination changes during image detection, resulting in low accuracy and poor robustness, which restricts the automation process of shiitake mushroom production.

[0006] As an advanced target detection algorithm, YOLO v8 has achieved advanced results on many natural scene datasets; however, due to the small differences in the cap patterns of different grades of shiitake mushrooms, the standard C2f module in the backbone network has not been fully utilized in feature extraction. In addition, considering that shiitake mushroom images usually contain small targets such as immature shiitake mushrooms, the traditional YOLO v8 algorithm is not specifically optimized for small target detection tasks, resulting in low overall detection accuracy. In addition, the traditional YOLOv8 model has a high number of parameters, which affects the efficiency and real-time performance of the model. Summary of the invention

[0007] In order to overcome the above-mentioned deficiencies of the prior art, the present invention provides a method and system for grading shiitake mushrooms cultivated with mushroom sticks based on improved YOLO v8.

[0008] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:

[0009] The first aspect of the present invention provides a method for grading mushrooms grown on mushroom sticks based on improved YOLO v8, comprising:

[0010] Acquire an image of mushrooms grown on mushroom sticks to be detected;

[0011] The acquired mushroom images are input into the trained improved YOLO v8 model to obtain the category and maturity of each detection target in the mushroom images;

[0012] The improved YOLO v8 model is obtained by replacing the C2f module in the original YOLO v8 model backbone network with the C2f_Faster_CGLU module, building a small target feature pyramid structure SOEP in the neck network to enhance the model's detection ability for small targets, and introducing a shared convolutional block in the detection head;

[0013] The small target feature pyramid structure SOEP includes an SPDConv module and a CSP-OmniKernel module; the SPDConv module is respectively connected to the second-layer C2f_Faster_CGLU module in the backbone network and the fifteenth Concat layer in the neck network; the CSPO-mniKernel module is arranged between the fifteenth Concat layer and the seventeenth C2f module in the neck network.

[0014] The second aspect of the present invention provides a mushroom grading system for cultivating mushrooms on mushroom sticks based on improved YOLO v8, comprising:

[0015] The data acquisition module is configured to: acquire an image of mushrooms grown on mushroom sticks to be detected;

[0016] The mushroom grading module is configured to: input the acquired mushroom image into the trained improved YOLO v8 model to obtain the category and maturity of each detection target in the mushroom image;

[0017] The improved YOLO v8 model is obtained by replacing the C2f module in the original YOLO v8 model backbone network with the C2f_Faster_CGLU module, building a small target feature pyramid structure SOEP in the neck network to enhance the model's detection ability for small targets, and introducing a shared convolutional block in the detection head;

[0018] The small target feature pyramid structure SOEP includes an SPDConv module and a CSP-OmniKernel module; the SPDConv module is respectively connected to the second-layer C2f_Faster_CGLU module in the backbone network and the fifteenth Concat layer in the neck network; the CSPO-mniKernel module is arranged between the fifteenth Concat layer and the seventeenth C2f module in the neck network.

[0019] The third aspect of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as described in the first aspect of the present invention.

[0020] The fourth aspect of the present invention provides an electronic device, comprising a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the method for grading shiitake mushrooms grown on mushroom sticks based on improved YOLO v8 as described in the first aspect of the present invention are implemented.

[0021] One or more of the above technical solutions have the following beneficial effects:

[0022] (1) Aiming at the limitations of traditional YOLOv8 in processing complex mushroom images, the present invention redesigned the backbone module; by combining the partial convolution PConv and CGLU in FasterNet, the structure of the C2f module in the backbone of the network was optimized, which significantly improved the feature extraction capability and detection accuracy in the mushroom grading process.

[0023] (2) Considering the difficulty in detecting small targets such as immature mushrooms, the present invention constructs a small target feature pyramid structure (SOEP). By introducing the SPDConv and CSPOMniKernel modules, the model's detection capability for small-sized mushrooms during grading is enhanced, thereby improving the overall detection accuracy.

[0024] (3) In order to reduce the number of model parameters and computational load while maintaining high detection accuracy, the present invention develops a lightweight shared convolutional detection head LSCD; by applying GroupNorm to standardize the feature map after the convolution layer, and combining shared convolution and Scale layers to adjust the feature scale, the model can significantly reduce the number of parameters while still being able to run efficiently in a resource-constrained environment.

[0025] (4) During the model training process, the training set is subjected to image enhancement processing, including adjusting brightness, chromaticity, contrast, and sharpness. The increase and decrease of brightness can simulate scenes under different lighting conditions, making the detection process less susceptible to the influence of lighting. This solves the problem that traditional methods are easily affected by lighting changes during image detection.

[0026] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0028] Figure 1 This is a training flowchart of the improved YOLO v8 model of the first embodiment.

[0029] Figure 2 This is the visualization interface of the improved YOLO v8 model of the first embodiment.

[0030] FIG. 3( a ) and FIG. 3( b ) are schematic diagrams of grading of mushrooms cultivated with two types of mushroom sticks according to the first embodiment.

[0031] Figure 4 This is a comparison chart of the test results of the improved YOLO v8 model of the first embodiment and the existing model.

[0032] Figure 5 This is a diagram of the improved YOLO v8 model structure of the first embodiment.

[0033] Figure 6 It is a schematic diagram of the C2f_Faster_CGLU module of the first embodiment.

[0034] Figure 7 It is a schematic diagram of the improved CGLU structure of the first embodiment.

[0035] Figure 8 FIG. 4 is a schematic diagram of an SPDConv module of the first embodiment.

[0036] Fig. 9 Schematic diagram of the CSP-OmniKernel module of the first embodiment.

[0037] Fig.10 This is a schematic diagram of the OmniKernel branches of the first embodiment.

[0038] Fig.11 Schematic diagram of the lightweight shared convolutional detection head LSCD of the first embodiment. DETAILED DESCRIPTION

[0039] Embodiment 1

[0040] like Figure 1 As shown, this embodiment discloses a mushroom grading method for mushroom cultivation based on improved YOLO v8, including:

[0041] Step 1: Preprocess and annotate the acquired mushroom stick cultivation image dataset, and use image enhancement technology to expand the annotated dataset;

[0042] Step 2: Use the expanded dataset to train the improved YOLO v8 model. During the training process, the content loss and frequency domain loss between the predicted image and the real image output by the model are calculated as the overall loss function of the model.

[0043] Step 3: Input the mushroom stick cultivation image to be detected in the real scene into the trained improved YOLO v8 model to obtain the category and size of each detection target in the mushroom image.

[0044] In step 1, it includes obtaining data and constructing training sets, test sets, and validation sets;

[0045] Collect data and take pictures of mushroom sticks under different lighting conditions with a fixed camera. Label the pictures of mushroom sticks according to the grading standards of shiitake mushrooms, and then enhance the image data to meet the model training requirements. Specifically include:

[0046] Step 101: Build a data collection platform in the mushroom stick cultivation area, and use a fixed camera to take pictures of mushroom sticks with different grades of shiitake mushrooms.

[0047] Among them, a 4x4cm black and white calibration plate was used as a reference for the size of shiitake mushrooms, and a total of 130 mushroom stick images were collected, covering samples at different growth stages and grading standards.

[0048] Step 102: Use LabelImg data labeling software to label the collected mushroom stick images.

[0049] Referring to Table 1, the category of shiitake mushrooms and the corresponding bounding box position in each image are marked according to the shiitake mushroom classification standard table.

[0050] Table 1 Shiitake mushroom grading standards

[0051]

[0052]

[0053] Step 103: To prevent the model from overfitting, the labeled image data is enhanced to expand the data set.

[0054] Enhancement processing specifically includes: adjusting brightness, chroma, contrast and sharpness.

[0055] In two different scenarios, the brightness, contrast and sharpness of the images were increased by 1.1 times and reduced by 10% respectively. At the same time, Gaussian noise and salt and pepper noise with a variance of 0.05 were added, and finally the number of data set samples was expanded to 1040.

[0056] Step 104: Batch process the expanded image data and label data to ensure that each image has corresponding label data; so that the expanded 1040 images and their labels can be used for model training to ensure the smooth progress of the training process.

[0057] Step 105: Divide the processed image data and label data into a validation set, a test set, and a training set according to the ratios of 10%, 20%, and 70%, respectively.

[0058] Step 106: The image size is uniformly adjusted to 480x480 pixels to ensure data consistency.

[0059] In step 2, include:

[0060] Step 201: Develop a visual operation interface

[0061] Step 2011: Implement the visualization interface of the YOLOv8-MR model based on the PyQt framework, as shown in Figure 2 As shown, the operator can select the weight file of the pre-trained model in this interface and load the mushroom pictures, videos or real-time camera data to be detected for detection.

[0062] Step 2012: The detection process is performed by the backend code module, which uses PyTorch to load the model weights and OpenCV to process the image and video data. The detection results are displayed in real time on the interface, and the detection time and target classification statistics are recorded.

[0063] Step 2013: The interface also integrates the result saving and operation control functions. The operator can specify the saving path of the test results through the interface, and terminate the test task or exit the program through the operation button.

[0064] Step 202: Model testing

[0065] Step 221: After training the YOLOv8 and improved YOLOv8-MR models using the dataset, the models are evaluated using precision (Precision, P), recall (Recall, R), mean average precision (mAP), model parameters (Parameters, Params) and Giga Floating-point Operations Per Second (GFLOPs). The evaluation results are shown in Table 2.

[0066] Table 2 Performance comparison between YOLOv8n and YOLOv8-MR

[0067]

[0068] Among them, precision (P) refers to the proportion of all instances predicted by the model to be positive that are actually positive.

[0069] The specific calculation formula is as follows:

[0070]

[0071] Recall (R) refers to the proportion of all instances that are actually positive that are correctly identified as positive by the model.

[0072] The specific calculation formula is as follows:

[0073]

[0074] mAP50 refers to the average precision (AP) when IoU is 0.5.

[0075] The specific calculation formula is as follows:

[0076] AP:

[0077]

[0078] mAP50 (average of AP for all categories):

[0079]

[0080] mAP50-95 refers to the mean of the average precision (AP) calculated at different IoU thresholds (from 0.50 to 0.95, with an increase of 0.05 each time).

[0081] Step 2022: Use the trained model weights to detect the mushroom stick image. The detection results are shown in Figures 3(a) and 3(b).

[0082] Step 2023: Train the YOLOv5 and YOLOv7 models on the same dataset and record the changes in their mAP50 values ​​during the training process. Then, compare these data with the mAP50 changes of the YOLOv8 and its improved version YOLOv8-MR models under the same training conditions, and summarize all the results. Finally, draw the mAP50 change curves of each model, as shown in Figure 4 As shown; it can be seen that the improved version of the YOLOv8-MR model provided by the present invention has higher accuracy.

[0083] Step 203: In order to optimize the image restoration process, content loss and frequency domain loss are used as the overall loss function of the model to guide model training. It should be noted that the overall loss function is the loss function of the OKM (full core module), which is only used in the OKM module and will not affect the training process of the entire YOLO v8 network.

[0084] (1) Content loss measures the difference between the predicted image and the real image through L1 loss (mean absolute error):

[0085]

[0086] in, and Y represent the predicted image and the real image respectively. The L1 loss is measured by calculating the absolute difference of each pixel in the two images and then summing and averaging these differences.

[0087] (2) In order to optimize the learning of frequency signals, frequency domain loss is introduced:

[0088]

[0089] Where F represents the fast Fourier transform (FFT), and Y represent the frequency domain representations of the predicted image and the true image, respectively.

[0090] (3) Combining content loss and frequency domain loss, the final overall loss function is:

[0091]

[0092] Among them, E represents the number of elements in the output, and λ is a balancing coefficient used to adjust the weight ratio between content loss and frequency domain loss.

[0093] In step 3, the original YOLO v8 model is improved, including: by replacing the C2f module in the backbone network of the original YOLO v8 model with the C2f_Faster_CGLU module, building a small target feature pyramid structure SOEP in the neck network to enhance the model's detection ability for small targets; and introducing a shared convolution block in the detection head to adapt to the detection requirements of different targets, thereby obtaining an improved YOLO v8 model.

[0094] like Figure 5As shown, the backbone network in the improved YOLO v8 model includes: sequentially connected input layer input, 0th ConvModule layer, first ConvModule layer, second C2f_Faster_CGLU module, third ConvModule layer, fourth C2f_Faster_CGLU module, fifth ConvModule layer, sixth C2f_Faster_CGLU module, seventh ConvModule layer, eighth C2f_Faster_CGLU module and ninth SPPF layer;

[0095] The neck network in the improved YOLO v8 model includes: the 14th SPDCnov layer and the 10th Upsample layer, the 11th Concat layer, the 12th C2f layer, the 13th Upsample layer, the 15th Concat layer, the 16th CSP-OmniKernel module, the 17th C2f layer, the 18th ConvModule layer, the 19th Concat layer, the 20th C2f layer, the 21st ConvModule layer, the 22nd Concat layer and the 23rd C2f layer connected in sequence;

[0096] The second C2f_Faster_CGLU module in the backbone network is connected to the fifteenth Concat layer in the neck network through the fourteenth SPDCnov layer; the fourth and sixth C2f_Faster_CGLU modules in the backbone network are respectively connected to the fifteenth Concat layer and the eleventh Concat layer in the neck network; the ninth SPPF layer in the backbone network is respectively connected to the tenth Upsample layer and the twenty-second Concat layer in the neck network; the twelfth C2f layer in the neck network is connected to the nineteenth Concat layer; the seventeenth C2f layer in the neck network is connected to the first detection head LSCD, the twentieth C2f layer is connected to the second detection head LSCD, and the twenty-third C2f layer is connected to the third detection head LSCD.

[0097] like Figure 6 As shown, the C2f_Faster_CGLU module includes a C2f module connected in sequence, a partial convolutional layer PConv, an improved CGLU structure, and a DropPath layer;

[0098] The partial convolution layer PConv is used to extract preliminary features; the improved CGLU structure is used to filter the preliminary features through the gating mechanism and integrate the filtered features through the 1x1 convolution layer; the integrated features are output after passing through the DropPath layer.

[0099] Step 301: Redesign the backbone network

[0100] Step 3011: Use the partial convolution PConv in FasterNet as the basic feature extraction component.

[0101] Step 3012: Integrate the CGLU (Convolutional GLU) structure and make innovative improvements to its structure, that is, use a 1x1 convolutional layer to replace the Linear layer in the original CGLU structure; the improved CGLU structure is as follows Figure 7 shown.

[0102] Step 3013: Combine PConv with the improved CGLU and add the DropPath mechanism to form the C2f_Faster_CGLU module.

[0103] Step 302: Adding a small target feature pyramid structure SOEP to the neck network

[0104] Since it is necessary to distinguish the maturity of shiitake mushrooms according to the size of their caps during the detection process, the detection accuracy of immature shiitake mushrooms is at a lower level compared to mature shiitake mushrooms, and the size of immature shiitake mushrooms is smaller. Therefore, in order to solve the problem of insufficient detection performance of small targets in the YOLO v8 model, the present invention proposes a Small Object Enhance Pyramid (SOEP) based on PAFPN to improve the detection capability of small targets.

[0105] The small target feature pyramid structure SOEP includes: SPDConv module and CSP-OmniKernel module; the SPDConv module is connected to the second layer C2f_Faster_CGLU module in the backbone network and the fifteenth Concat layer in the neck network respectively; the CSP-OmniKernel module is set between the fifteenth Concat layer and the seventeenth C2f module in the neck network.

[0106] Step 3021: The SPDConv module includes a space-to-depth transformation module SPD and a 3x3 convolutional layer connected in sequence; the input feature map is first processed by the space-to-depth transformation module to convert the spatial information of the feature map into the channel dimension; then the 3x3 convolutional layer is used to further extract local features, and the local features are output after integration.

[0107] like Figure 8 The following is a diagram of SPDConv when the slice interval scale = 2. The SPDConv module contains the following main components:

[0108] Input feature segmentation and splicing: The input feature map is first processed by the Space-to-Depth (SPD) transformation module. Specifically, the forward method divides the input feature map into four sub-regions (upper left, upper right, lower left, and lower right) through slicing operations, and then splices them together along the channel dimension. This operation increases the number of channels of the feature map by four times and reduces the spatial size. This process effectively converts the spatial information of the feature map to the channel dimension, preparing for subsequent convolution operations.

[0109] 3x3 convolution layer: A 3x3 convolution layer is applied to the output after feature segmentation to further extract local features. This convolution operation effectively integrates the information of different sub-regions, improving the ability to express small target features and capture details.

[0110] Output feature integration: After convolution processing, the generated feature map contains the comprehensive feature information of multiple sub-regions and has richer feature representation.

[0111] In SOEP, the P2 feature layer (i.e., the output of the second layer C2f_Faster_CGLU module) is used as input and first processed by SPDConv. SPDConv divides the input feature map into multiple sub-regions and performs convolution operations on each of them. After that, the feature map processed by SPDConv, the output feature map of the fourth layer C2f_Faster_CGLU, and the feature map upsampled by the thirteenth layer Upsample layer are fused together in the fifteenth Concat module, and the fusion results are then integrated through the sixteenth layer CSP-OmniKernel module.

[0112] Step 3022: CSP-OmniKernel module, including: a second 1x1 convolution layer, a feature segmentation module Split, a parallel multi-scale feature extraction module OmniKernel and Concat layer, and a third 1x1 convolution layer connected in sequence;

[0113] like Fig. 9 As shown in the figure, the output of the fifteenth Concat layer first passes through the second 1x1 convolution layer, and then the features are divided into two branches (OmniKernel branch and identity mapping branch) through the Split module; one branch uses the multi-scale feature extraction module OmniKernel to extract multi-scale features; the other branch passes through the identity mapping (the identity mapping branch retains the original features), and then the outputs of the two branches are spliced ​​in the channel dimension using the Concat layer, and finally pass through the third 1x1 convolution layer for feature fusion and output to the seventeenth C2f module of the neck network.

[0114] The CSP-OmniKernel provided by the present invention combines the designs of CSP and OmniKernel. First, the input features are preliminarily processed by the second 1x1 convolutional layer, and the output feature map is then nonlinearly transformed by the GELU activation function; thereafter, the third 1x1 convolutional layer divides the input features into two parts, one part of which is subjected to multi-scale feature extraction through the OmniKernel branch, and the other part is retained as a residual connection through the Split branch.

[0115] Among them, the OmniKernel branch includes: the fourth 1x1 convolution layer connected in sequence, three parallel branches: a local branch (detail branch), a context branch, and a global branch (frequency domain branch), and the fifth 1x1 convolution layer;

[0116] like Fig.10 As shown, in OmniKernel, given the input feature X∈R C×H×W After being processed by the fourth 1×1 convolutional layer, these features are fed into three branches, namely the local branch, the context branch, and the global branch, to enhance the multi-scale representation. The results of these three branches are fused by addition and output through the fifth 1×1 convolutional layer.

[0117] (1) The local branch includes a deep convolutional layer;

[0118] The convolution kernel size of the deep convolution layer in the local branch is 1x1. The local branch focuses on the modulation of the local signal through a 1×1 deep convolution operation, emphasizing the extraction of local details and fine features, and supplementing the deficiencies of the context branch and the global branch in local feature extraction.

[0119] (2) The context branch consists of three parallel deep convolutional layers;

[0120] The convolution kernel sizes of the three parallel deep convolution layers are 31×31, 1×31, and 31×1 respectively; the context branch captures large-scale spatial features by using deep convolution with a convolution kernel size of 31×31. At the same time, the band context information is obtained by combining the 1×31 and 31×1 deep convolution operations.

[0121] (3) The global branch includes a Dual-domain Channel Attention Module (DCAM) and a Frequency-based Spatial Attention Module (FSAM) connected sequentially; the Dual-domain Channel Attention Module is used to integrate features after feature modulation in the frequency and spatial domains through the Frequency-based Spatial Attention Module.

[0122] Among them, the dual-domain channel attention module (DCAM) includes a frequency channel attention module (FCA) and a spatial channel attention module (SCA) connected sequentially.

[0123] The frequency domain branch emphasizes global feature modeling and cross-domain information integration from the frequency domain perspective, and improves feature representation through dual-domain processing. Specifically:

[0124] First, given the input feature X Global ∈R C×H×W , the input features are processed by the frequency channel attention module (FCA):

[0125]

[0126] Where F and IF represent the fast Fourier transform and its inverse operation respectively, X FCA , and GAP represent the output of FCA, a 1×1 convolutional layer, and global average pooling, respectively. Represents an element-by-element multiplication operation. The FCA module optimizes the spectrum information by modulating the global features in the frequency domain.

[0127] Secondly, the features output by the frequency channel attention module (FCA) are input to the spatial channel attention module (SCA) to further enhance the features after frequency domain modulation:

[0128]

[0129] Through SCA, the model performs finer feature adjustments at the channel level.

[0130] Finally, the frequency-based spatial attention module (FSAM) performs fine-grained refinement of features to highlight useful frequency components required for high-quality image reconstruction:

[0131]

[0132] Through FSAM, the model can focus on processing the key frequency components in the image to achieve more accurate feature extraction.

[0133] Step 303: Design a lightweight shared convolutional detection head LSCD

[0134] During the training process, in order to reduce the number of model parameters and improve the training speed, the present invention introduces a shared convolution block in the detection head and designs a lightweight shared convolution detection head (LSCD); the detection head includes a first detection head, a second detection head and a third detection head, which are used to process the feature maps of the P3, P4, and P5 feature layers (i.e., the seventeenth, twentieth, and twenty-third C2f layers), respectively.

[0135] The shared convolution block includes three parallel sixth 1x1 convolutional layers and two sequentially connected 3x3 convolutional layers. The three parallel sixth 1x1 convolutional layers are used to send the features of the seventeenth, twentieth and twenty-third C2f layers in the neck network into two sequentially connected 3x3 convolutional layers to extract deep features. The features output by the 3x3 convolutional layers are sent to three parallel detection heads. Each detection head includes two independent convolutional layers, namely Conv_Reg and Conv_Cls, which are used to output the category and size of the target to be detected, respectively.

[0136] like Fig.11 As shown, the lightweight shared convolution detection head includes three parallel sixth 1x1 convolution layers, two sequentially connected 3x3 convolution layers, three parallel detection heads and a Scale layer; each detection head includes two convolution layers: Conv_Reg and Conv_Cls layers.

[0137] Step 3031: The feature maps from the P3, P4, and P5 feature layers are respectively compressed through the sixth 1x1 convolutional layer, and GroupNorm is applied to normalize them. The normalization calculation formula of GroupNorm is:

[0138]

[0139] Where x is a feature calculated by a certain layer and i is an index. In the case of 2D images, i = (i N ,i C ,i H ,i W ) is a 4D vector that indexes features in the order (N, C, H, W), where N is the batch axis, C is the channel axis, and H and W are the spatial height and width axes.

[0140] μ i and σ i Respectively represent the mean and standard deviation within the group, calculated as follows:

[0141]

[0142] where ∈ is a small constant, m represents the number of elements in each group, and x k represents the value of the kth feature channel, is the set of pixels for which the mean and standard deviation are calculated.

[0143] Step 3032: The feature map processed by the shared convolution module is further subjected to two consecutive 3x3 convolution operations to further extract deep features, and is normalized again by GroupNorm.

[0144] Step 3033: After passing through two consecutive 3x3 convolution operations, the processed feature maps are passed to two independent convolutional layers, namely Conv_Reg and Conv_Cls.

[0145] Among them, Conv_Reg is responsible for generating feature maps for bounding box regression and outputting the coordinates and size information of the target; Conv_Cls is responsible for generating feature maps for target classification and outputting the confidence of the target category.

[0146] Step 3034: Use the Scale layer to appropriately scale the output features of each detection head.

[0147] The features output by each detection head are first passed through the convolution layer to generate feature maps for regression and classification, and then scaled through the Scale layer so that the output features can adapt to different target scales.

[0148] In summary, the present invention proposes a method and system for grading mushrooms grown on mushroom sticks based on a neural network. By redesigning the backbone module, constructing a small target feature pyramid, and developing a lightweight shared convolutional detection head, the present invention significantly improves the detection accuracy and efficiency of different types of mushrooms in the process of mushroom grading. At the same time, the number of model parameters is reduced, and the model is lightweight, making it suitable for deployment in small detection equipment.

[0149] Embodiment 2

[0150] This embodiment discloses a mushroom grading system for mushroom cultivation based on improved YOLO v8, including:

[0151] The data acquisition module is configured to: acquire an image of mushrooms grown on mushroom sticks to be detected;

[0152] The mushroom grading module is configured to: input the acquired mushroom image into the trained improved YOLO v8 model to obtain the category and maturity of each detection target in the mushroom image;

[0153] The improved YOLO v8 model is obtained by replacing the C2f module in the original YOLO v8 model backbone network with the C2f_Faster_CGLU module, building a small target feature pyramid structure SOEP in the neck network to enhance the model's detection ability for small targets, and introducing a shared convolutional block in the detection head;

[0154] The small target feature pyramid structure SOEP includes an SPDConv module and a CSP-OmniKernel module; the SPDConv module is connected to the second layer C2f_Faster_CGLU module in the backbone network and the fifteenth Concat layer in the neck network respectively; the CSPO-mniKernel module is set between the fifteenth Concat layer and the seventeenth C2f layer in the neck network.

[0155] Embodiment 3

[0156] The purpose of this embodiment is to provide a computer-readable storage medium.

[0157] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in a method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as described in Example 1 of the present disclosure.

[0158] Embodiment 4

[0159] The purpose of this embodiment is to provide an electronic device.

[0160] An electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps in the method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as described in Example 1 of the present disclosure are implemented.

[0161] The steps involved in the apparatuses of the above embodiments 2, 3 and 4 correspond to the method embodiment 1, and the specific implementation methods can refer to the relevant description part of embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood to include any medium that can store, encode or carry an instruction set for execution by a processor and enable the processor to execute any method in the present invention.

[0162] Those skilled in the art should understand that the modules or steps of the present invention described above can be implemented by a general-purpose computer device, or alternatively, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. The present invention is not limited to any specific combination of hardware and software.

[0163] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.

Claims

1. A method for grading mushrooms grown on mushroom sticks based on improved YOLO v8, characterized in that: include: Acquire an image of mushrooms grown on mushroom sticks to be detected; The acquired mushroom images are input into the trained improved YOLO v8 model to obtain the category and maturity of each detection target in the mushroom images; The improved YOLO v8 model is obtained by replacing the C2f module in the original YOLO v8 model backbone network with the C2f_Faster_CGLU module, building a small target feature pyramid structure SOEP in the neck network to enhance the model's detection ability for small targets, and introducing a shared convolutional block in the detection head; The small target feature pyramid structure SOEP includes an SPDConv module and a CSP-OmniKernel module; the SPDConv module is respectively connected to the second-layer C2f_Faster_CGLU module in the backbone network and the fifteenth Concat layer in the neck network; the CSPO-mniKernel module is arranged between the fifteenth Concat layer and the seventeenth C2f module in the neck network.

2. A method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as claimed in claim 1, characterized in that: The C2f_Faster_CGLU module includes a C2f module, a partial convolutional layer PConv, an improved CGLU structure and a DropPath layer connected in sequence; The Linear layer in the original CGLU structure is replaced by the first 1x1 convolutional layer to obtain an improved CGLU structure; The partial convolution layer PConv is used to extract preliminary features; The improved CGLU structure is used to filter preliminary features through a gating mechanism, and to integrate the filtered features through the first 1x1 convolutional layer; the integrated features are output after passing through the DropPath layer.

3. A method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as claimed in claim 1, characterized in that: The SPDConv module includes a sequentially connected space-to-depth transformation module SPD and a 3x3 convolutional layer; The input feature map is first processed by the space-to-depth transformation module to convert the spatial information of the feature map into the channel dimension; then a 3x3 convolutional layer is used to further extract local features, which are then integrated and output.

4. A method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as claimed in claim 1, characterized in that: The CSP-OmniKernel module includes: a second 1x1 convolution layer, a feature segmentation module Split, a parallel multi-scale feature extraction module OmniKernel and a Concat layer, and a third 1x1 convolution layer connected in sequence; The output of the fifteenth Concat layer passes through the second 1x1 convolution layer and the feature segmentation module Split in turn to split the features into two branches. One branch uses the multi-scale feature extraction module OmniKernel to extract multi-scale features; the other branch uses the Concat layer to splice the outputs of the two branches in the channel dimension after identity mapping, and then passes through the third 1x1 convolution layer to output to the seventeenth C2f module of the neck network.

5. A method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as claimed in claim 4, characterized in that: The multi-scale feature extraction module OmniKernel includes: a fourth 1x1 convolutional layer, a local branch, a context branch and a global branch connected in parallel, and a fifth 1x1 convolutional layer; The input features are processed by the fourth 1x1 convolutional layer and then input to three parallel branches to enhance multi-scale representation. The features output by the three branches are output after passing through the fifth 1x1 convolutional layer. The local branch includes a deep convolution layer, the context branch includes three parallel deep convolution layers, and the global branch includes a dual-domain channel attention module and a frequency-based spatial attention module connected in sequence; the dual-domain channel attention module is used to integrate features after feature modulation in the frequency domain and the spatial domain through the frequency-based spatial attention module.

6. A method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as claimed in claim 1, characterized in that: The shared convolution block includes three parallel sixth 1x1 convolutional layers and two sequentially connected 3x3 convolutional layers; The three parallel sixth 1x1 convolutional layers are used to send the features of the seventeenth, twentieth and twenty-third C2f layers in the neck network into two sequentially connected 3x3 convolutional layers to extract deep features. The features output by the 3x3 convolutional layers are sent to three parallel detection heads to obtain the category and size of the target to be detected.

7. The method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 as claimed in claim 1, characterized in that: The training process of the improved YOLO v8 model includes: The obtained mushroom stick cultivation image dataset is preprocessed and annotated, and the annotated dataset is expanded using image enhancement technology; The improved YOLO v8 model is trained using the expanded dataset. During the training process, the content loss and frequency domain loss between the predicted image output by the model and the real image are calculated as the overall loss function of the model.

8. A mushroom grading system for mushroom cultivation based on improved YOLO v8, characterized in that: include: The data acquisition module is configured to: acquire an image of mushrooms grown on mushroom sticks to be detected; The mushroom grading module is configured to: input the acquired mushroom image into the trained improved YOLO v8 model to obtain the category and maturity of each detection target in the mushroom image; The improved YOLO v8 model is obtained by replacing the C2f module in the original YOLO v8 model backbone network with the C2f_Faster_CGLU module, building a small target feature pyramid structure SOEP in the neck network to enhance the model's detection ability for small targets, and introducing a shared convolutional block in the detection head; The small target feature pyramid structure SOEP includes an SPDConv module and a CSP-OmniKernel module; the SPDConv module is respectively connected to the second-layer C2f_Faster_CGLU module in the backbone network and the fifteenth Concat layer in the neck network; the CSPO-mniKernel module is arranged between the fifteenth Concat layer and the seventeenth C2f module in the neck network.

9. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the steps in the method for grading mushrooms grown on mushroom sticks based on improved YOLO v8 are implemented as described in any one of claims 1 to 7.

10. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the method for grading shiitake mushrooms grown on mushroom sticks based on improved YOLO v8 are implemented as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Vehicle target detection method and device based on multi-scale feature extraction and fusion

    CN119888449A

  • Forest fire target detection method, system and equipment based on improved YOLO and medium

    CN120182790A

  • Railway track defect detection method based on MFGA-YOLO model

    CN120298307A

  • A railway track defect detection method based on an MFGA-YOLO model

    CN120298307B

  • Tunnel anomaly detection model establishment and detection early warning method

    CN120388294A