Greenhouse tomato fruit maturity instance segmentation method based on dual-backbone network fusion

By using a dual-backbone network fusion method, a lightweight CNN and Swin-Transformer path are constructed. Combined with FasterNetBlock and CBAM attention modules, the problems of local feature extraction and global context modeling in tomato ripeness detection in existing technologies are solved. This achieves high-precision tomato fruit ripeness detection and pixel-level segmentation, supporting automated harvesting.

CN121789210APending Publication Date: 2026-04-03赵柏栋
View PDF 0 Cites 1 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-04
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing methods for detecting tomato maturity rely on a single backbone network architecture, which makes it difficult to balance local feature extraction efficiency with global context modeling. Traditional detection methods cannot provide accurate bounding boxes and pixel-level instance segmentation, and cannot support centroid localization, size measurement, and pose estimation for automated harvesting. Furthermore, existing methods do not perform well in complex greenhouse environments.

Method used

We employ a dual-backbone network fusion approach to construct a lightweight CNN path and a Swin-Transformer path. By combining FasterNetBlock, CBAM attention module, and BiFPN network, we perform feature extraction and pixel-level instance segmentation using an improved YOLOv8s-seg model. This approach effectively integrates local features with global context, enhancing detection accuracy and robustness.

Benefits of technology

It achieves high-precision detection of tomato fruit maturity, improving detection accuracy and recall rate. It can accurately delineate the boundary outline of tomatoes in complex greenhouse environments, providing precise pixel-level information support for automated harvesting, and maintaining efficient and low-power operation on edge computing devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121789210A_ABST
    Figure CN121789210A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of agricultural informatization and intellectualization, in particular to a greenhouse tomato fruit maturity instance segmentation method based on dual-backbone network fusion, which comprises the following steps: S1, collecting tomato images in a greenhouse environment, and carrying out preprocessing and data enhancement; s2, performing instance segmentation and labeling on the image; s3, constructing a dual-backbone network feature extraction module; s4, constructing a BiFPN multi-scale feature fusion module; s5, constructing a decoupling detection head for classification, positioning and mask prediction; s6, training and verifying the model by adopting the marked picture set; s7, performing maturity detection and instance segmentation on the tomato fruit picture by adopting the model which is verified to be qualified; according to the method disclosed by the invention, the perception capability of related characteristics of the maturity is enhanced through the Faster NetBlock module and the CBAM attention module; under the synergistic effect of the two, the model keeps high precision, the recall rate is greatly increased by 6.7% to 88.9%, and all-round optimization of detection precision-recall rate-efficiency is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of agricultural informatization and intelligentization technology, specifically to a method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion. Background Technology

[0002] Tomatoes, one of the world's most widely cultivated vegetables, play a crucial role in global food security, with an annual production exceeding 180 million tons. This nutrient-rich crop is abundant in vitamin C, vitamin A, lycopene, and antioxidants, offering numerous benefits such as boosting immune function and improving cardiovascular health. However, the labor-intensive nature of tomato harvesting poses a significant challenge to the agricultural industry, with manual harvesting costs accounting for 30% to 50% of total production costs. Traditional methods for assessing tomato maturity rely on manual sampling and chemical analysis, which are not only labor-intensive and costly, but the increasing shortage of skilled agricultural workers is also hindering sustainable development. The rise of smart agriculture and precision agriculture technologies offers promising solutions to these challenges.

[0003] Accurately identifying tomato maturity remains a significant technical challenge under the complex conditions of greenhouses and fields. In unstructured conditions, tomato feature recognition is further complicated by changes in light intensity, leaf occlusion, and fruit overlap, which greatly reduces the effectiveness of traditional machine vision algorithms. Visual complexity stems from color changes at the ripening stage, irregular fruit shape and occlusion, multi-scale fruit distribution within clusters, and diurnal light variations. In recent years, deep learning has demonstrated great potential in overcoming these challenges, and researchers have applied algorithms such as Mask R-CNN and YOLOv8 to tomato recognition in greenhouse environments.

