Method for detecting various edible mushrooms in complex environment based on SSM-YOLO-tiny lightweight improved algorithm

By improving the YOLOv8n model, combining Slim-Neck and SENetv2 modules and knowledge distillation technology, the efficient and accurate detection problems of various types of edible fungi in complex environments are solved, and efficient identification and automated classification under low computing resources are achieved.

CN120580684APending Publication Date: 2025-09-02JILIN AGRICULTURAL UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510652515.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

The existing edible fungus detection methods are difficult to efficiently and accurately identify a variety of edible fungus in complex environments, especially in wild environments and cultivation scenarios, where there are problems of occlusion and overlap, and the traditional methods consume high computing resources and cannot meet market demand.

Method used

Using SSM-YOLO-tiny lightweight improvement algorithm, the Slim-Neck structure and SENetv2 module are introduced by integrating public and self-built data sets, combining knowledge distillation technology to optimize model parameter quantity and calculation complexity, and improve feature extraction capabilities.

Benefits of technology

It significantly improves the detection accuracy of edible fungi in complex environments, reduces calculation overhead, reduces manual identification time and error, improves detection efficiency and safety, and is suitable for embedded device deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120580684A_ABST
    Figure CN120580684A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image recognition, in particular to a method for detecting various edible mushrooms in a complex environment based on an SSM-YOLO-tiny lightweight improved algorithm, which can improve the classification detection precision of various edible mushrooms in the complex environment while keeping relatively low calculation overhead. By reducing the depth and the number of channels of the model and introducing a Slim-Neck structure and a SENetv2 module, the parameter quantity and the calculation complexity of the model are effectively reduced, the deployment efficiency in an embedded system is improved, and the detection performance of the model is further optimized through a knowledge distillation technology; according to the method, the time cost of manual identification and the identification error rate of similar mushrooms can be remarkably reduced, the working efficiency and the safety of field edible mushroom picking are improved, and the labor intensity and the edge deployment cost are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition technology, and specifically to a classification, positioning and detection method for 21 types of edible fungi in wild environments and production environments based on the SSM-YOLO-tiny lightweight model. Background Art

[0002] The edible fungi consumption market is mainly concentrated in household daily consumption and the catering industry, so the demand for efficient sorting and accurate pricing of different types of edible fungi has increased significantly.

[0003] As the variety and market size of edible fungi expand, traditional trading methods that rely on manual identification and weighing are inefficient and unable to meet modern market demands. Especially in markets with a wide variety of edible fungi, manual identification is not only time-consuming and labor-intensive, but also prone to classification and pricing errors, impacting transaction efficiency. Therefore, there is an urgent need for efficient, automated edible fungi identification and classification technology to reduce labor costs and improve market operational efficiency.

[0004] Currently, most international and domestic research on the classification and recognition of edible fungi still relies on traditional machine learning methods, which typically rely on shallow networks to perform simple classification. Due to limited experimental data, existing technologies primarily focus on binary classification of toxic and non-toxic edible fungi, which is unable to cope with the complex and diverse edible fungi species found in real-world scenarios. Furthermore, existing methods struggle to adapt to the training requirements of large convolutional neural networks, limiting both recognition accuracy and the breadth of their application scenarios.

[0005] With the development of deep learning and computer vision technologies, deep learning-based object detection algorithms, such as the YOLO series of models, have been widely used in the agricultural field, covering scenarios such as weed identification and fruit detection. Due to their low computational complexity and high speed, the YOLO series of models has gradually been applied to the detection of small targets. However, existing edible fungus detection methods still struggle to meet the needs of efficient identification of multiple types of edible fungi in complex environments, especially in wild environments and cultivated scenarios, where edible fungi have significant morphological differences and a wide variety of species, and the detection process may be subject to occlusion and overlap.

