A visual weight grading method compatible with flammulina velutipes and auricularia auricula

By using an improved Mask R-CNN deep learning model and multimodal data synchronization locking technology, combined with the morphological differences between enoki mushrooms and golden ear fungus, efficient and low-error-rate grading of enoki mushrooms and golden ear fungus was achieved, solving the problems of low efficiency and poor accuracy in existing technologies, and improving sorting accuracy and equipment safety.

CN122200637APending Publication Date: 2026-06-12BINZHOU POLYTECHNIC
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BINZHOU POLYTECHNIC
Filing Date
2026-04-27
Publication Date
2026-06-12

Smart Images

  • Figure CN122200637A_ABST
    Figure CN122200637A_ABST
Patent Text Reader

Abstract

A visual weight grading method compatible with flammulina velutipes and chroogomphus rutilus, comprising the following steps: S1. obtaining a detection image of the material to be detected; S2. pre-identification is carried out according to the detection image, and the product type is obtained; S3. judging the product quality based on the product type, and finally completing the grading. The present application utilizes the significant and distinguishable difference between flammulina velutipes and chroogomphus rutilus in morphological characteristics, that is, flammulina velutipes is in the form of a cluster bundle, the overall contour is a vertical strip bundle with a long axis obviously larger than a short axis, the color is mainly off-white or light yellow, and the texture is fine and linear; chroogomphus rutilus is in the form of a single block, the overall contour is close to a circle, the color is obviously orange to golden yellow, and the surface texture is rough and wrinkled. The classification effect is good, and the error rate is low.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to a method for grading the apparent weight of both enoki mushrooms and golden ear fungus. Background Technology

[0002] Currently, grading in the edible mushroom industry mainly relies on manual labor, which suffers from low efficiency and inconsistent standards. Existing automated grading equipment is mostly designed for single varieties (such as grading the cap diameter of shiitake mushrooms) and lacks versatility.

[0003] For enoki mushrooms, due to their slender and easily overlapping stems, traditional diameter measurement methods have large errors and are difficult to accurately quantify the core quality indicator of "umbrella opening degree".

[0004] For golden ear fungus, the commodity value is highly dependent on the weight and color of a single fruit. Machine vision alone cannot perceive the weight, and weighing alone cannot identify defective products that are moldy or have poor color.

[0005] In addition, the current identification process generally uses traditional conveyor belts, which can easily cause brittle mushrooms to roll or suffer mechanical damage. Summary of the Invention

[0006] To address the aforementioned issues, this application proposes a weight-based grading method compatible with both enoki mushrooms and golden ear fungus, comprising the following steps: S1. Acquiring a detection image of the material to be tested; S2. Performing preliminary identification based on the detection image to obtain the product type; S3. Judging the product quality based on the product type to finally complete the grading. For products identified as enoki mushrooms, the following steps are followed for grading: S131. Acquire the detection image and perform end-to-end instance segmentation using a modified Mask R-CNN deep learning model; S132. Extract effective feature pixels; S133. Calculate the pixel area ratio parameter; S134. Extract defect features; S135. Final grading. For products identified as "golden ear" products, the following steps are followed for classification: S231. Multimodal data synchronization and feature extraction; S232. Multidimensional benchmark mapping of physical morphology; S233. Visual quantification and weighted scoring; S234. Dynamic degradation error prevention mechanism; S235. Final classification. This application utilizes the significant identifiable differences in morphological characteristics between enoki mushrooms and golden ear fungus. Enoki mushrooms are clustered and bundled, with an overall outline of vertical stripes whose long axis is significantly larger than its short axis, and are mainly off-white or light yellow in color, with a fine linear texture. Golden ear fungus, on the other hand, is single-unit and blocky, with an overall outline that is close to round, and a distinct orange-yellow to golden-yellow color, with a rough and wrinkled surface texture. This method of quantitative classification yields good classification results and a low error rate.

[0007] Preferably, the detection image of the material to be tested is obtained in the following manner: Place the material to be tested into the rubber tray and then put it into the collection dark box; The acquisition dark box includes a detection conveyor belt at the bottom, an industrial camera for acquiring detection images is set above the detection conveyor belt, and an LED ring light source is set outside the corresponding industrial camera. A weighing support is installed below the conveyor belt for inspection.

[0008] Preferably, the rubber tray has several arc-shaped grooves inside, and rubber ribs are provided at the bottom of the arc-shaped grooves.

[0009] Preferably, the product type is determined by pre-identification based on the detected image according to the following steps: S21. Pre-screening of outline aspect ratio: The detected image is converted into an RGB image, binarized, and the overall bounding rectangle of the sample is extracted. The aspect ratio R is then calculated. aspect = Major axis / Minor axis. If R... aspect If R ≥ 2.0, it is determined to be enoki mushroom; if R aspect If the color value is less than 2.0, proceed to step two for color verification. S22.HSV Color Feature Verification: Convert the image to the HSV color space and extract the tonal mean of the sample area. H With the mean saturation S The typical color gamut of golden ear fungus is orange-yellow, H∈[15°,40°], S≥0.5, while the color gamut of enoki mushroom is white to light yellow. Or S < 0.3. If the color characteristics match the color gamut of *Euryale ferox*, it is ultimately determined to be *Euryale ferox*; otherwise, it is determined to be *Enoki mushroom*. If the color characteristics match the color gamut of golden ear fungus, it is ultimately determined to be golden ear fungus; otherwise, it is determined to be enoki mushroom.

[0010] S23. Confidence Arbitration of Deep Learning Models: When the morphological and color features extracted in step one or step two result in insufficient confidence in the rule judgment due to abnormal lighting, sample contamination, or atypical morphology, i.e., the maximum softmax probability output by MobileNetV3 is lower than the preset threshold P, th When the sample is marked as "low confidence pending verification", the system will trigger the conveyor belt to pause or slow down, and issue an audio-visual prompt on the operation interface. The operator will then manually confirm the information once. At the same time, the feature data will be automatically archived into the model's continuous learning database for subsequent closed-loop optimization iterations of the model.

[0011] Preferably, the preset threshold P th The calibration should be performed as follows: (a) Construction of validation set: In the real collection environment of the production line, a private validation set containing more than 500 images each of enoki mushroom and golden ear fungus, covering various light intensities and sample states, was constructed and manually labeled frame by frame. (b) ROC and Curve analysis: Let MobileNetV3 output the Softmax maximum probability value p for the validation set samples. max The algorithm iterates through the candidate threshold interval [0.70, 0.95] (step size 0.01) and calculates the Precision, Recall, and... for each threshold. Score and plot the corresponding curve. Select The threshold corresponding to the peak score is used as P. th : , ; (c) Experimental conclusion: Experimental data show that when p max When p < 0.85, the actual classification accuracy of the model drops to approximately 87%, which is below the acceptable lower limit of the system (95%); when p max When the accuracy is ≥ 0.85, the accuracy rate remains stable above 98.6%. On the validation set, hour The score reached a peak of 0.982, therefore P was ultimately determined. h = 0.85 is used as the critical threshold for triggering manual review.