[0004] Existing detection methods mainly rely on single-stage bounding box algorithms, which have the following technical problems: First, a single-backbone network architecture cannot simultaneously balance local feature extraction efficiency and global context modeling capability. Second, traditional detection only provides a rough bounding box, which cannot support key post-processing tasks such as centroid positioning, size measurement and attitude estimation required for automated harvesting; Third, existing methods lack pixel-level instance segmentation capabilities, making it difficult to accurately delineate the boundary contours of each tomato. Therefore, to address the above issues, a greenhouse tomato fruit maturity instance segmentation method based on dual-backbone network fusion is proposed. Summary of the Invention

[0005] The purpose of this invention is to provide a method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion, so as to solve the problems mentioned in the background art.

[0006] To achieve the above objectives, the present invention provides the following technical solution: As an optional embodiment of the greenhouse tomato fruit maturity instance segmentation method based on dual-backbone network fusion described in this invention, the method includes the following steps: S1. A collection of images of tomato fruits under different maturity levels, light conditions, and degrees of shading in a greenhouse environment; S2. Perform instance segmentation and annotation on the tomato fruit image set to determine the range of tomato fruits at different maturity levels; S3. Construct a tomato fruit maturity instance segmentation model based on YOLOv8s-seg; S4. The tomato fruit maturity instance segmentation model was trained and validated using the labeled tomato fruit image set. S5. A validated tomato fruit maturity instance segmentation model is used to perform maturity detection and pixel-level instance segmentation on tomato fruit images.

[0007] As an optional solution to the greenhouse tomato fruit maturity instance segmentation method based on dual backbone network fusion described in this invention, when annotating the tomato fruit image set, tomato fruits of different maturity are divided into three types: mature, semi-mature, and immature.

[0008] As an optional scheme of the greenhouse tomato fruit maturity instance segmentation method based on dual backbone network fusion described in this invention, the labeled tomato fruit image set is divided into training set, test set and validation set in a ratio of 8:1:1.

[0009] As an optional solution to the greenhouse tomato fruit maturity instance segmentation method based on dual-backbone network fusion described in this invention, the tomato fruit maturity instance segmentation model is improved from the existing YOLOv8s-seg model, specifically as follows: A dual-backbone network feature extraction module is constructed, including a parallel lightweight CNN path and a Swin-Transformer path; The lightweight CNN path replaces the original C2f module with the FasterNetBlock module; Integrating the CBAM attention module into a lightweight CNN path; The Swin-Transformer path adopts the Swin Transformer Tiny architecture; The PANet neck network part in the YOLOv8s-seg model is replaced with a BiFPN network.

[0010] As an optional solution for the greenhouse tomato fruit maturity instance segmentation method based on dual backbone network fusion described in this invention, the improvement of the FasterNetBlock module is as follows: a partial convolution strategy is adopted to segment the input feature map into two paths: a partial channel and a residual channel. Only the partial channel is subjected to 3×3 convolution operation, and the residual channel is subjected to identity mapping. Finally, the outputs of the two paths are spliced ​​and fused, which reduces the computational complexity by about 15% compared with standard convolution.

[0011] As an optional solution to the greenhouse tomato fruit maturity instance segmentation method based on dual backbone network fusion described in this invention, the improvement of integrating the CBAM attention module into the lightweight CNN path is as follows: the CBAM module sequentially performs channel attention calculation and spatial attention calculation. Channel attention is obtained by performing global average pooling and global max pooling on the feature map, then processing it through a multilayer perceptron and adding them together for activation. Spatial attention is obtained by performing average pooling and max pooling on the channel dimensions, then concatenating them and activating them through a 7×7 convolution.

[0012] As an optional scheme of the greenhouse tomato fruit maturity instance segmentation method based on dual backbone network fusion described in this invention, when training the tomato fruit maturity instance segmentation model using an annotated tomato fruit image set, feature extraction is performed through a dual backbone network, and then the multi-scale features output by the dual backbone network are fused through a BiFPN neck network. Then, the detection head module in the head network generates candidate prediction boxes for abnormal types, and the candidate prediction boxes are continuously optimized according to the loss function to train the model to obtain weights that are closer to the labels.