[0006] Furthermore, the diversity and complexity of mushrooms make accurate classification in complex environments challenging. Approximately 14,000 mushroom species are defined globally, of which only about 25% are edible. Due to the high morphological similarity of some mushrooms, especially the subtle differences in appearance between poisonous and non-poisonous mushrooms, traditional detection methods struggle to achieve efficient and accurate classification in a short period of time. This places higher demands on the safety of edible fungi in market transactions, wild collection, and consumption.

[0007] Therefore, how to build an efficient, lightweight mushroom detection model that can adapt to a variety of complex environments, especially under the condition of limited computing resources, has become a technical problem that needs to be solved urgently. Summary of the Invention

[0008] The purpose of the present invention is to provide an automatic edible fungus identification method based on a lightweight and improved SSM-YOLO-tiny algorithm, which can improve the classification and detection accuracy of various edible fungi in complex environments while maintaining a low computational overhead. By reducing the model depth and number of channels and introducing the Slim-Neck structure and SENetv2 module, the present invention effectively reduces the number of model parameters and computational complexity, improves the deployment efficiency in embedded systems, and further optimizes the model's detection performance through knowledge distillation technology. This method can significantly reduce the time cost of manual identification and the recognition error rate of similar mushrooms, improve work efficiency and the safety of picking edible fungi in the wild, and reduce labor intensity and edge deployment costs.

[0009] In order to achieve the above technical objectives, the present invention mainly adopts the following technical solutions:

[0010] A method for detecting multiple edible fungi in a complex environment based on the SSM-YOLO-tiny lightweight improved algorithm includes the following steps:

[0011] Step 1: This paper integrates an unlabeled public edible fungus image dataset and a self-built dataset, covering 21 common edible fungi, including wild and cultivated fungi; the dataset is enhanced and annotated, and saved in YOLO format;

[0012] Step 2: Construction of a lightweight edible fungus classification and detection model: Based on YOLOv8n as the baseline model, an improved lightweight edible fungus classification and detection model is constructed;

[0013] Step 3: Training the lightweight edible fungus classification and detection model: Input various edible fungus images in YOLO format into the trained lightweight edible fungus classification and detection model for training;

[0014] Step 4: Acquisition of edible mushroom images: Acquire the image of the edible mushroom to be detected and perform preprocessing;

[0015] Step 5: Obtaining edible fungus image detection results: Input the preprocessed edible fungus image to be detected into the trained lightweight edible fungus detection model to obtain the edible fungus image detection results.

[0016] The dataset construction method described in step 1 includes the following steps:

[0017] (1) Images of 21 common edible mushrooms were obtained from the Ymushroom public dataset, the roboflow public dataset, and the self-built oyster mushroom dataset. Figure 1 ;

[0018] (2) Manually annotate the images of various edible fungi and divide them into training set (60%), validation set (20%) and test set (20%).

[0019] (3) Data enhancement was performed on the categories that lacked representation to balance the number of categories in the dataset; a total of 9,099 edible mushroom images and 19,511 labels were obtained. Figure 2 ;

[0020] (1) Optionally, establish a list of edible fungi varieties, collect images of various edible fungi varieties in different environments based on the list of edible fungi varieties, and establish an edible fungi dataset; conduct market research, select the total number of edible fungi varieties, establish a list of edible fungi varieties, and collect images of various edible fungi varieties in different environments based on the list of edible fungi varieties;

[0021] (2) optional, division ratio;

[0022] The construction of the lightweight edible fungus detection model in step 2 includes the following steps:

[0023] (1) Set YOLOv8n to include Backbone module, Neck module and Head module;

[0024] (2) The original C2f module in the Neck module is replaced with the VoVGSCSP module, and the original Conv module of the upsampling is replaced with the GSConv module, so that the model can accelerate the prediction calculation, retain the hidden connection, and reduce the resistance caused by the depth of the model;

[0025] (3) In the Neck module, a SENetv2 module is added after each C2f module that is originally output to the Head module, so that the output passes through SENetv2 before being output backward or to the detection head to enhance the inter-channel and global feature expression capabilities;

[0026] Use the above improvements to build a YOLOv81 model and train it to obtain training weights;