[0012] Preferably, for products identified as enoki mushrooms, the following steps are followed for grading: S131. Acquire the detection images and perform end-to-end instance segmentation using the modified Mask R-CNN deep learning model: S1311. Lightweight backbone reconstruction for feature extraction in Mask R-CNN deep learning models: The original ResNet backbone is replaced with the lightweight MobileNetV3 network, and a lightweight backbone is obtained by introducing depthwise separable convolution and a linear bottleneck structure. To address the issue of small caps in unopened enoki mushrooms, which are easily missed during detection, a Feature Pyramid Network (FPN) is connected after the lightweight backbone. Through a top-down path and lateral connections, the deep semantic features used to locate large overlapping areas are deeply fused with the shallow high-resolution features used to accurately delineate the edges of small caps and stems. S1312. Lightweight backbone cascaded CBAM hybrid attention mechanism enhances anti-interference capability. During forward propagation, the feature map first passes through the Channel Attention module. The system adaptively learns and amplifies the channel weights that are sensitive to "fungus texture" and "color hue" through global average pooling and max pooling, while suppressing the feature weights of the background rubber material. Subsequently, the feature map enters the Spatial Attention module. The algorithm calculates the weight distribution in the spatial dimension, forcing the neural network to concentrate more computing power on the "stipe edge contour" and the "spatial boundary between the cap and stipe." This segmented, serial attention enhancement mechanism enables the model to accurately extract the contour boundaries of each individual fungus even when faced with high-density, crowded fungal samples. S1313. Loss Function and Topology Reconstruction Introducing the Dice Loss joint loss function L based on Intersection over Union (IoU). total Its core mathematical calculation formula is as follows: ; The specific meanings and calculation methods of each symbol are as follows: L BCE Binary cross-entropy loss: Calculates the cross-entropy between the predicted and labeled values ​​independently for each pixel in the mask image, focusing on single-pixel classification accuracy. ; Prediction mask matrix: The probability matrix output by the model after Sigmoid activation. , which represents the predicted probability that each pixel belongs to the foreground (bacterial cell).

[0013] Y-real mask matrix: a binary mask matrix with manual pixel-level annotations. , where 1 represents the bacterial cell region and 0 represents the background.

[0014] L Dice Dice loss: Measures the degree of agreement between the predicted mask and the real mask from the perspective of overall region overlap, and imposes a stronger penalty on global structural defects such as mask breaks and holes. ; α and β are dynamic balancing coefficients: they control the relative weights of the two loss terms in the total loss. In the early training phase (Epochs 1-50), α=0.7 and β=0.3 are set, with binary cross-entropy driving rapid convergence. In the later training phase (Epoch 51 and onwards), α=0.4 and β=0.6 are switched to increase the weight of the Dice penalty and refine the global topology of the mask. In practice, the optimal combination can be determined through grid search on the validation set.

[0015] ε, smoothing constant: value This prevents numerical overflow caused by the denominator being zero when both the predicted mask and the true mask are empty.

[0016] When the stipe mask predicted by the network shows breaks and holes, the molecule The denominator remains essentially unchanged while the value shrinks dramatically, resulting in L Dice When the gradient approaches 1, a large penalty is imposed on the broken region during gradient reversal, thereby driving the network to continuously optimize the global connectivity of the mask and ensuring that the stipe projection region used for area integration remains intact.

[0017] S1314. Prior Dataset Construction and Dynamic Closed-Loop Fine-Tuning Private Feature Set Annotation: On a real production line, RGB images of enoki mushrooms spanning multiple batches with different light intensities and tray loading densities were collected to construct a prior dataset containing tens of thousands of independent strains. High-precision pixel-level polygon annotations were then performed, strictly distinguishing between Cap and Stalk labels.

[0018] Targeted data augmentation: Considering the high-speed movement of the conveyor belt, Gaussian blur and motion blur noise are artificially injected into the clean image during training, and multi-angle affine transformation and contrast perturbation are performed to force the model to learn robust features against blur.

[0019] Transfer Learning and Adaptive Evolution: Utilizing transfer learning techniques, the pre-trained weights of the model on a public dataset are used as a starting point. Cosine annealing is employed for deep fine-tuning, ultimately resulting in an improved Mask R-CNN deep learning model. This application is used in industrial high-speed assembly line sorting scenarios. The unique biological morphology of enoki mushrooms presents significant challenges to traditional machine vision. On one hand, enoki mushrooms grow in clusters, with severe cross-occlusion and spatial overlap between individuals; on the other hand, their slender and irregular shape makes traditional instance segmentation algorithms prone to misjudgments such as blurred edges, target adhesion, and even "stalk breakage" when extracting masks. To completely solve these pain points and meet the stringent requirements of microsecond-level computation for edge computing units, this invention deeply reconstructs and improves the underlying structure and algorithms of the standard Mask R-CNN network architecture.

[0020] S132. Extract effective feature pixels; By iterating through both mask matrices and integrating and summing the effective pixels in the two-dimensional space, the projected area of ​​the target under the camera's field of view can be accurately obtained. Its mathematical expression is: ; ; S133. Pixel Area Ratio Parameter Calculation Based on the extracted actual projected area, the system performs a ratio calculation and outputs the dimensionless core determination parameter—the pixel area ratio of the cap to the stipe (…). ): ; Biological principle mapping: When enoki mushrooms are in their unopened state, their caps are compact. The value is extremely small; as maturity increases (umbrella opens), the cap spreads horizontally while the projected area of ​​the stipe remains basically constant, and this ratio shows a significant upward trend.

[0021] S134. Defect Feature-Assisted Extraction: Extract the HSV color vector from the global image and calculate the total number of pixels in the dark spots or browning areas on the surface. And calculate the defect percentage. : ; S135. Final Classification get and defect tolerance threshold ( The above calculation results are then hard-mapped to physical actions: Premium grade, G final =4: When satisfied and When the system determines that the cap is not open, upright, and white with no disease spots, it outputs a special grade sorting instruction.

[0022] Grade A, G final =3: When satisfied and When the system determines that there is slight opening of the umbrella but the overall shape meets the standard, it outputs a first-level sorting instruction.

[0023] Grade II, G final =2: When satisfied Slight browning may be present. When the product is found to be substandard, the system classifies it as a second-grade product.

[0024] Substandard products (rejected), G final =1: When satisfied (Severe umbrella opening) or When there is severe rot / disease, a veto mechanism is triggered, and an instruction to reject substandard products is directly output.

[0025] Preferably, the Feature Pyramid Network (FPN) is connected after the lightweight backbone in the following manner: Let the multi-layer feature map output by the MobileNetV3 lightweight backbone be... The corresponding downsampling step sizes are {4, 8, 16, 32} pixels, and the fusion is performed according to the following steps: (a) Lateral Connection: For each layer of backbone features Channel alignment was performed using 1×1 convolution, and the dimensions were uniformly compressed to 256 to obtain the lateral features. : , ; (b) Top-down upsampling fusion: from the deepest layer Initially, the layers are fused sequentially upwards. Nearest neighbor interpolation is used to double the spatial resolution, and element-wise addition with the horizontal features of the same layer is performed before 3×3 convolution to eliminate upsampling artifacts. , ; The addition operation deeply fuses the semantic features of large overlapping regions in the deep layers with the high-resolution detail features in the shallow layers, enabling the output features at each scale to be combined. It possesses both semantic discrimination capability and spatial positioning accuracy.

[0026] (c) Small target enhancement layer To address the issue of unopened enoki mushroom caps with a diameter less than 20 pixels (at 640×640 input) being easily missed during detection, in... Based on this, an additional upsampling is performed to obtain an ultra-high resolution feature layer with a stride of 2: ; The layers correspond to the anchor scale (32×32) of the Region Proposal Network (RPN), improving the recall rate of small targets and ensuring accurate segmentation of the small cap and stipe edges.

[0027] Preferably, the lightweight backbone cascaded CBAM hybrid attention mechanism is implemented as follows: CBAM consists of a channel attention module and a spatial attention module connected in series, which are used to process the input feature map. The process is repeated sequentially, resulting in a double-enhanced feature map. .

[0028] (a) Channel attention module Mc(F): Performs global average pooling and global max pooling on the feature map F respectively, feeds the two results into the same shared MLP (two fully connected layers, number of hidden nodes C / r, r=16), adds them element by element, and then activates them with Sigmoid to generate the channel weight vector: ; ;

[0029] in This indicates channel-by-channel multiplicative broadcasting. This step adaptively amplifies the channel weights that are sensitive to "cell texture" and "color chroma" while suppressing the rubber tray background feature channels.

[0030] (b) Spatial attention module Ms: for channel-enhanced feature maps The mean and maximum values ​​are calculated along the channel dimension, and then concatenated along the channel dimension to form a two-channel feature map. This feature map is then processed by a 7×7 depthwise convolution and sigmoid activation to generate a spatial weight map. ; ; in For channel splicing, For a 7×7 convolution with a large receptive field (covering the entire length of the stipe), the Sigmoid output is an H×W single-channel spatial weight map. This step drives the neural network to concentrate more computing power on the "stipe edge contour" and the "spatial boundary between the cap and stipe", accurately stripping the contour boundaries of individual individuals in high-density, crowded samples.

[0031] (c) Parameter description: CBAM introduces very few additional parameters (only about 0.1% of the backbone parameters), but it is effective for instance segmentation in crowded enoki mushroom scenarios. It can improve by approximately 3.8 percentage points (based on internal ablation experiments).

[0032] Preferably, for products identified as golden ear fungus, the following steps are followed for grading: S231. Multimodal data synchronization locking and feature extraction Within the same extremely short time window, the system simultaneously locks onto two sets of underlying data. First, it extracts the dynamic weight data W (unit: grams) from the micro-scale; second, it analyzes the apparent texture image from the high-resolution camera and calculates the maximum circumscribed circle diameter D of the earpiece on the two-dimensional projection plane using an edge contour detection algorithm. ear ; S232. Multidimensional benchmark mapping of physical form To address the dual requirements of weight and size for golden ear mushrooms, a joint step mapping function based on the "barrel effect" is constructed. Weight baseline levels are calculated separately. and diameter reference level The minimum value between the two is taken as the physical base level. (That is, if any one item fails to meet the standard, the entire grade will be downgraded): ; Weight sub-class Step mapping (based on the high-density physical properties of gold ear): ; Diameter sub-level Step mapping: =4 ( 10cm), =3 (8cm) 10cm), =2 (5cm) 8cm), =1 ( 5cm).