[0013] As an optional solution to the greenhouse tomato fruit maturity instance segmentation method based on dual backbone network fusion described in this invention, the loss function includes a classification loss function, a localization loss function, and a mask loss function.

[0014] Compared with the prior art, the beneficial effects of the present invention are: This invention achieves effective fusion of local features and global context through a dual-backbone network architecture. The FasterNetBlock module in the lightweight CNN path reduces computational redundancy through partial convolution strategies, while the CBAM attention module enhances the perception of maturity-related features (such as color and texture). The Swin-Transformer path captures the long-range spatial dependence of the gradual change in maturity stages within fruit clusters through a hierarchical shift window mechanism. With the synergistic effect of these two approaches, the model maintains high accuracy (mAP@0.5 improved by 5.7% to 95.1%) while significantly improving recall by 6.7% to 88.9%, achieving comprehensive optimization of detection accuracy, recall, and efficiency. This invention replaces the traditional PANet with BiFPN, establishing an adaptive information flow path between features at different scales through a bidirectional feature fusion mechanism with learnable weights. This design avoids the information loss inherent in the traditional FPN structure, enhances the detection capability of tomatoes at multiple scales from small to large in greenhouse environments, and exhibits stronger robustness, especially in shading and dense scenes. This invention achieves pixel-level instance segmentation, which, compared to traditional bounding box detection, can accurately delineate the boundary contour of each tomato, providing precise pixel-level information support for key post-processing tasks required for automated harvesting, such as centroid positioning, size measurement, and attitude estimation. The model trained by this invention can be deployed on edge computing devices, such as the NVIDIA Jetson Orin Nano. In an edge deployment environment, it maintains an accuracy of 91.8%, consumes only 8.7W, and has a model size of 43.2MB. This meets the low power consumption and high precision requirements of real-time agricultural applications in greenhouse environments and provides reliable technical support for intelligent tomato harvesting robots. The dataset used in this invention was obtained from the actual greenhouse environment in which tomato fruits exist, including complex scenarios such as leaf shading, light changes, and cluster distribution. Compared with the traditional laboratory environment, the dataset is closer to actual production and life, which is more beneficial for training deep learning models to detect the ripeness of tomato fruits. Attached Figure Description

[0015] Figure 1 The images shown are preprocessing results for different scenarios in the embodiments of the present invention, including the original image, masked image, segmented image, Mosaic enhancement, and Mix-up enhancement results; Figure 2 This is a structural diagram of the tomato fruit maturity instance segmentation model based on a dual-backbone network in an embodiment of the present invention. Figure 3 This is a performance comparison chart between DTBi-YOLOv8-seg and the baseline model in this embodiment of the invention; Figure 4 This is a comparison chart of the recognition performance of different models tested in the embodiments of the present invention; Figure 5 This is a test diagram of the DTBi-YOLOv8-seg model in edge deployment in an embodiment of the present invention. Detailed Implementation

[0016] Example 1 Please see Figure 1 The present invention provides a technical solution: A method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion, the method comprising the following steps: S1. Collect a set of tomato fruit images under different maturity levels, light conditions, and shading levels in a greenhouse environment. Set the resolution to 4032×3024 pixels, normalize the image size to 640×640 pixels, and augment the dataset using Mosaic and Mix-up data augmentation methods, such as... Figure 1 As shown; S2. Perform instance segmentation and annotation on the tomato fruit image set to determine the range of tomato fruits at different ripeness levels. Use the LabelImg tool for manual annotation. The annotation format is compatible with YOLO bounding boxes and mask labels. The annotation categories include three types: ripe (Ripe), half-ripe (Half-Ripe), and unripe (Unripe). S3. Construct a tomato fruit maturity instance segmentation model based on YOLOv8s-seg; S4. The tomato fruit maturity instance segmentation model was trained and validated using the labeled tomato fruit image set. S5. A validated tomato fruit maturity instance segmentation model is used to perform maturity detection and pixel-level instance segmentation on tomato fruit images.