[0027] (4) Set the depth coefficient of the YOLOv8n model to 0.25 and the number of channels to 512 to further reduce the weight parameters and computational complexity of the model;

[0028] (5) The improved YOLOv81 model is used as the teacher model, and the improved YOLOv8n model is used as the student model. The mimicking distillation method is used for offline distillation training.

[0029] Alternatively, (5) you can choose to use the original YOLOv8n depth coefficient 0.33 and the number of channels 1024, and use CWD (channel-wise distillation) distillation to obtain SSM-YOLOn, which can achieve better results, but has a higher number of parameters and computational complexity than SSM-YOLO-tiny;

[0030] Set the GSConv and VoVGSCSP combination to a Slim-Neck structure:

[0031] (1) The GSConv (Group Shuffle Convolution) module consists of two parts: group convolution and depthwise convolution. It aims to achieve efficient feature extraction through group convolution and channel reorganization. It uses group convolution to reduce the amount of computation while retaining important feature information through splicing and reorganization.

[0032] (2) The first part is set as a standard group convolution (Conv) to preliminarily extract local features of edible fungi. The input tensor first passes through a 1×1 convolution kernel to adjust the number of channels and extract preliminary features;

[0033] (3) The calculation formula of standard group convolution is:

[0034] (4)

[0035] (5) The second part is set to a 5×5 depthwise convolution to capture a wider range of contextual information about edible fungi. This convolution operation uses grouped convolution, where the number of channels is divided into several groups, and each group is convolved separately;

[0036] (6)

[0037] (7) The calculation formula of GSConv is:

[0038] (8) FLOPs GSConv =FLOPs1+FLOPs2

[0039] (9)

[0040] (10) Where H×W is the size of the input edible fungus feature map, C in is the number of input channels, C outis the number of output channels, k×k is the convolution kernel size, and g is the number of groups;

[0041] (11) Finally, the output feature maps of the two parts are merged through the splicing operation to form a complete feature map.

[0042] (12) The VoVNet with GSConv and Cross Stage Partial Block (VoVGSCSP) module consists of four parts. It combines the design ideas of GSConv and CSP (Cross Stage Partial) and mainly enhances the network's feature extraction capabilities through cross-stage fusion of features. VoVGSCSP further combines lightweight design with deep feature extraction to achieve efficient and accurate feature expression.

[0043] (13) The first part is set as two independent 1×1 convolutional layers (cv1 and cv2) to process the input edible fungus feature map respectively;

[0044] (14) Convolution processing calculation formula:

[0045] (15) FLOPs cv1 =C in ×C hidden ×1×1×H×W

[0046] (16) Among them, C hidden is the number of channels in the hidden layer, usually equal to C out ×e, e is the scaling factor;

[0047] (17) The second part is set as the GSBottleneck module, which further advances the detailed features of edible fungi through a combination of multiple GSConvs, and a cross-layer connection to retain the detailed information of the edible fungi input features;

[0048] (18) The calculation formula of shortcut is:

[0049] (19) FLOPs shortcut =C in ×C out ×1×1×H×W

[0050] (20) The calculation formula for GSBottleneck processing is:

[0051] (21) FLOPs GSBottleneck =n×FLOPs GSConv +FLOPs shortcut

[0052] (twenty two)

[0053] (23)where n is the number of layers of GSBottleneck;

[0054] (24) Set the third part as the splicing operation, which splices the two features (the features processed by GSBottleneck in cv1 and the features processed directly by cv2) together to generate 2×C hidden Feature map of

[0055] (25) The calculation formula of the splicing operation is:

[0056] (26) FLOPs concat =2×C hidden ×H×W

[0057] (27) Set the fourth part to a 1×1 convolution (cv3) to fuse the output features of the two branches;

[0058] (28) The calculation formula of fused convolution is:

[0059] (29) FLOPs cv3 =2×C hidden ×C out ×1×1×H×W

[0060] Setting up the SENetv2 module:

[0061] (1) SELayerV2 is an improved version of the classic SE (Squeeze-and-Excitation) module, which includes four steps and mainly improves the expressiveness of the model by introducing multiple sub-channel processing (Cardinality).

[0062] (2) Set the Squeeze operation: Use global average pooling (AdaptiveAvgPool2d(1)) to compress the spatial dimension and globally summarize the spatial information of each channel of the input feature map into a scalar.

[0063] (3) For the input tensor After pooling, we get:

[0064] (4)

[0065] (5) Setting the Excitation operation: Next, multiple fully connected layers (fc1 to fc4) are used to aggregate information between channels of features:

[0066] (6) Excitation operation formula:

[0067] (7)y1=σ(W2·δ(W1·y))

[0068] (8) and δ, σ are activation functions ReLU and Sigmoid respectively

[0069] (9) Setting up Cardinality sub-channel processing: This module processes four parallel sub-channel paths, each with its own fully connected layer, and then concatenates their outputs (torch.cat) and fuses them through a fully connected layer;

[0070] (10) Cardinality subchannel processing formula

[0071] (11)

[0072] (12) The fusion result is set to pass through the Sigmoid activation function and multiply it with the input feature map channel by channel to obtain the final enhanced feature;

[0073] (13) The output formula is:

[0074] (14)output=x·σ(fc(y concat ))

[0075] Set the Mimic knowledge distillation method:

[0076] (1) This paper adopts a knowledge distillation method based on feature imitation, which allows students to directly learn the effective information of teacher features, is applicable to different architectures, contains all teacher information, focuses on feature directions to improve student performance, flexibly handles multi-label problems, and can achieve higher distillation accuracy;

[0077] (2) Teacher network: Given an image x, the teacher backbone network extracts features f t ,in are the features of the penultimate layer (after global average pooling and before the final classifier or detection head);

[0078] (3) Student network: Student backbone network extracts features f s In order to make f s and f t Match the dimensions of , and add a linear embedding layer;

[0079] (4) The formula of the linear embedding layer is defined as:

[0080] (5)

[0081] (6) Among them, f is the feature extracted by the student backbone network

[0082] (7) The loss function is set to be classified into classification loss, mean square error loss, and loss based on local sensitive hashing (LSH). Different loss functions are used to guide the student model to learn the knowledge of the teacher model.

[0083] (8) Set the classification loss to the cross entropy loss function, and the formula is defined as:

[0084] (9)

[0085] (10) Where n is the number of samples, yi is the true label of the i-th sample, is the model's predicted output for the i-th sample;

[0086] (11) The formula for setting the mean square error loss function is defined as:

[0087] (12)

[0088] (13) Where, f t (x i ) and f s (x i ) represent the features of the teacher and student for the i-th image in the training set, D represents the dimension of the feature (after linear embedding fc1), and n is the number of images;

[0089] (14) Setting the loss based on Locality Sensitive Hashing (LSH) to encourage the student features and teacher features to have similar distributions in the hash space, so that the student imitates the teacher in the feature direction while giving a certain degree of freedom in the amplitude;

[0090] (15) Formula of hash function:

[0091] (16)

[0092] (17) Among them, It is a feature. is a random vector whose entries are sampled from a Gaussian distribution. b is a real number uniformly selected from the range [0, r]. r is the length of each bin. [-] is the floor function.

[0093] (18) The formula for generating hash code by LSH module:

[0094] (19)

[0095] (20) Among them, It is a feature. is the weight, Its entries are sampled from a Gaussian distribution.

[0096] It is a deviation;

[0097] (21) The hash codes of student features and teacher features are matched. The goal is to make the hash codes of student features the same as the hash codes of teacher features. This is achieved by learning a classification problem using binary cross entropy loss, as follows:

[0098] (twenty two)

[0099] (twenty three)

[0100] (twenty four)

[0101] (25) Where: n is the number of images. N is the number of hash functions. j is the th hash code of the teacher feature. , where is the sigmoid function, f s It is a student characteristic.

[0102] Set the CWD knowledge distillation method:

[0103] (1) This paper adopts a knowledge distillation method based on channel attention. By effectively transferring the knowledge of the teacher network to the student network, the feature extraction ability and classification performance of the student network are improved while maintaining the efficient use of computing resources. The method mainly consists of three parts: channel distillation (CD), guided knowledge distillation (GKD), and early decay teacher strategy (EDT).

[0104] (2) Channel distillation is set to pass the information of the teacher network on each channel to the student network through the attention mechanism. Specifically, each channel of the teacher network corresponds to a different visual pattern and has a high feature expression ability. Through global average pooling (GAP), the teacher network can calculate the importance weight for each channel. The student network can capture more effective feature information by imitating the channel attention distribution of the teacher network;

[0105] (3) The loss function of channel distillation is defined as:

[0106] (4)

[0107] (5) Among them, w ij is the weight of the jth channel of the i-th sample, n and c represent the number of samples and channels respectively;

[0108] (6) Set the guided knowledge distillation strategy to use only the samples correctly predicted by the teacher network to guide the learning of the student network, ignoring the samples with incorrect predictions. In this way, the student network only imitates the correct output of the teacher network, thereby improving its performance;

[0109] (7) The loss function guiding the knowledge distillation strategy is defined as:

[0110] (8)

[0111] (9) Where I is the indicator function, which is l when the teacher network predicts correctly and 0 when it is wrong;

[0112] (10) Setting the early attenuation teacher strategy to gradually reduce the weight of the channel distillation loss as training progresses, so that the student network can be better optimized autonomously in the later stage;

[0113] (11) The weight decay of the early decay teacher strategy is:

[0114] (12)

[0115] (13) where α is the initial weight of the distillation loss, n e is the epoch number of the current training, and n is the preset total epoch number.

[0116] The training of the lightweight edible fungus detection model described in step 3 includes the following steps:

[0117] (1) Training environment configuration: GPU is NVDIA GeForce RTX 3090, CPU is Intel(R) Xeon(R) Gold5218 CPU@2.30GHz , based on Windows 10 system equipped with Pytorch framework and Python 3.8 programming language;

[0118] (2) Training parameter settings: The model input size is 640×640, the number of samples per batch is 32, the stochastic gradient descent method SGD is used to optimize the network parameters, the momentum is set to 0.937, the initial learning rate of the weight is 0.01, the weight decay is 0.0005, and a total of 200 rounds of training;

[0119] (3) The edible mushroom image dataset is input into the Backbone module of the lightweight edible mushroom detection model. The image is processed through a series of Conv modules and C2f modules. The model gradually extracts feature information at different levels from the bottom to the top. The model finally outputs a multi-level feature map, which includes features of different scales and depths extracted from the edible mushroom images. Feature information of different levels is extracted;

[0120] (4) The Neck module receives the multi-level feature map from the Backbone module, first undergoes two upsamplings and fuses it with the Backbone output features and outputs the features when passing through the VoVGSCSP. It then undergoes two downsamplings through the GSConv module and fuses it with the output features during upsampling.

[0121] (5) The Head module receives the feature map of the fused multi-level edible fungi features processed by the Neck module, and performs classification and positioning detection of edible fungi on the fused feature map.

[0122] Beneficial effects:

[0123] Compared to existing technologies, this method for classifying and locating 21 edible fungi species based on the lightweight SSM-YOLO-tiny model effectively addresses the need for efficient and accurate detection of multiple edible fungi in complex environments. By improving the YOLOv8n model, it reduces unnecessary parameters and computational complexity, significantly alleviating the hardware burden and making it more suitable for deployment on embedded devices and mobile devices.

[0124] By introducing the Slim-Neck and SENetv2 modules in the Neck part, the model's ability to extract the morphological features of edible fungi and better retain the hidden connections of the features is further improved, especially in dealing with occlusion, overlap and complex background conditions in the wild environment, showing excellent results in the classification and positioning of edible fungi.