[0033] S233. Visual Quantization and Weighted Scoring The image is converted to the HSV color space, and the saturation mean is extracted and normalized to obtain the color score. (Characteristics: golden or light in color); Surface dark spots, damage, and contour distortion features are extracted using a defect detection algorithm to calculate the surface integrity score. A linear weighted average is used to obtain the overall visual score. : ; S234. Dynamic degradation error prevention mechanism Using the comprehensive visual score S vision For the benchmark level A veto-response constraint is applied. If the visual score falls below a preset threshold... If a minor flaw or slightly lighter color is detected, the degradation formula will be triggered. If severe lesions or mold are detected, the item will be forcibly removed from the list. ; S235. Final Classification Based on the final calculated comprehensive score G final Strictly match the physical execution actions of the tiered exits: Premium grade (corresponding to) The system determined that the target was extremely large (diameter greater than 10cm and single flower weight). 250g), and with an extremely high visual score (golden color, full and undamaged), a super-grade push rod command was issued.

[0034] Grade 1 product (corresponding to) ): The system determines that the physical indicators are in the core high-quality range (diameter 8-10cm and weight 200-250g); or although the physical size reaches the special grade, there are slight defects in the visual surface (such as slightly lighter color), and the algorithm triggers the downgrade mechanism and issues a first-level push rod command.

[0035] Grade II (corresponding to) ): If the system determines that the physical indicators are moderate (diameter 5-8cm and weight 100-200g); or if the visual judgment indicates that there are local defects, it will be downgraded from the previous level and a second-level push rod command will be issued.

[0036] Substandard products / rejection (corresponding to) The system determines that the physical indicators are severely insufficient (immature specimens with a diameter less than 5cm or a weight less than 100g); or the visual algorithm detects serious fatal defects in the target such as deformity, breakage, lesions, or mold, triggering a veto mechanism to prevent errors. The push lever action is not executed, and the specimen flows naturally with the conveyor belt to the end of the off-product collection box. This application addresses the industry pain point that a single modality cannot simultaneously consider both "physical density (weight)" and "sensory color" for the grading of golden ear fungus, enabling more accurate grading.

[0037] Preferably, it also includes a sorting conveyor belt, with several pneumatic push rods arranged on the side of the sorting conveyor belt, and corresponding grade collection boxes arranged on the side of the sorting conveyor belt; the pneumatic push rods are controlled by an electronic control system, and the electronic control system adopts a hard real-time event-driven communication protocol based on industrial Ethernet. S41. Data Frame Encapsulation When obtained Immediately afterwards, a structured "sorting control data frame" is generated; this data frame contains: [Start symbol | Absolute timestamp T] stamp Material Tracking Identifier Serial Number ID tray | Overall rating result G final | CRC checksum]; S42. Data Frame Transmission and Interrupt Response Data frames are transmitted to the lower-level PLC via a high-speed bus. Upon receiving the data packet, the PLC triggers a hardware-level receive interrupt for rapid parsing. and the material The ranking results are pushed into the high-speed shift register (FIFO queue) inside the PLC, waiting for physical tracking mapping.

[0038] S43. Dynamic displacement tracking based on encoder spatiotemporal mapping Because the conveyor belt's operating speed v fluctuates slightly, the system does not rely on a simple time delay for control, but instead constructs an "electronic cam (E-Cam)" tracking model based on position pulses.

[0039] Pulse equivalent calibration: A high-resolution incremental rotary encoder is coaxially mounted on the main drive roller of the sorting conveyor belt. Let the roller diameter be D, and the encoder's single-turn resolution be... The pulse equivalent generated per unit distance traveled by the conveyor belt satisfy: ; Dynamic tracking queue initialization: Assume a material placement photoelectric sensor is installed at the exit of the detection box. When the pallet carrying the material triggers this sensor (marked as...) At any given moment, the PLC immediately retrieves the corresponding tray from the FIFO queue. And allocate a separate pulse counter for this tray in memory. The initial value is set to 0.

[0040] Target pulse calculation: Let the physical distance from the reference position of the photoelectric sensor to the center line of the pneumatic push rod of the collection channel corresponding to level i be . The system calculates the total number of target pulses required for the tray to reach the target channel. : .

[0041] S44. Dynamic displacement tracking based on encoder spatiotemporal mapping During high-speed operation, the response of the pneumatic solenoid valve, the inflation of the cylinder, and the mechanical extension of the push rod all require time. If the command is issued only when the tray is completely aligned with the push rod, it will inevitably lead to "push misalignment" or "missed push". Therefore, a feedforward hysteresis compensation algorithm is embedded in the PLC.

[0042] Total system latency measurement: The system is pre-calibrated and the total latency from the issuance of the command to the contact tray of the push rod is calculated. : ; in For PLC scan cycle, This refers to the solenoid valve's switching response time. The cylinder extension stroke time; Early trigger pulse compensation: Based on the instantaneous linear velocity v of the current conveyor belt, the system calculates the advance distance the tray will move during the lag time. Based on this, the PLC dynamically corrects the actual trigger pulse threshold. : ; High-speed physical execution: As the conveyor belt runs, the counter of the tray... Strictly equal to the corrected At that moment, the PLC's high-speed I / O module instantly outputs a drive level, activating the high-frequency pilot-operated solenoid valve of the corresponding channel. The pneumatic push rod extends precisely, using its flexible contact end to smoothly push the tray into the corresponding collection channel. Once the push rod is in place, it triggers a magnetic switch, and the system automatically controls the solenoid valve to reset, completing a single execution cycle.

[0043] It also includes the following security policies: Default security policy (Fail-Safe rejection mechanism): Trays that do not match any channel pulse threshold, or those that were not received due to communication packet loss. The system does not perform any push lever action on the pallet; the pallet will automatically move with the conveyor belt to the "Substandard / Re-inspection Error-proof Collection Box" at the very end, completely preventing defective products from being mixed into the qualified product warehouse.