[0017] To enhance the model's generalization and robustness, and to enrich the dataset, this embodiment uses both real-world and online images when annotating the tomato fruit image set. The original dataset contains 1875 images, totaling approximately 9000 labeled instances. The dataset is then divided into training, testing, and validation sets in an 8:1:1 ratio, resulting in a training set of 1500 images, a testing set of 188 images, and a validation set of 187 images. These images are labeled using LabelImg, with mature fruits labeled as (Ripe), semi-ripe fruits as (Half-Ripe), and unripe fruits as (Unripe).

[0018] This embodiment further defines Embodiment 1. The tomato fruit maturity instance segmentation model is an improvement on the existing YOLOv8s-seg model (hereinafter referred to as DTBi-YOLOv8-seg). The specific improvements are as follows: A dual-backbone network feature extraction module is constructed, including a parallel lightweight CNN path and a Swin-Transformer path; The lightweight CNN path replaces the original C2f module with the FasterNetBlock module; Integrating the CBAM attention module into a lightweight CNN path; The Swin-Transformer path adopts the Swin Transformer Tiny architecture; The PANet neck network part in the YOLOv8s-seg model is replaced with a BiFPN network.

[0019] A schematic diagram of the improved DTBi-YOLOv8-seg model is shown below. Figure 2 As shown.

[0020] In the DTBi-YOLOv8-seg model, there are Input, Backbone, Neck, Head, and Output. Conv (3x3, stride=2) (3×3 size convolutional layer, stride set to 2); Swin Transformer (Shift Window Transformer); FasterNet Block (FasterNet network module); Convn (n=3,4,5) (n-dimensional convolution (n takes values ​​of 3, 4, 5)); CBAM (Channel + Spatial) (CBAM attention module, which includes a channel attention submodule and a spatial attention submodule). Multi-scale Detection Heads; Positional Encoding Pn (n=3,4,5) (n-order pooling (n takes values ​​of 3, 4, 5)); Fusion; BIFPN (Bidirectional Feature Pyramid Network (BIFPN)). The innovation of the FasterNetBlock module lies in its use of a partial convolution strategy. It divides the input feature map into two paths: a partial channel and a residual channel. Only the partial channels undergo 3×3 convolution, while the residual channels are subjected to identity mapping. The calculation formula is as follows: This design reduces computational complexity by approximately 15% compared to standard convolution, making it suitable for resource-constrained greenhouse robot deployment scenarios. The innovation of the CBAM attention module is reflected in the fact that it is a functionally complementary design that enhances the shallow feature representation capability by embedding the CBAM module.

[0021] The CBAM module performs channel attention calculation and spatial attention calculation sequentially. The channel attention calculation formula is as follows: The formula for calculating spatial attention is: The final output feature map is This module can suppress background interference such as leaves, while emphasizing maturity-related features such as color changes; The innovation of the Swin-Transformer path is reflected in: adopting the Swin Transformer Tiny architecture to process downsampled features from early layers of the CNN path, and using a hierarchical shift window mechanism for multi-head self-attention calculation. The attention calculation formula is as follows: Attention is computed within a local window, and global dependencies are simulated using a shifted window. The window size M is set to 7, the number of attention heads is set to 6, and sinusoidal positional encoding is added to preserve spatial location information. This path supplements the local focus of the CNN by focusing on the global color distribution. The innovation of the BiFPN module lies in its use of a bidirectional feature fusion mechanism with learnable weights to execute repeated top-down and bottom-up paths. The weighted fusion formula is as follows: The weight calculation formula is: This adaptive weighting mechanism ensures a balanced contribution of features at different scales, which is superior to the fixed connection method in PANet.