[0125] This invention utilizes deep learning technology, and through continuous optimization, the model can effectively detect different varieties of edible fungi in multiple scenarios, balancing parameter quantity, efficiency, and accuracy. Furthermore, through the application of knowledge distillation technology, the model's detection performance is further optimized, enabling efficient and low-cost deployment. This method not only improves the automation level of edible fungi detection but also reduces errors caused by manual intervention, providing important technical support for accurate pricing, sorting efficiency, and field harvesting safety in the edible fungi market.

[0126] The designed SSM-YOLO-tiny algorithm introduces modules such as Slim-Neck and SENetv2 in the Neck part, achieving better detection results while reducing the number of model parameters and computational complexity. By reducing the depth and number of channels and using Mimic distillation learning technology, the number of model parameters is reduced from 3.01M to 1.74M, a 42% reduction, and the computational complexity is reduced from 8.2GFLOPS to 6.6GFLOPS, a 20% reduction. The mAP50 and mAP95 improve by 1.64% and 3.52% on the validation set, and by 0.94% and 2.75% on the test set, respectively.

[0127] In various scenarios, including those with different shapes, densities, and background complexities, the edible fungus detection method designed by the present invention can effectively solve the problem of difficulty in identification and missed identification caused by overlapping different mushrooms, and has a lower false detection rate for similar mushrooms, indicating that the improved edible fungus detection method has good robustness.

[0128] The designed SSM-YOLO-tiny model is significantly higher than advanced target algorithms such as YOLOv8n and YOlOv10n in terms of accuracy indicators such as mAP50 and mAP95, and is lower in model size, weight parameters, and inference calculation amount than the original YOLOv8n model, which is more conducive to the migration and application of the model on various mobile embedded devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0129] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 the structures shown in these drawings without paying any creative work.

[0130] Figure 1 This is a sample of the 21 edible fungi dataset used in this invention.

[0131] Figure 2 Distribution diagram of the number of labels for 21 edible fungi used in this invention

[0132] Figure 3 This is a flowchart of the SSM-YOLO-tiny-based lightweight and improved edible fungus detection method according to an embodiment of the present invention;

[0133] Figure 4 Schematic diagram of the network structure of the SSM-YOLO-tiny detection model in the present invention;

[0134] Figure 5 This is a comparison chart of the detection effect of the SSM-YOLO-tiny model in the present invention compared with the original YOLOv8n model training process;

[0135] Figure 6 This is a comparison chart of the detection effect test examples of the SSM-YOLO-tiny model in the present invention compared with the original YOLOv8n model; DETAILED DESCRIPTION

[0136] While the preferred embodiments of the present invention have been described in detail above, it should be understood that, after reading the above teachings of the present invention, those skilled in the art may make various changes or modifications to the present invention. Such equivalents also fall within the scope of the claims appended hereto.

[0137] The present invention provides a method for detecting multiple edible fungi in complex environments based on a lightweight improved SSM-YOLO algorithm. The following are specific embodiments of the present invention:

[0138] Dataset construction:

[0139] This paper integrates a publicly available dataset of edible mushroom images with a self-built dataset, covering 21 major edible mushroom species (see Table 1). Data augmentation techniques are used to preprocess categories with fewer than 500 labels. These are then annotated according to the requirements of the YOLO model. The dataset is then divided into training, validation, and test sets in a 6:2:2 ratio to ensure diversity and accuracy in model training.

[0140] Data enhancement methods include rotation, flipping, brightness adjustment, etc., especially for complex environment images collected in the wild. Table 1