[0044] Pneumatic actuator stall monitoring: If the feedback signal of cylinder retraction limit is not received within a specified time (e.g., 500ms) after the push rod extends, the PLC will determine that mechanical jamming has occurred, immediately cut off the power supply of the solenoid valve of the channel, trigger the system's audible and visual alarm, and suspend the upstream feed conveyor belt.

[0045] Queue overflow prevention control: When the number of unexecuted materials in the FIFO queue approaches the register limit, or the encoder pulse signal is lost, the PLC starts the emergency stop interrupt routine to ensure absolute consistency between system data and physical state.

[0046] This application can bring the following beneficial effects: 1. This application utilizes the significant identifiable differences in morphological characteristics between enoki mushrooms and golden ear fungus. Enoki mushrooms are clustered and bundled, with an overall outline of vertical stripes whose long axis is significantly larger than its short axis. Their color is mainly off-white or light yellow, and their texture is fine and linear. Golden ear fungus, on the other hand, is single and blocky, with an overall outline that is close to round. Its color is distinctly orange-yellow to golden yellow, and its surface texture is rough and wrinkled. This method is used for quantitative classification, which yields good classification results and a low error rate.

[0047] 2. This application is applied to high-speed industrial assembly line sorting scenarios. The unique biological morphology of enoki mushrooms presents significant challenges to traditional machine vision. On one hand, enoki mushrooms grow in clusters, resulting in severe cross-occlusion and spatial overlap between individuals; on the other hand, their slender and irregular shape makes traditional instance segmentation algorithms prone to misjudgments such as blurred edges, target adhesion, and even "stalk breakage" when extracting masks. To completely solve these problems and meet the stringent requirements of microsecond-level computation for edge computing units, this invention deeply reconstructs and improves the underlying structure and algorithms of the standard Mask R-CNN network architecture.

[0048] 3. This application's grading of golden ear fungus can solve the industry pain point that a single modality cannot simultaneously take into account its "physical density (weight)" and "sensory color", and can achieve more accurate grading. Attached Figure Description

[0049] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a flowchart illustrating the process of this application; Figure 2 A schematic diagram showing the morphological segmentation and area ratio of enoki mushrooms; Figure 3 This is a schematic diagram illustrating the lightweight backbone reconstruction of the feature extraction in the Mask R-CNN deep learning model. Figure 4 This is a schematic diagram of a rubber pallet. Detailed Implementation

[0050] To clearly illustrate the technical features of this solution, the following detailed description, in conjunction with the accompanying drawings, will be provided.

[0051] like Figure 1-4 As shown, a method for grading the apparent weight of both enoki mushrooms and golden ear fungus includes the following steps: S1. Obtain the detection image of the material to be tested; The detection image of the material to be tested is obtained in the following manner: Place the material to be tested into the rubber tray and then put it into the collection dark box; The acquisition dark box includes a detection conveyor belt at the bottom, an industrial camera for acquiring detection images is set above the detection conveyor belt, and an LED ring light source is set outside the corresponding industrial camera. A weighing support is installed below the conveyor belt for inspection.

[0052] like Figure 4 As shown, the rubber tray 1 is provided with several arc-shaped grooves 2, and rubber ribs 3 are provided at the bottom of the arc-shaped grooves 2.

[0053] S2. Perform pre-recognition based on the detected image to obtain the product type; S21. Pre-screening of outline aspect ratio: The detected image is converted into an RGB image, binarized, and the overall bounding rectangle of the sample is extracted. The aspect ratio R is then calculated. aspect = Major axis / Minor axis. If R... aspect If R ≥ 2.0, it is determined to be enoki mushroom; if R aspect If the color value is less than 2.0, proceed to step two for color verification. S22.HSV Color Feature Verification: Convert the image to the HSV color space and extract the tonal mean of the sample area. H With the mean saturationS The typical color gamut of golden ear fungus is orange-yellow, H∈[15°,40°], S≥0.5, while the color gamut of enoki mushroom is white to light yellow. Or S < 0.3. If the color characteristics match the color gamut of *Euryale ferox*, it is ultimately determined to be *Euryale ferox*; otherwise, it is determined to be *Enoki mushroom*. If the color characteristics match the color gamut of golden ear fungus, it is ultimately determined to be golden ear fungus; otherwise, it is determined to be enoki mushroom.

[0054] S23. Confidence Arbitration of Deep Learning Models: When the morphological and color features extracted in step one or step two result in insufficient confidence in the rule judgment due to abnormal lighting, sample contamination, or atypical morphology, i.e., the maximum softmax probability output by MobileNetV3 is lower than the preset threshold P, th When the sample is marked as "low confidence pending verification", the system will trigger the conveyor belt to pause or slow down, and issue an audio-visual prompt on the operation interface. The operator will then manually confirm the information once. At the same time, the feature data will be automatically archived into the model's continuous learning database for subsequent closed-loop optimization iterations of the model.

[0055] The preset threshold P th The calibration should be performed as follows: (a) Construction of validation set: In the real collection environment of the production line, a private validation set containing more than 500 images each of enoki mushroom and golden ear fungus, covering various light intensities and sample states, was constructed and manually labeled frame by frame. (b) ROC and Curve analysis: Let MobileNetV3 output the Softmax maximum probability value p for the validation set samples. max The algorithm iterates through the candidate threshold interval [0.70, 0.95] (step size 0.01) and calculates the Precision, Recall, and... for each threshold. Score and plot the corresponding curve. Select The threshold corresponding to the peak score is used as P. th : , ; (c) Experimental conclusion: Experimental data show that when p max When p < 0.85, the actual classification accuracy of the model drops to approximately 87%, which is below the acceptable lower limit of the system (95%); when p max When the accuracy is ≥ 0.85, the accuracy rate remains stable above 98.6%. On the validation set, hour The score reached a peak of 0.982, therefore P was ultimately determined. h = 0.85 is used as the critical threshold for triggering manual review.

[0056] S3. Determine product quality based on product type, and finally complete the classification; For products identified as enoki mushrooms, the following steps will be followed for grading: S131. Acquire the detection images and perform end-to-end instance segmentation using the modified Mask R-CNN deep learning model: S1311. Lightweight backbone reconstruction for feature extraction in Mask R-CNN deep learning models: The original ResNet backbone is replaced with the lightweight MobileNetV3 network, and a lightweight backbone is obtained by introducing depthwise separable convolution and a linear bottleneck structure. To address the issue of small caps in unopened enoki mushrooms, which are easily missed during detection, a Feature Pyramid Network (FPN) is connected after the lightweight backbone. Through a top-down path and lateral connections, the deep semantic features used to locate large overlapping areas are deeply fused with the shallow high-resolution features used to accurately delineate the edges of small caps and stems. The specific steps for connecting the Feature Pyramid Network (FPN) after the lightweight backbone are as follows: Let the multi-layer feature map output by the MobileNetV3 lightweight backbone be... The corresponding downsampling step sizes are {4, 8, 16, 32} pixels, and the fusion is performed according to the following steps: (a) Lateral Connection: For each layer of backbone features Channel alignment was performed using 1×1 convolution, and the dimensions were uniformly compressed to 256 to obtain the lateral features. : , ; (b) Top-down upsampling fusion: from the deepest layer Initially, the layers are fused sequentially upwards. Nearest neighbor interpolation is used to double the spatial resolution, and element-wise addition with the horizontal features of the same layer is performed before 3×3 convolution to eliminate upsampling artifacts. , ; The addition operation deeply fuses the semantic features of large overlapping regions in the deep layers with the high-resolution detail features in the shallow layers, enabling the output features at each scale to be combined. It possesses both semantic discrimination capability and spatial positioning accuracy.

[0057] (c) Small target enhancement layer To address the issue of unopened enoki mushroom caps with a diameter less than 20 pixels (at 640×640 input) being easily missed during detection, in... Based on this, an additional upsampling is performed to obtain an ultra-high resolution feature layer with a stride of 2: ; The layers correspond to the anchor scale (32×32) of the Region Proposal Network (RPN), improving the recall rate of small targets and ensuring accurate segmentation of the small cap and stipe edges.