[0022] Example 2 This embodiment is an improvement upon embodiment 1. Please refer to [link / reference]. Figure 1 Specifically, the labeled images from the training set are input into the DTBi-YOLOv8-seg network for training. First, features are extracted through the backbone network. Then, the neck network fuses the multi-scale features output from the backbone network, enhancing the model's ability to detect multi-scale targets. Finally, the detection head module generates candidate prediction boxes for anomaly types.

[0023] The candidate predicted boxes are continuously optimized based on the number of loss functions, and the trained model obtains weights that are closer to the labels. The loss function of this invention is consistent with the loss function of the basic YOLOv8s-seg network, mainly including classification loss, localization loss and mask loss. The localization loss part mainly adopts the CIoU strategy. After constraining the bounding boxes with parameters such as center distance and aspect ratio, it measures the overlap area and intersection-union ratio between the predicted boxes and the ground truth boxes, and obtains the corresponding matching degree. The training parameters are as follows: input image size 640×640, epoch 300, learning rate 0.001 decaying to 0.00001 using cosine annealing, momentum set to 0.937, weight decay to 0.0005, and batch size 16. The effectiveness of the DTBi-YOLOv8-seg network in this invention is verified through specific experiments; In this experiment, the main metrics used for the detection model include precision, recall, mean precision (mAP) metrics mAP@0.5 (%) and mAP@0.5-95 (%), and the number of parameters (Params). Comparative Experiment: To verify the detection performance of the proposed DTBi-YOLOv8-seg network, experiments were conducted on the same test set to compare it with five other mainstream segmentation models (YOLOv5s-seg, YOLOv9-seg, YOLOv11-seg, Mask R-CNN, and Cascade Mask R-CNN). The results are shown in Table 1. Analysis of Table 1 shows that the DTBi-YOLOv8-seg network provided by this invention achieved the best results in Precision and mAP@0.5 (%), reaching 91.8% and 95.1% respectively, significantly higher than other models. It also approached the optimal performance in Recall, showing improvements of 6.7%, 4.0%, 2.8%, and 5.3% in Precision, Recall, mAP@0.5, and F1 score compared to YOLOv11-seg. A comparison of the recognition performance of different models in complex greenhouse scenes is also provided. Figure 4 As shown in the figure, A represents the original image, and BG represents the segmentation results of different detection models. It can be clearly seen that the DTBi-YOLOv8-seg model of this invention can accurately identify tomatoes at different maturity levels and precisely delineate their boundary contours even in complex scenarios such as leaf occlusion, light changes, and dense fruit distribution, demonstrating significantly better segmentation accuracy than other comparative models. Table 1:

[0024] To further verify the improvement effect, the classification performance of the DTBi-YOLOv8-seg model of this invention was compared with that of the baseline model YOLOv8s-seg. Figure 3 As shown in the figure, in the detection of mature tomatoes, the accuracy of the model of this invention reached 95.5%, an improvement of 4.8% compared with the baseline; in the detection of semi-ripe tomatoes, mAP@0.5 reached 89.7%, an improvement of 7.6% compared with the baseline; and in the detection of immature tomatoes, all indicators showed significant improvement. The results indicate that the model of this invention is superior to the baseline model in all maturity categories.

[0025] Ablation experiments: The first improvement, adding the Swin-Transformer path, improved accuracy by 1.1%, mAP@0.5 by 2.1%, and mAP@0.5-95 by 1.1% compared to the original model, with no change in the number of parameters after rounding. The second improvement, fusing the FasterNetBlock downsampling module, improved recall by 3.0%, mAP@0.5 by 2.0%, and mAP@0.5-95 by 1.3%, with only a 1.3% decrease in accuracy, but a 0.10M reduction in parameters. The third improvement, introducing the BiFPN network, improved recall by 3.2%, mAP@0.5 by 0.6%, and mAP@0.5-95 by 0.4%, with a 5.4% decrease in accuracy and a 3.10M increase in parameters. It can be seen that all three improvements enhanced the model's basic performance without significantly increasing the number of parameters, with the second improvement reducing the number of parameters in the base model to some extent. The improvements were then combined pairwise to observe their impact on the results. It can be seen that the pairwise combinations improved all metrics compared to the original model. Finally, combining all three improvements resulted in a 3.4% increase in accuracy, a 4.6% increase in recall, and improvements of 3% and 2.9% in mAP@0.5 and mAP@0.5-95, respectively. The number of parameters increased by 2.99M compared to the original model. This improved model performance without increasing model complexity. The results are shown in Table 2. Table 2:

[0026] Edge Deployment Testing: Through edge deployment testing, this invention evaluated the effectiveness of the model in grading tomato maturity in real-world scenarios. For example... Figure 5 As shown, after edge deployment, the DTBi-YOLOv8-seg model maintains high detection accuracy and can accurately distinguish tomatoes at different ripeness levels. The model achieves 91.8% accuracy with a power consumption of only 8.7W and a model size of 43.2MB. This not only confirms the model's versatility and reliability in complex environments but also provides solid technical support for intelligent tomato harvesting decisions. Figure 1 Chinese: Bright Light, Dark Light, Stacked Scenario, Original Image, Mask Image, Segmentation Image, Mosaic Augmentation, Mix-up Augmentation.

[0027] Example 3 This embodiment further defines Embodiment 2 and is used to verify the deployment performance of the model on edge devices.

[0028] Edge Deployment Testing: The trained DTBi-YOLOv8-seg model was deployed on an NVIDIA Jetson OrinNano edge computing device for testing. This device runs JetPack 5.1.2 (based on Ubuntu 20.04), and is equipped with a 6-core ARM Cortex-A78AE processor, a 1024-core Ampere GPU, and 16GB of LPDDR5 memory. The software environment includes Python 3.8, CUDA 11.4, cuDNN 8.6, TensorRT 8.5, and PyTorch 1.12.0. Test results show that the DTBi-YOLOv8-seg model maintains high detection accuracy after edge deployment, accurately distinguishing tomatoes at different ripeness levels. The model achieves 91.8% accuracy with a power consumption of only 8.7W and a model size of 43.2MB. Compared with other comparative models, the model of this invention achieves the optimal balance between accuracy and energy efficiency: YOLOv5s-seg accuracy 84.7%, power consumption 8.5W, model size 14.3MB; YOLOv9-seg accuracy 77.8%, power consumption 9.1W, model size 28.7MB; YOLOv11-seg accuracy 85.1%, power consumption 6.2W, model size 12.2MB; Mask R-CNN accuracy 52.8%, power consumption 11.3W, model size 170.1MB; Cascade Mask R-CNN accuracy 61.3%, power consumption 12.7W, model size 180.6MB. The test results above confirm the versatility and reliability of the model of the present invention in complex greenhouse environments, providing solid technical support for intelligent tomato harvesting decisions.

[0029] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only for the purpose of helping to understand the method and core ideas of the present invention. The above descriptions are only preferred embodiments of the present invention. It should be noted that due to the limitations of textual expression, while there are objectively infinite specific structures, those skilled in the art can make several improvements, modifications, or changes without departing from the principles of the present invention, and can also combine the above technical features in an appropriate manner. These improvements, modifications, changes, or combinations, or the direct application of the inventive concept and technical solution to other situations without modification, should all be considered within the scope of protection of the present invention.

Claims

1. A method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion, characterized in that: The method includes the following steps: S1. Collect a set of tomato fruit images under different maturity levels, light conditions, and shading levels in a greenhouse environment. Normalize the image size to 640×640 pixels and use Mosaic and Mix-up data augmentation methods to expand the dataset. S2. Perform instance segmentation and labeling on the tomato fruit image set to determine the range of tomato fruits at different maturity levels. The labeling categories include three types: mature, semi-mature, and immature. S3. Construct a tomato fruit maturity instance segmentation model based on YOLOv8s-seg; the tomato fruit maturity instance segmentation model is an improvement on the existing YOLOv8s-seg model, specifically: A dual-backbone network feature extraction module is constructed, including a parallel lightweight CNN path and a Swin-Transformer path; The lightweight CNN path replaces the original C2f module with the FasterNetBlock module and integrates the CBAM attention module; The Swin-Transformer path adopts the Swin Transformer Tiny architecture and processes features in parallel with the CNN path. The PANet neck network part in the YOLOv8s-seg model was replaced with a BiFPN network. The outputs of the dual backbone networks are fused by splicing and then fed into BiFPN for multi-scale feature fusion. S4. The tomato fruit maturity instance segmentation model was trained and validated using the labeled tomato fruit image set. S5. A validated tomato fruit maturity instance segmentation model is used to perform maturity detection and pixel-level instance segmentation on tomato fruit images.

2. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The labeled tomato fruit image set was divided into training, testing, and validation sets in a ratio of 8:1:

1.

3. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: When training a tomato fruit maturity instance segmentation model using an annotated tomato fruit image set, feature extraction is performed through a dual-backbone network. A lightweight CNN path extracts local texture and edge features, while a Swin-Transformer path captures global contextual dependencies. Then, a BiFPN neck network is used to fuse the multi-scale features output by the dual-backbone network. Finally, a decoupled detection head module generates classification prediction, bounding box regression, and mask prediction. The prediction results are continuously optimized based on the loss function, and the training model obtains weights that are closer to the labels.

4. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The FasterNetBlock module in the lightweight CNN path employs a partial convolution strategy, dividing the input feature map into partial channels and residual channels, and performing convolution operations only on partial channels. The calculation formula is as follows: ,in and These are the inputs for the segmented partial channels and the residual channels, respectively.

5. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The CBAM attention module performs channel attention and spatial attention calculations sequentially. The formula for calculating channel attention is: , The formula for calculating spatial attention is: , in, Here is the channel attention weight matrix. Here is the spatial attention weight matrix. For the input feature map, It is the Sigmoid activation function. It is a multilayer perceptron. This is a global average pooling operation. This is a global max pooling operation. For convolution operations with 7×7 kernels, [ This indicates a splicing operation along the channel dimension.

6. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The Swin-Transformer path employs a hierarchical shift window mechanism for multi-head self-attention computation. The formula for calculating attention is: , in, Indicates attention output, For querying the matrix, The key matrix, For value matrices, express and Matrix multiplication by transpose The dimension of the key vector is used for scaling to prevent gradient vanishing. For normalized exponential functions, The learnable relative position offset matrix is ​​set to a window size of 7.

7. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The weighted fusion formula for the BiFPN module is as follows: , in, The output feature map after fusion. This represents summing over all input features. For the first Each input feature corresponds to a learnable weight, which has been normalized using softmax. For the first One input feature map, The sum of all weights is used for normalization. To prevent small constants from being divided by zero from being set to 0.0001.

8. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The loss function includes a binary cross-entropy loss for classification, a combination of distribution focus loss and CIoU loss for bounding box regression, and a binary cross-entropy loss for mask prediction. The total loss function is: , in, This is the total loss function value. Lreg is the classification loss used to measure the difference between the predicted class and the true class, while Lreg is the regression loss used to measure the localization error between the predicted bounding box and the true bounding box. Mask loss is used to measure the pixel-level difference between the predicted mask and the true mask. , , The weighting coefficients for classification loss, regression loss, and masking loss are used to balance the contributions of each loss term.

9. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The training parameters were set as follows: initial learning rate 0.001, decayed to 0.00001 using cosine annealing, Adam optimizer, momentum 0.937, weight decay 0.0005, batch size 16, training epochs 300, and input image size 640×640.

10. The method for segmenting greenhouse tomato fruit maturity instances based on dual-backbone network fusion according to claim 1, characterized in that: The trained model can be deployed on NVIDIA Jetson Orin Nano edge devices, maintaining 91.8% accuracy, consuming 8.7W of power, and having a model size of 43.2MB, meeting the needs of real-time agricultural applications.

Citation Information

Cited By

  • Mask detection method and device

    CN122089738A