[0141] English name Chinese name Features Total number of tags Lentinus edodes mushroom Rich in protein and multiple vitamins 1043 Agaricus bisporus Agaricus bisporus The most common edible mushrooms come in two varieties: white and brown 987 Collybia albuminosa Alternaria Growing on rotten wood, relatively rare 673 Hericium erinaceus Hericium erinaceus It has a unique shape and taste and is known as a "mountain treasure". 1008 Coprinus comatus Coprinus comatus Best eaten when young, it liquefies when ripe 830 Morchella esculenta Morels Precious wild edible mushrooms are expensive 914 Dictyophora indusiata bamboo fungus Has a unique mesh structure and tastes delicious 893 Boletus Boletus There are many species, some of which have high edible value 761 Cantharellus cibarius chanterelles Delicious and often used in various dishes 1246 Clitocybe maxima Funnel mushroom Large mushrooms that grow in meadows and forest edges 1067 Cordyceps militaris Cordyceps sinensis It has the effects of enhancing immunity and resisting fatigue 758 Auricularia auricula fungus Rich in gelatin, often used in Chinese cuisine 966 Pleurotus eryngii King Oyster Mushroom Crisp and tender texture, delicious taste 624 Pleurotus cystidiosus Abalone Mushroom The shape is similar to other oyster mushrooms and the taste is delicious 1203 Agaricus blazei Murill Agaricus blazei Has anti-cancer and immune-enhancing effects 660 Armillaria mellea Armillaria Can grow on tree roots, forming mycelial bundles 1226 Hypsizygus marmoreus White jade mushroom White color, crisp and tender taste 1021 Pleurotus ostreatus Oyster mushroom Widely cultivated and delicious 1140 Pleurotus citrinopileatus Golden Oyster Mushroom Golden color, tender and smooth taste 642 Flammulina velutiper Enoki mushrooms Slender, delicious, often used in hot pot and cold dishes 643 Agrocybe aegerita Agrocybe tumefaciens Delicious, often used in soups 1206

[0142] Model construction:

[0143] The lightweight model is based on YOLOv8n and incorporates the Slim-Neck architecture and SENetv2 module into the Neck module. This reduces model complexity by reducing the number of channels and depth, while also enhancing the model's feature extraction capabilities for edible fungi. The Slim-Neck architecture integrates the GSConv and VoVGSCSP modules for more efficient feature representation and processing.

[0144] The improved model can efficiently classify and locate different types of edible fungi in the wild and production environments. In particular, when faced with the problems of a large number of edible fungi species, large morphological differences, and possible overlapping occlusion, the model shows good robustness.

[0145] Model training:

[0146] The model was trained using an NVIDIA RTX 3090 GPU. The model input size was set to 640×640, and stochastic gradient descent (SGD) was used for optimization. The training batch size was 32, and the learning rate and weight decay were dynamically adjusted based on the training results.

[0147] During the training process, the Mimic method performs knowledge distillation, effectively transferring the knowledge of the YOLOv81-based teacher model to the improved YOLOv8n student model, thereby improving the feature extraction and classification capabilities of the student model, and ultimately achieving higher detection accuracy in complex environments.

[0148] Edible mushroom image detection:

[0149] The detection process includes: first, the image of the edible fungus to be tested is collected by a camera device, and after inputting it into the model, the model preprocesses the image. Then, the model inputs the preprocessed image into the Backbone module, extracts the multi-level feature map, and obtains the final classification and positioning results after Slim-Neck processing in the Neck module.

[0150] The detection results output the classification labels and location information of edible fungi, which is particularly suitable for the automated collection, classification and identification of edible fungi in complex field environments or production scenarios.

[0151] Deployment and application:

[0152] The invented model, due to its lightweight design, is suitable for deployment on embedded devices and mobile terminals. On embedded platforms, by reducing the amount of computation and model parameters, it improves detection speed and energy efficiency, enabling real-time detection on edge devices, significantly expanding its application scenarios.

[0153] The present invention achieves efficient and accurate detection of various types of edible fungi by introducing the Slim-Neck structure, SENetv2 module and knowledge distillation technology. In particular, it optimizes the computational requirements of the model in complex environments and achieves good application effects.