[0058] S1312. Lightweight backbone cascaded CBAM hybrid attention mechanism enhances anti-interference capability. During forward propagation, the feature map first passes through the Channel Attention module. The system adaptively learns and amplifies the channel weights that are sensitive to "fungus texture" and "color hue" through global average pooling and max pooling, while suppressing the feature weights of the background rubber material. Subsequently, the feature map enters the Spatial Attention module. The algorithm calculates the weight distribution in the spatial dimension, forcing the neural network to concentrate more computing power on the "stipe edge contour" and the "spatial boundary between the cap and stipe." This segmented, serial attention enhancement mechanism enables the model to accurately extract the contour boundaries of each individual fungus even when faced with high-density, crowded fungal samples. CBAM consists of a channel attention module and a spatial attention module connected in series, which are used to process the input feature map. The process is repeated sequentially, resulting in a double-enhanced feature map. .

[0059] (a) Channel attention module Mc(F): Performs global average pooling and global max pooling on the feature map F respectively, feeds the two results into the same shared MLP (two fully connected layers, number of hidden nodes C / r, r=16), adds them element by element, and then activates them with Sigmoid to generate the channel weight vector: ; ; in This indicates channel-by-channel multiplicative broadcasting. This step adaptively amplifies the channel weights that are sensitive to "cell texture" and "color chroma" while suppressing the rubber tray background feature channels.

[0060] (b) Spatial attention module Ms: for channel-enhanced feature maps The mean and maximum values ​​are calculated along the channel dimension, and then concatenated along the channel dimension to form a two-channel feature map. This feature map is then processed by a 7×7 depthwise convolution and sigmoid activation to generate a spatial weight map. ; ; in For channel splicing, For a 7×7 convolution with a large receptive field (covering the entire length of the stipe), the Sigmoid output is an H×W single-channel spatial weight map. This step drives the neural network to concentrate more computing power on the "stipe edge contour" and the "spatial boundary between the cap and stipe", accurately stripping the contour boundaries of individual individuals in high-density, crowded samples.

[0061] (c) Parameter description: CBAM introduces very few additional parameters (only about 0.1% of the backbone parameters), but it is effective for instance segmentation in crowded enoki mushroom scenarios. It can improve by approximately 3.8 percentage points (based on internal ablation experiments).

[0062] S1313. Loss Function and Topology Reconstruction Introducing the Dice Loss joint loss function L based on Intersection over Union (IoU). total Its core mathematical calculation formula is as follows: ; The specific meanings and calculation methods of each symbol are as follows: L BCE Binary cross-entropy loss: Calculates the cross-entropy between the predicted and labeled values ​​independently for each pixel in the mask image, focusing on single-pixel classification accuracy. ; Prediction mask matrix: The probability matrix output by the model after Sigmoid activation. , which represents the predicted probability that each pixel belongs to the foreground (bacterial cell).

[0063] Y-real mask matrix: a binary mask matrix with manual pixel-level annotations. , where 1 represents the bacterial cell region and 0 represents the background.

[0064] L Dice Dice loss: Measures the degree of agreement between the predicted mask and the real mask from the perspective of overall region overlap, and imposes a stronger penalty on global structural defects such as mask breaks and holes. ; α and β are dynamic balancing coefficients: they control the relative weights of the two loss terms in the total loss. In the early training phase (Epochs 1-50), α=0.7 and β=0.3 are set, with binary cross-entropy driving rapid convergence. In the later training phase (Epoch 51 and onwards), α=0.4 and β=0.6 are switched to increase the weight of the Dice penalty and refine the global topology of the mask. In practice, the optimal combination can be determined through grid search on the validation set.

[0065] ε, smoothing constant: value This prevents numerical overflow caused by the denominator being zero when both the predicted mask and the true mask are empty.

[0066] When the stipe mask predicted by the network shows breaks and holes, the molecule The denominator remains essentially unchanged while the value shrinks dramatically, resulting in L Dice When the gradient approaches 1, a large penalty is imposed on the broken region during gradient reversal, thereby driving the network to continuously optimize the global connectivity of the mask and ensuring that the stipe projection region used for area integration remains intact.

[0067] S1314. Prior Dataset Construction and Dynamic Closed-Loop Fine-Tuning Private Feature Set Annotation: On a real production line, RGB images of enoki mushrooms spanning multiple batches with different light intensities and tray loading densities were collected to construct a prior dataset containing tens of thousands of independent strains. High-precision pixel-level polygon annotations were then performed, strictly distinguishing between Cap and Stalk labels.

[0068] Targeted data augmentation: Considering the high-speed movement of the conveyor belt, Gaussian blur and motion blur noise are artificially injected into the clean image during training, and multi-angle affine transformation and contrast perturbation are performed to force the model to learn robust features against blur.

[0069] Transfer learning and adaptive evolution: Using transfer learning techniques, the pre-trained weights of the model on a public dataset are used as the starting point, and a cosine annealing strategy is used for deep fine-tuning to finally obtain an improved MaskR-CNN deep learning model.

[0070] S132. Extract effective feature pixels; By iterating through both mask matrices and integrating and summing the effective pixels in the two-dimensional space, the projected area of ​​the target under the camera's field of view can be accurately obtained. Its mathematical expression is: ; ; S133. Pixel Area Ratio Parameter Calculation Based on the extracted actual projected area, the system performs a ratio calculation and outputs the dimensionless core determination parameter—the pixel area ratio of the cap to the stipe (…). ): ; Biological principle mapping: When enoki mushrooms are in their unopened state, their caps are compact. The value is extremely small; as maturity increases (umbrella opens), the cap spreads horizontally while the projected area of ​​the stipe remains basically constant, and this ratio shows a significant upward trend.

[0071] S134. Defect Feature-Assisted Extraction: Extract the HSV color vector from the global image and calculate the total number of pixels in the dark spots or browning areas on the surface. And calculate the defect percentage. : ; S135. Final Classification get and defect tolerance threshold ( The above calculation results are then hard-mapped to physical actions: Premium grade, G final =4: When satisfied and When the system determines that the cap is not open, upright, and white with no disease spots, it outputs a special grade sorting instruction.

[0072] Grade A, G final =3: When satisfied and When the system determines that there is slight opening of the umbrella but the overall shape meets the standard, it outputs a first-level sorting instruction.

[0073] Grade II, G final =2: When satisfied Slight browning may be present. When the product is found to be substandard, the system classifies it as a second-grade product.

[0074] Substandard products, removed, G final =1: When satisfied (Severe umbrella opening) or When there is severe rot / disease, a veto mechanism is triggered, and an instruction to reject substandard products is directly output.

[0075] For products identified as "golden ear" products, the following steps will be followed for grading: S231. Multimodal data synchronization locking and feature extraction Within the same extremely short time window, the system simultaneously locks onto two sets of underlying data. First, it extracts the dynamic weight data W (unit: grams) from the micro-scale; second, it analyzes the apparent texture image from the high-resolution camera and calculates the maximum circumscribed circle diameter D of the earpiece on the two-dimensional projection plane using an edge contour detection algorithm. ear ; S232. Multidimensional benchmark mapping of physical form To address the dual requirements of weight and size for golden ear mushrooms, a joint step mapping function based on the "barrel effect" is constructed. Weight baseline levels are calculated separately. and diameter reference level The minimum value between the two is taken as the physical base level. (That is, if any one item fails to meet the standard, the entire grade will be downgraded): ; Weight sub-class Step mapping (based on the high-density physical properties of gold ear): ; Diameter sub-level Step mapping: =4 ( 10cm), =3 (8cm) 10cm), =2 (5cm) 8cm), =1 ( 5cm).