[0154] The above shows and describes the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions merely illustrate the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and modifications are intended to fall within the scope of the present invention. The scope of protection claimed by the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for detecting multiple edible fungi in complex environments based on the SSM-YOLO-tiny lightweight improved algorithm, characterized by: The following steps are involved: Step 1: Integrate unlabeled public edible fungi image datasets and self-built datasets, covering 21 common edible fungi, including wild and cultivated fungi; perform data augmentation and data annotation on the datasets, and save them in YOLO format; Step 2: Construction of a lightweight edible fungus classification and detection model: Based on YOLOv8n as the baseline model, an improved lightweight edible fungus classification and detection model is constructed; Step 3: Training the lightweight edible fungus classification and detection model: Input various edible fungus images in YOLO format into the trained lightweight edible fungus classification and detection model for training; Step 4: Acquisition of edible mushroom images: Acquire the image of the edible mushroom to be detected and perform preprocessing; Step 5: Obtaining edible fungus image detection results: Input the preprocessed edible fungus image to be detected into the trained lightweight edible fungus detection model to obtain the edible fungus image detection results.

2. The method for detecting multiple edible fungi in complex environments based on the SSM-YOLO-tiny lightweight improved algorithm according to claim 1, characterized in that: 1) We obtained images of 21 common edible mushroom species from the Ymushroom and Roboflow public datasets, as well as a self-built dataset of oyster mushrooms. 2) We manually annotated each type of edible mushroom image and divided the dataset into a training set (60%), a validation set (20%), and a test set (20%). 3) We performed data augmentation on underrepresented categories to ensure a balanced number of categories in the dataset. A total of 9099 edible mushroom images and 19511 labels were obtained.

3. The method for detecting multiple edible fungi in complex environments based on the SSM-YOLO-tiny lightweight improved algorithm according to claim 1, characterized in that: The construction of the lightweight edible fungus detection model described in step 2 further includes the following steps: 1): Set YOLOv8n to include Backbone module, Neck module and Head module; 2) Replace the original C2f module in the Neck module with the VoVGSCSP module and the original upsampling Conv module with the GSConv module to speed up the prediction calculation of the model, retain the hidden connections, and reduce the resistance caused by the model depth; 3) In the Neck module, an SENetv2 module is added after each C2f module that originally outputs to the Head module. This allows the output to pass through SENetv2 before being output to the backward or detection head to enhance the inter-channel and global feature expression capabilities. The YOLOv81 model is constructed and trained using the above improvements to obtain training weights. 4) Set the depth coefficient of the YOLOv8n model to 0.25 and the number of channels to 512 to further reduce the number of weight parameters and computational complexity of the model; 5) The improved YOLOv81 model is used as the teacher model, the improved YOLOv8n model is used as the student model, and the mimic distillation method is used for offline distillation training.

4. The method for detecting multiple edible fungi in complex environments based on the SSM-YOLO-tiny lightweight improved algorithm according to claim 1, characterized in that: The training of the lightweight edible fungus detection model described in step 3 further includes the following steps: (1) Training environment configuration: GPU is NVID IA GeForce RTX 3090, CPU is Intel(R) Xeon(R) Gold 5218CPU@2.30GHz, and it is run on Windows 10 system with Pytorch framework and Python 3.8 programming language; (2) Training parameter settings: The model input size is 640×640, the number of samples per batch is 32, the stochastic gradient descent method SGD is used to optimize the network parameters, the momentum is set to 0.937, the initial learning rate of the weight is 0.01, the weight decay is 0.0005, and a total of 200 rounds of training; (3) The edible mushroom image dataset is input into the Backbone module of the lightweight edible mushroom detection model. The images are processed through a series of Conv modules and C2f modules. The model gradually extracts feature information at different levels from the bottom to the top. The model finally outputs a multi-level feature map. These feature maps include features of different scales and depths extracted from the edible mushroom images, as well as feature information extracted at different levels. (4) The Neck module receives the multi-level feature map from the Backbone module, first undergoes two upsamplings and fuses it with the Backbone output features and outputs the features when passing through the VoVGSCSP. It then undergoes two downsamplings through the GSConv module and fuses it with the output features during upsampling. (5) The Head module receives the feature map of the fused multi-level edible fungi features processed by the Neck module, and performs classification and positioning detection of edible fungi on the fused feature map.