[0076] S233. Visual Quantization and Weighted Scoring The image is converted to the HSV color space, and the saturation mean is extracted and normalized to obtain the color score. (Characteristics: golden or light in color); Surface dark spots, damage, and contour distortion features are extracted using a defect detection algorithm to calculate the surface integrity score. A linear weighted average is used to obtain the overall visual score. : ; S234. Dynamic degradation error prevention mechanism Using the comprehensive visual score S vision For the benchmark level A veto-response constraint is applied. If the visual score falls below a preset threshold... If a minor flaw or slightly lighter color is detected, the degradation formula will be triggered. If severe lesions or mold are detected, the item will be forcibly removed from the list. ; S235. Final Classification Based on the final calculated comprehensive score G final Strictly match the physical execution actions of the tiered exits: Premium grade (corresponding to) The system determined that the target was extremely large (diameter greater than 10cm and single flower weight). 250g), and with an extremely high visual score (golden color, full and undamaged), a super-grade push rod command was issued.

[0077] Grade 1 product (corresponding to) ): The system determines that the physical indicators are in the core high-quality range (diameter 8-10cm and weight 200-250g); or although the physical size reaches the special grade, there are slight defects in the visual surface (such as slightly lighter color), and the algorithm triggers the downgrade mechanism and issues a first-level push rod command.

[0078] Grade II (corresponding to) ): If the system determines that the physical indicators are moderate (diameter 5-8cm and weight 100-200g); or if the visual judgment indicates that there are local defects, it will be downgraded from the previous level and a second-level push rod command will be issued.

[0079] Substandard products / rejection (corresponding to) If the system determines that the physical indicators are seriously insufficient (immature body with a diameter of less than 5cm or a weight of less than 100g); or if the visual algorithm detects that the target has serious fatal defects such as deformity, breakage, disease spots or mold, it will trigger a veto mechanism to prevent the push rod action from being executed, and the target will flow naturally with the conveyor belt to the end of the foreign product collection box.

[0080] S4 electronic control system control It also includes a sorting conveyor belt, with several pneumatic push rods installed on the side of the sorting conveyor belt, and corresponding grade collection boxes installed on the side of the sorting conveyor belt; the pneumatic push rods are controlled by an electronic control system, which adopts a hard real-time event-driven communication protocol based on industrial Ethernet. S41. Data Frame Encapsulation When obtained Immediately afterwards, a structured "sorting control data frame" is generated; this data frame contains: [Start symbol | Absolute timestamp T] stamp Material Tracking Identifier Serial Number ID tray | Overall rating result G final | CRC checksum]; S42. Data Frame Transmission and Interrupt Response Data frames are transmitted to the lower-level PLC via a high-speed bus. Upon receiving the data packet, the PLC triggers a hardware-level receive interrupt for rapid parsing. and the material The ranking results are pushed into the high-speed shift register (FIFO queue) inside the PLC, waiting for physical tracking mapping.

[0081] S43. Dynamic displacement tracking based on encoder spatiotemporal mapping Because the conveyor belt's operating speed v fluctuates slightly, the system does not rely on a simple time delay for control, but instead constructs an "electronic cam (E-Cam)" tracking model based on position pulses.

[0082] Pulse equivalent calibration: A high-resolution incremental rotary encoder is coaxially mounted on the main drive roller of the sorting conveyor belt. Let the roller diameter be D, and the encoder's single-turn resolution be... The pulse equivalent generated per unit distance traveled by the conveyor belt satisfy: ; Dynamic tracking queue initialization: Assume a material placement photoelectric sensor is installed at the exit of the detection box. When the pallet carrying the material triggers this sensor (marked as...) At any given moment, the PLC immediately retrieves the corresponding tray from the FIFO queue. And allocate a separate pulse counter for this tray in memory. The initial value is set to 0.

[0083] Target pulse calculation: Let the physical distance from the reference position of the photoelectric sensor to the center line of the pneumatic push rod of the collection channel corresponding to level i be . The system calculates the total number of target pulses required for the tray to reach the target channel. : .

[0084] S44. Dynamic displacement tracking based on encoder spatiotemporal mapping During high-speed operation, the response of the pneumatic solenoid valve, the inflation of the cylinder, and the mechanical extension of the push rod all require time. If the command is issued only when the tray is completely aligned with the push rod, it will inevitably lead to "push misalignment" or "missed push". Therefore, a feedforward hysteresis compensation algorithm is embedded in the PLC.

[0085] Total system latency measurement: The system is pre-calibrated and the total latency from the issuance of the command to the contact tray of the push rod is calculated. : ; in For PLC scan cycle, This refers to the solenoid valve's switching response time. The cylinder extension stroke time; Early trigger pulse compensation: Based on the instantaneous linear velocity v of the current conveyor belt, the system calculates the advance distance the tray will move during the lag time. Based on this, the PLC dynamically corrects the actual trigger pulse threshold. : ; High-speed physical execution: As the conveyor belt runs, the counter of the tray... Strictly equal to the corrected At that moment, the PLC's high-speed I / O module instantly outputs a drive level, activating the high-frequency pilot-operated solenoid valve of the corresponding channel. The pneumatic push rod extends precisely, using its flexible contact end to smoothly push the tray into the corresponding collection channel. Once the push rod is in place, it triggers a magnetic switch, and the system automatically controls the solenoid valve to reset, completing a single execution cycle.

[0086] It also includes the following security policies: Default security policy (Fail-Safe rejection mechanism): Trays that do not match any channel pulse threshold, or those that were not received due to communication packet loss. The system does not perform any push lever action on the pallet; the pallet will automatically move with the conveyor belt to the "Substandard / Re-inspection Error-proof Collection Box" at the very end, completely preventing defective products from being mixed into the qualified product warehouse.

[0087] Pneumatic actuator stall monitoring: If the feedback signal of cylinder retraction limit is not received within a specified time (e.g., 500ms) after the push rod extends, the PLC will determine that mechanical jamming has occurred, immediately cut off the power supply of the solenoid valve of the channel, trigger the system's audible and visual alarm, and suspend the upstream feed conveyor belt.

[0088] Queue overflow prevention control: When the number of unexecuted materials in the FIFO queue approaches the register limit, or the encoder pulse signal is lost, the PLC starts the emergency stop interrupt routine to ensure absolute consistency between system data and physical state.

[0089] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for grading enoki mushrooms and golden ear mushrooms by apparent weight, characterized in that: Includes the following steps: S1. Obtain the detection image of the material to be tested; S2. Perform pre-recognition based on the detected image to obtain the product type; S3. Determine product quality based on product type, and finally complete the classification; For products identified as enoki mushrooms, the following steps will be followed for grading: S131. Acquire the detection images and perform end-to-end instance segmentation using the modified Mask R-CNN deep learning model: S132. Extract effective feature pixels; S133. Pixel area ratio parameter calculation; S134. Defect Feature-Assisted Extraction: S135. Final classification; For products identified as "golden ear" products, the following steps will be followed for grading: S231. Multimodal data synchronization locking and feature extraction; S232. Multidimensional benchmark mapping of physical morphology; S233. Visual Quantification and Weighted Scoring; S234. Dynamic degradation error prevention mechanism; S235. Final classification.

2. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 1, characterized in that: The detection image of the material to be tested is obtained in the following manner: Place the material to be tested into the rubber tray and then put it into the collection dark box; The acquisition dark box includes a detection conveyor belt at the bottom, an industrial camera for acquiring detection images is set above the detection conveyor belt, and an LED ring light source is set outside the corresponding industrial camera. A weighing support is installed below the conveyor belt for inspection.

3. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 2, characterized in that: The rubber tray has several arc-shaped grooves inside, and rubber ribs are provided at the bottom of the arc-shaped grooves.

4. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 1, characterized in that: The product type is determined by pre-identification based on the detected image, following these steps: S21. Pre-screening of outline aspect ratio: The detected image is converted into an RGB image, binarized, and the overall bounding rectangle of the sample is extracted. The aspect ratio R is then calculated. aspect = Major axis / Minor axis; if R aspect If R ≥ 2.0, it is determined to be enoki mushroom; if R aspect If the color is less than 2.0, proceed to step two for color verification. S22.HSV Color Feature Verification: The image was converted to the HSV color space, and the mean hue (H) and mean saturation (S) of the sample region were extracted. The typical color gamut of *Auricularia auricula-judae* is orange-yellow, H∈[15°,40°], S≥0.5, while the color gamut of *Enoki mushroom* is white to light yellow. Or S<0.3; if the color characteristics match the color gamut of golden ear fungus, it is finally determined to be golden ear fungus; otherwise, it is determined to be enoki mushroom. If the color characteristics match the color gamut of golden ear fungus, it is ultimately determined to be golden ear fungus; otherwise, it is determined to be enoki mushroom. S23. Confidence Arbitration of Deep Learning Models: When the morphological and color features extracted in step one or step two result in insufficient confidence in the rule judgment due to abnormal lighting, sample contamination, or atypical morphology, i.e., the maximum softmax probability output by MobileNetV3 is lower than the preset threshold P, th When the sample is marked as "low confidence pending verification", the system will trigger the conveyor belt to pause or slow down, and issue an audio-visual prompt on the operation interface. The operator will then manually confirm the information once. At the same time, the feature data will be automatically archived into the model's continuous learning database for subsequent closed-loop optimization iterations of the model.

5. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 4, characterized in that: The preset threshold P th The calibration should be performed as follows: (a) Construction of validation set: In the real collection environment of the production line, a private validation set containing more than 500 images each of enoki mushroom and golden ear fungus, covering various light intensities and sample states, was constructed and manually labeled frame by frame. (b) ROC and Curve analysis: Let MobileNetV3 output the Softmax maximum probability value p for the validation set samples. max Within the candidate threshold range [0.70, 0.95], with a step size of 0.01, the Precision, Recall, and [other parameters] are calculated for each threshold. Score and plot the corresponding curve; Select The threshold corresponding to the peak score is used as ; ; (c) Experimental conclusion: Experimental data show that when p max When p < 0.85, the actual classification accuracy of the model drops to approximately 87%, which is lower than the system's acceptable lower limit of 95%; when p max When the accuracy is ≥ 0.85, the accuracy rate remains stable at over 98.6%; on the validation set, =0.85 The score reached a peak of 0.982, therefore P was ultimately determined. h = 0.85 is used as the critical threshold for triggering manual review.

6. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 1, characterized in that: For products identified as enoki mushrooms, the following steps are used for grading: S131. Acquire the detection images and perform end-to-end instance segmentation using the modified Mask R-CNN deep learning model: S1311. Lightweight backbone reconstruction for feature extraction in Mask R-CNN deep learning models: The original ResNet backbone is replaced with a lightweight MobileNetV3 network, and a lightweight backbone is obtained by introducing depthwise separable convolutions and linear bottleneck structures. To address the issue of small caps in unopened enoki mushrooms, which are easily missed during detection, a Feature Pyramid Network (FPN) is connected after the lightweight backbone. Through a top-down path and lateral connections, the deep semantic features used to locate large overlapping areas are deeply fused with the shallow high-resolution features used to accurately delineate the edges of small caps and stems. S1312. Lightweight backbone serial CBAM hybrid attention mechanism enhances anti-interference capability; During forward propagation of the model, the feature map first passes through the Channel Attention module. The system adaptively learns and amplifies the channel weights that are sensitive to "bacterial texture" and "color hue" through global average pooling and max pooling, while suppressing the feature weights of the background rubber material. Subsequently, the feature map enters the SpatialAttention module. The algorithm calculates the weight distribution of the spatial dimension, forcing the neural network to concentrate more computing power on the "stipe edge contour" and the "spatial junction between the cap and the stipe". This segmented and serial attention enhancement mechanism enables the model to accurately extract the contour boundary of each individual when faced with high-density and crowded fungal samples. S1313. Loss Function and Topology Reconstruction; Introducing the Dice Loss joint loss function L based on crossover-union ratio total The calculation formula is as follows: ; The specific meanings and calculation methods of each symbol are as follows: L BCE Binary cross-entropy loss: Calculates the cross-entropy between the predicted and labeled values ​​independently for each pixel in the mask image, focusing on single-pixel classification accuracy. ; Prediction mask matrix: The probability matrix output by the model after Sigmoid activation. , representing the predicted probability that each pixel belongs to a foreground bacterial cell; The true mask matrix Y: a binary mask matrix with manually annotated pixels Y ∈ {0,1} H×W , where 1 represents the bacterial cell region and 0 represents the background; L Dice Dice loss: Measures the degree of agreement between the predicted mask and the real mask from the perspective of overall region overlap, and imposes a stronger penalty on global structural defects such as mask breaks and holes. ; α and β are dynamic balancing coefficients: they control the relative weights of the two losses in the total loss; in the early stage of training, i.e., Epoch 1-50, α=0.7 and β=0.3 are set, and the binary cross-entropy is mainly used to drive fast convergence; in the later stage of training, i.e. after Epoch 51, α=0.4 and β=0.6 are switched to increase the proportion of Dice penalty and refine the global topology of the mask. ε, smoothing constant: value This prevents numerical overflow caused by the denominator being zero when both the predicted mask and the true mask are empty; When the stipe mask predicted by the network shows breaks and holes, the molecule The denominator remains essentially unchanged while the value shrinks dramatically, resulting in L Dice When the gradient approaches 1, a large penalty is imposed on the broken region during gradient reversal, thereby driving the network to continuously optimize the global connectivity of the mask and ensuring that the stipe projection region of the area integral is intact. S1314. Prior Dataset Construction and Dynamic Closed-Loop Fine-Tuning Private Feature Set Annotation: On a real production line, RGB images of enoki mushrooms spanning multiple batches, different light intensities, and tray loading densities were collected to construct a prior dataset containing tens of thousands of independent strains. High-precision pixel-level polygon annotations were performed, strictly distinguishing between Cap and Stalk labels. Targeted data augmentation: Considering the high-speed movement of the conveyor belt, Gaussian blur and motion blur noise are artificially injected into the clean image during training, and multi-angle affine transformation and contrast perturbation are performed to force the model to learn robust features against blur. Transfer learning and adaptive evolution: Using transfer learning techniques, the pre-trained weights of the model on a public dataset are used as the starting point, and cosine annealing strategy is used for deep fine-tuning to finally obtain an improved Mask R-CNN deep learning model. S132. Extract effective feature pixels; By iterating through the two mask matrices and integrating and summing the effective pixels in the two-dimensional space, the projected area of ​​the target under the camera's field of view can be accurately obtained; its mathematical expression is: ; ; S133. Pixel Area Ratio Parameter Calculation Based on the extracted actual projected area, the system performs ratio calculations and outputs the dimensionless core determination parameter—the pixel area ratio of the cap to the stipe. : ; Biological principle mapping: When enoki mushrooms are in their unopened state, their caps are compact. The value is extremely small; as maturity increases, the cap spreads laterally while the projected area of ​​the stipe remains basically constant, and this ratio shows a significant upward trend. S134. Defect Feature-Assisted Extraction: Extract the HSV color vector from the global image and calculate the total number of pixels in the dark spots or browning areas on the surface. And calculate the defect percentage. : ; S135. Final Classification get and defect tolerance threshold ( The above calculation results are then hard-mapped to physical actions: Premium grade, G final =4: and ; Grade A, G final =3: and ; Grade II, G final =2: or hour; Substandard products, G final =1: or hour.

7. The apparent weight grading method compatible with enoki mushrooms and golden ear fungus as described in claim 6, characterized in that: Specifically, the Feature Pyramid Network (FPN) is connected after the lightweight backbone in the following manner: Let the multi-layer feature map output by the MobileNetV3 lightweight backbone be... The corresponding downsampling step sizes are {4, 8, 16, 32} pixels, and the fusion is performed according to the following steps: (a) Lateral Connection: For each layer of backbone features Channel alignment was performed using 1×1 convolution, and the dimensions were uniformly compressed to 256 to obtain the lateral features. : ; (b) Top-down upsampling fusion: from the deepest layer Initially, the layers are fused sequentially upwards. Nearest neighbor interpolation is used to double the spatial resolution, and element-wise addition with the horizontal features of the same layer is performed before 3×3 convolution to eliminate upsampling artifacts. ; The addition operation deeply fuses the semantic features of large overlapping regions in the deep layers with the high-resolution detail features in the shallow layers, enabling the output features at each scale to be combined. It possesses both semantic discrimination capability and spatial positioning accuracy; (c) Small target enhancement layer To address the issue of unopened enoki mushroom caps with a diameter less than 20 pixels being easily missed in 640×640 input, in Based on this, an additional upsampling is performed to obtain an ultra-high resolution feature layer with a stride of 2: ; The anchor scale of the layer and the region proposal network (RPN) is 32×32, which improves the recall rate of small targets and ensures accurate segmentation of small cap and stipe edges.

8. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 6, characterized in that: The lightweight backbone cascaded CBAM hybrid attention mechanism is implemented as follows: CBAM consists of a channel attention module and a spatial attention module connected in series, which are used to process the input feature map. The process is repeated sequentially, resulting in a double-enhanced feature map. ; (a) Channel attention module Mc(F): Performs global average pooling and global max pooling on the feature map F respectively, feeds the two results into the same shared MLP, adds them element-wise, and then activates them with Sigmoid to generate the channel weight vector: ; ; in This indicates channel-wise multiplicative broadcasting; this step adaptively amplifies the channel weights that are sensitive to "cell texture" and "color chroma" while suppressing the rubber tray background feature channels. (b) Spatial attention module Ms: for channel-enhanced feature maps The mean and maximum values ​​are calculated along the channel dimension, and then concatenated along the channel dimension to form a two-channel feature map. This feature map is then processed by a 7×7 depthwise convolution and sigmoid activation to generate a spatial weight map. ; ; in For channel splicing, For a 7×7 convolution with a large receptive field (which can cover the entire length of the stipe), the Sigmoid output is a single-channel spatial weight map of size H×W. This step drives the neural network to concentrate more computing power on the "stipe edge contour" and the "spatial boundary between the cap and stipe", accurately stripping the contour boundary of individual individuals in high-density crowded samples.

9. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 1, characterized in that: For products identified as "golden ear" products, the following steps will be followed for grading: S231. Multimodal data synchronization locking and feature extraction Within the same extremely short time window, the system simultaneously locks two sets of underlying data: first, it extracts the dynamic weight data W from the micro-electronic scale; second, it analyzes the apparent texture image from the high-resolution camera and calculates the maximum circumscribed circle diameter D of the ear on the two-dimensional projection plane using an edge contour detection algorithm. ear ; S232. Multidimensional benchmark mapping of physical form To address the dual requirements of weight and size for golden ear mushrooms, a joint step mapping function based on the "barrel effect" is constructed; weight benchmark levels are calculated separately. and diameter reference level The minimum value between the two is taken as the physical base level. This means that if any one of the criteria is not met, the entire grade will be downgraded. ; Weight sub-class Step mapping: ; Diameter sub-level Step mapping: At 10cm, =4; 8cm At 10cm, =3; 5cm At 8cm, =2; At 5cm, =1; S233. Visual Quantization and Weighted Scoring The image is converted to the HSV color space, and the saturation mean is extracted and normalized to obtain the color score. The color is characterized as golden yellow or light yellow; surface dark spots, damage, and contour distortion features are extracted using a defect detection algorithm to calculate the surface integrity score. Perform linear weighting to obtain a comprehensive visual score. : ; S234. Dynamic degradation error prevention mechanism Using the comprehensive visual score S vision For the benchmark level Implement a veto-restraint mechanism; if the visual score is lower than a preset threshold... Then the downgrade formula is triggered. If severe lesions or mold are detected, the item will be forcibly removed from the list. ; S235. Final Classification Based on the final calculated comprehensive score G final Strictly match the physical execution actions of the tiered exits: Premium grade, corresponding to ; Grade 1 product, corresponding to ; Grade II product, corresponding to ; Substandard products, corresponding to .

10. The method for grading enoki mushrooms and golden ear mushrooms by apparent weight as described in claim 1, characterized in that: It also includes a sorting conveyor belt, with several pneumatic push rods installed on the side of the sorting conveyor belt, and corresponding grade collection boxes installed on the side of the sorting conveyor belt; the pneumatic push rods are controlled by an electronic control system, which adopts a hard real-time event-driven communication protocol based on industrial Ethernet. S41. Data Frame Encapsulation When obtained Immediately afterwards, a structured "sorting control data frame" is generated; this data frame contains: [Start symbol | Absolute timestamp T] stamp Material Tracking Identifier Serial Number ID tray | Overall rating result G final | CRC checksum]; S42. Data Frame Transmission and Interrupt Response Data frames are sent to the lower-level PLC via a high-speed bus; upon receiving the data packet, the PLC triggers a hardware-level receive interrupt for rapid parsing. and the material The ranking results are pushed into the high-speed shift register inside the PLC, into the FIFO queue, waiting for physical tracking mapping; S43. Dynamic displacement tracking based on encoder spatiotemporal mapping Because the conveyor belt's running speed v fluctuates slightly, the system does not rely on a simple time delay (Timer) for control, but instead constructs an "electronic cam (E-Cam)" tracking model based on position pulses. Pulse equivalent calibration: A high-resolution incremental rotary encoder is coaxially mounted on the main drive roller of the sorting conveyor belt; assuming the roller diameter is D, the encoder's single-turn resolution is... The pulse equivalent generated per unit distance traveled by the conveyor belt satisfy: ; Dynamic tracking queue initialization: Assume a material placement photoelectric sensor is installed at the exit of the detection box; when the pallet carrying the material triggers the sensor, it is marked as... At that moment, the PLC immediately retrieves the corresponding tray from the FIFO queue. And allocate a separate pulse counter for this tray in memory. The initial value is set to 0; Target pulse calculation: Let the physical distance from the reference position of the photoelectric sensor to the center line of the pneumatic push rod of the collection channel corresponding to level i be . The system calculates the total number of target pulses required for the tray to reach the target channel. : ; S44. Dynamic displacement tracking based on encoder spatiotemporal mapping During high-speed operation, the response of the pneumatic solenoid valve, the charging of the cylinder, and the mechanical extension of the push rod all require time. If the command is issued only when the tray is completely aligned with the push rod, it will inevitably lead to "push off" or "missed push"; therefore, a feedforward hysteresis compensation algorithm is embedded in the PLC. Total system latency measurement: The system is pre-calibrated and the total latency from the issuance of the command to the contact tray of the push rod is calculated. : ; in For PLC scan cycle, This refers to the solenoid valve's switching response time. The cylinder extension stroke time; Early trigger pulse compensation: Based on the instantaneous linear velocity v of the current conveyor belt, the system calculates the advance distance the tray will move during the lag time. ; Based on this, the PLC dynamically corrects the actual trigger pulse threshold. : ; High-speed physical execution: As the conveyor belt runs, the counter of the tray... Strictly equal to the corrected At that moment, the PLC's high-speed I / O module instantly outputs a drive level, activating the high-frequency pilot-operated solenoid valve of the corresponding channel; the pneumatic push rod extends precisely, using the flexible contact end to smoothly push the tray into the corresponding collection slide; after the push rod reaches the position, it triggers the magnetic switch, and the system automatically controls the solenoid valve to reset, completing a single execution cycle.