Greenhouse tomato instance segmentation method and device in complex background environment

By using a combination of convolutional neural networks and instance segmentation algorithms in the greenhouse, the problem of accuracy and robustness of tomato segmentation under complex backgrounds was solved, and more efficient tomato fruit identification and growth status analysis were achieved.

CN118736221APending Publication Date: 2024-10-01INTELLIGENT EQUIPMENT RESEARCH CENTER BEIJING ACADEMY OF AGRICULTURE AND FORESTRY SCIENCES
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410833867.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

It is difficult for the existing technology to accurately segment tomato fruits in the greenhouse under complex background environments, and there are problems such as low segmentation accuracy, low robustness, and low efficiency.

Method used

Feature extraction based on the convolutional neural network EfficientNet is used, combined with the feature fusion module of the adaptive feature pyramid and multi-scale attention network, and the instance segmentation algorithm SOLOv2 and CondInst are used for instance segmentation to generate the tomato mask and bounding box, and use CatBoost The regression model fits the growth state information.

Benefits of technology

It improves the accuracy and robustness of greenhouse tomato instance segmentation in complex background environments, provides richer image analysis results than semantic segmentation, and improves segmentation efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118736221A_ABST
    Figure CN118736221A_ABST
Patent Text Reader

Abstract

The invention provides a greenhouse tomato instance segmentation method and device in a complex background environment, and the method comprises the steps: carrying out the feature extraction of a to-be-segmented tomato image based on an OfficientNet network, and obtaining a feature map; based on a feature fusion module, performing adaptive fusion on different scale features in the feature map to obtain a fused feature map; and based on an instance segmentation module, performing instance segmentation, and determining a mask and a bounding box of the tomato. According to the greenhouse tomato instance segmentation method and device in the complex background environment provided by the invention, the features of different levels in the feature map of the to-be-segmented tomato image are fused through the feature fusion module, and the expression ability and the distinguishing ability of the features are improved. And on the basis of an instance segmentation module, instance segmentation is performed on the fused feature map to obtain a mask and a bounding box, so that accurate segmentation of the tomato fruits in the greenhouse is effectively realized, and the accuracy of greenhouse tomato instance segmentation in a complex background environment is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method and device for segmenting greenhouse tomato instances in a complex background environment. Background Art

[0002] Tomato is one of the important economic crops, and its growth status and quality directly affect the benefits and safety of agricultural production. In order to effectively monitor and manage the growth process of tomatoes in greenhouses, it is necessary to obtain accurate information on the number, size, shape, color, maturity, etc. of tomato fruits in greenhouses. It not only helps farmers predict tomato yield and harvest time, but also provides a basis for tomato quality assessment and pest and disease identification.

[0003] Existing greenhouse tomato fruit image acquisition usually faces complex background environments such as occlusion, lighting, noise, and viewing angle, which makes it difficult to segment and identify tomatoes in the image. How to achieve the demand for accurate segmentation of greenhouse tomatoes under complex background environments is an important issue that needs to be solved urgently in the industry. Summary of the invention

[0004] The present invention provides a method and a device for segmenting greenhouse tomato instances in a complex background environment, so as to improve the accuracy of segmenting greenhouse tomato instances in a complex background environment.

[0005] The present invention provides a method for segmenting greenhouse tomato instances under a complex background environment, comprising:

[0006] Based on the convolutional neural network EfficientNet, feature extraction is performed on the tomato image to be segmented to obtain a feature map of the tomato image to be segmented;

[0007] Based on a feature fusion module, adaptively fuse the features of different scales in the feature map to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network;

[0008] Based on the instance segmentation module, the fused feature map is subjected to instance segmentation to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0009] According to a method for segmenting greenhouse tomato instances in a complex background environment provided by the present invention, based on a feature fusion module, the different scale features in the feature map are adaptively fused to obtain a fused feature map, including:

[0010] Processing the feature map based on an adaptive feature pyramid to obtain a feature pyramid including different feature layers;

[0011] A multi-scale feature fusion network based on a channel attention mechanism dynamically allocates different channel weights according to different feature layers, and fuses the different feature layers based on the channel weights to obtain a fused feature map.

[0012] According to a greenhouse tomato instance segmentation method under a complex background environment provided by the present invention, based on an instance segmentation module, instance segmentation is performed on the fused feature map to determine a mask of a tomato and a bounding box of a tomato in the tomato image to be segmented, including:

[0013] Performing instance segmentation processing on the fused feature map based on SOLOv2 to obtain a mask and a category of each instance in the fused feature map;

[0014] Based on CondInst, instance segmentation processing is performed on the mask of each instance and the category of each instance to obtain the mask of the tomato and the bounding box of the tomato in the tomato image to be segmented.

[0015] According to a method for segmenting greenhouse tomatoes in a complex background environment provided by the present invention, after determining the mask of tomatoes and the boundary box of tomatoes in the to-be-segmented tomato image, the method further includes:

[0016] Marking tomatoes in the tomato image to be segmented to obtain marking information;

[0017] Based on the tomato mask and the tomato bounding box, the annotation information and the evaluation model, the tomato mask and the tomato bounding box are evaluated to determine the difference between the segmentation result and the true annotation, and the evaluation model is determined based on the average precision mean, the mean absolute error and the structural similarity index.

[0018] According to a method for instance segmentation of greenhouse tomatoes in a complex background environment provided by the present invention, the training process of the instance segmentation module includes:

[0019] Acquire a tomato fruit image dataset, and annotate each tomato in the tomato fruit image dataset at the pixel level to obtain the annotated tomato fruit image dataset;

[0020] Based on the contrast-limited adaptive histogram equalization method, the random erasing method and the style transfer method, the annotated tomato fruit image dataset is expanded to obtain an expanded dataset.

[0021] Based on the expanded data set, an initial instance segmentation module is trained to obtain the instance segmentation module.

[0022] According to a method for segmenting greenhouse tomatoes in a complex background environment provided by the present invention, after determining the mask of tomatoes and the boundary box of tomatoes in the to-be-segmented tomato image, the method further includes:

[0023] Extracting shape information, texture information and pest and disease information of the tomatoes based on the masks of the tomatoes and the bounding boxes of the tomatoes in the tomato image to be segmented;

[0024] Based on the CatBoost regression model, the shape information, texture information and pest and disease information are fitted to obtain the growth status information of the tomato.

[0025] The present invention also provides a greenhouse tomato instance segmentation device under a complex background environment, comprising:

[0026] A feature extraction module, used for performing feature extraction on the tomato image to be segmented based on a convolutional neural network EfficientNet, to obtain a feature map of the tomato image to be segmented;

[0027] A feature map determination module, used for adaptively fusing features of different scales in the feature map based on a feature fusion module to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network;

[0028] The segmentation module is used to perform instance segmentation on the fused feature map based on the instance segmentation module to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0029] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for segmenting greenhouse tomato instances in a complex background environment as described above is implemented.

[0030] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for segmenting greenhouse tomato instances in a complex background environment as described in any one of the above is implemented.

[0031] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for segmenting greenhouse tomato instances in a complex background environment as described above is implemented.

[0032] The method and device for instance segmentation of greenhouse tomatoes in a complex background environment provided by the present invention fuses the features of different levels in the feature map of the tomato image to be segmented through a feature fusion module, thereby improving the expressiveness and distinguishing ability of the features. Based on the instance segmentation module, instance segmentation is performed on the fused feature map to obtain information of its mask and bounding box, effectively realizing the accurate segmentation of greenhouse tomato fruits, providing richer and more detailed image analysis results than semantic segmentation, and improving the accuracy of instance segmentation of greenhouse tomatoes in a complex background environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0034] Figure 1 It is a flow chart of a greenhouse tomato instance segmentation method under a complex background environment provided by the present invention;

[0035] Figure 2 It is a structural schematic diagram of a greenhouse tomato example segmentation device under a complex background environment provided by the present invention;

[0036] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0038] Instance segmentation is to segment each target object in the image and give its category and location information. The instance segmentation method provides richer and more detailed image analysis results than image classification and target detection methods, providing more decision support for greenhouse tomato growth monitoring and management.

[0039] Among the related methods, the instance segmentation methods of tomato fruit in greenhouses can be mainly divided into two categories: region-based methods and pixel-based methods.

[0040] The idea of ​​the region-based method is: first use the target detection algorithm (Faster R-CNN, YOLO, SSD, etc.) to locate and identify the tomatoes in the image to obtain the bounding box of the tomato, and then use the segmentation algorithm (Mask R-CNN, FCN, U-Net, etc.) to segment the image within the bounding box to obtain the mask of the tomato. The advantage of this type of method is that it uses the mature technology of target detection to quickly screen and locate the tomatoes in the image, reducing the amount of calculation and time for segmentation. However, the disadvantage is that the accuracy and quality of the bounding box directly affect the segmentation effect. If the bounding box is too large or too small, or contains multiple tomatoes, the segmentation result will be inaccurate or incomplete. In addition, two stages of training and inference are required, which increases the complexity and resource consumption of the model.

[0041] The idea of ​​the pixel-based method is to directly use the segmentation algorithm (PSPNet, Deeplab, HRNet, etc.) to classify each pixel in the image to obtain the semantic segmentation result of the image, and then use the clustering algorithm (Mean Shift, DBSCAN, HDBSCAN, etc.) to post-process the semantic segmentation result to obtain the mask and bounding box of the tomato. Its advantage is that it avoids the influence of the bounding box, directly segments the tomatoes in the image, and improves the accuracy and completeness of the segmentation. However, the disadvantage is that all pixels in the image need to be calculated, which increases the amount of calculation and time for segmentation. In addition, the segmentation results need to be post-processed, which increases the complexity and instability of the model. Therefore, the instance segmentation methods of greenhouse tomato fruits in the related methods have limitations and shortcomings, and it is difficult to adapt to the segmentation needs of greenhouse tomato fruit images under complex background environments.

[0042] Specifically, the defects of the greenhouse tomato fruit detection and segmentation technology based on image processing in related methods are:

[0043] The segmentation accuracy is not high. Since the tomato fruits in the greenhouse grow in a complex background environment, including occlusion, lighting, shadows, reflections, noise, etc., the quality of the tomato fruit images in the greenhouse is low, and it is difficult to distinguish the tomato fruits from the background. Therefore, the existing methods such as threshold segmentation, edge detection, morphological operations, and region growing often cannot accurately segment the tomato fruits, or will cause over-segmentation or under-segmentation problems, resulting in low segmentation accuracy.

[0044] The segmentation is not robust. Due to the diversity and variability of greenhouse tomato fruit images (different varieties, different maturity, different angles, different scales, different shapes, etc.), the features of greenhouse tomato fruit images are inconsistent and difficult to process with unified rules or parameters. Therefore, existing methods are often sensitive to image quality and threshold selection, noise and occlusion, image scale and shape, and are easily affected by various factors, resulting in weak segmentation results.

[0045] The segmentation efficiency is not high. Due to the number and complexity of greenhouse tomato fruit images, a large number of tomato fruits, complex backgrounds, and multiple layers of leaves, the processing of greenhouse tomato fruit images requires a lot of computing resources and time. Therefore, existing methods require multiple steps and multiple parameters for processing, or require manual intervention and adjustment, resulting in low efficiency of segmentation results.

[0046] Aiming at the defects in the related methods, the present invention proposes a method for segmenting greenhouse tomatoes in a complex background environment. Figure 1 This is a flow chart of the greenhouse tomato instance segmentation method under complex background environment provided by the present invention. Figure 1 , the greenhouse tomato instance segmentation method under complex background environment provided by the present invention may include:

[0047] Step 110, based on the convolutional neural network EfficientNet, feature extraction is performed on the tomato image to be segmented to obtain a feature map of the tomato image to be segmented;

[0048] Step 120, based on a feature fusion module, adaptively fuses the features of different scales in the feature map to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network;

[0049] Step 130, based on the instance segmentation module, instance segmentation is performed on the fused feature map to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0050] The execution subject of the greenhouse tomato instance segmentation method under complex background environment provided by the present invention can be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (NAS) or a personal computer (PC), etc., which is not specifically limited by the present invention.

[0051] The following takes the method for segmenting greenhouse tomatoes in a complex background environment provided by the present invention executed by a computer as an example to explain the technical solution of the present invention in detail.

[0052] In step 110, based on the convolutional neural network EfficientNet, feature extraction is performed on the tomato image to be segmented to obtain a feature map of the tomato image to be segmented.

[0053] EfficientNet is an efficient convolutional neural network based on network scaling. It dynamically adjusts the depth, width and resolution of the network according to different computing resources and data sets to improve the expressiveness and receptive field of features. EfficientNet can extract effective features from images and use EfficientNet as the backbone network to improve feature extraction capabilities. It is used to extract effective features from images and provide input for subsequent segmentation.

[0054] Specifically, network scaling is a method used to optimize the structure of convolutional neural networks. It dynamically adjusts the depth, width, and resolution of the network according to different computing resources and data sets to balance the complexity and performance of the network. Depth - the number of layers of the network, width - the number of channels of the network, resolution - the size of the input image of the network. The goal of network scaling is to find the optimal combination of depth, width, and resolution while keeping the complexity of the network unchanged, so as to maximize the feature expression ability and receptive field of the network.

[0055] The network scaling method used is based on the basic model EfficientNet-B0. By scaling the coefficient α, its depth, width and resolution are uniformly scaled to obtain different models from EfficientNet-B1 to EfficientNet-B7. Specifically, for each model, the calculation formula for its depth, width and resolution is as follows:

[0056] d=α φ d0,w=α φ w0,r=α φ r0;

[0057] Wherein, d, w, r represent depth, width and resolution respectively, φ represents scaling factor, d0, w0, r0 represent depth, width and resolution of EfficientNet-B0 respectively. The network scaling parameters used in the present invention are: α=1.2, φ=1~7, d0=39, w0=32, r0=224.

[0058] EfficientNet is an efficient convolutional neural network based on network scaling. It consists of multiple convolutional modules and fully connected modules. Each convolutional module contains multiple residual units. Each residual unit contains bottleneck structure, depthwise separable convolution, dilated convolution and skip connection. The bottleneck structure is used to reduce parameters and computational complexity. It consists of 1×1 convolution, batch normalization (BN) and activation function (ReLU), which compresses the number of input channels to a smaller value. Depthwise separable convolution is used to improve the expressiveness and receptive field of features. It consists of depthwise convolution and 1×1 convolution, which separates the convolution of space and channels, reduces parameters and computational complexity, while maintaining the diversity and effectiveness of features. Dilated convolution is used to increase the receptive field of features. A certain space is inserted between each element of the convolution kernel to increase the size of the convolution kernel without increasing parameters and computational complexity. Skip connection is used to solve the problem of gradient disappearance and network degradation. It directly adds the input features to the output features to enhance the transmission and fusion of features.

[0059] The parameters of EfficientNet used are shown in Table 1:

[0060] Table 1 Parameters of EfficientNet

[0061] Model Resolution depth width parameter FLOPS B0 224 39 32 5.3M 0.39B B1 240 55 48 7.8M 0.70B B2 260 63 56 9.2M 1.0B B3 300 71 64 12M 1.8B B4 380 87 96 19M 4.2B B5 456 103 128 30M 9.9B B6 528 119 160 43M 19B B7 600 143 192 66M 37B

[0062] The core parameter configuration of EfficientNet is shown in Table 2:

[0063] Table 2 EfficientNet core parameter configuration table

[0064] Parameter name Parameter Value Parameter Explanation width_coefficient 1 Network width, which controls the number of channels in the network depth_coefficient 1 Network depth, which controls the number of layers in the network resolution 1 Network resolution, controls the size of the input image dropout_rate 0.2 The random dropout rate in the network controls the degree of network regularization

[0065] In order to extract effective features from the tomato image to be segmented, EfficientNet is used as the backbone network to segment the tomato image I″′ k Processing is performed to obtain the feature map F k Specifically, each image I″′ kAdjust to the same size as the resolution of EfficientNet, and then input it into EfficientNet to obtain the output of the last convolution module of EfficientNet, that is, the feature map F k . Feature map F k The size is H′×W′×C′, where H′, W′, and C′ represent the height, width, and number of channels of the feature map, respectively, and are related to the parameters of EfficientNet. The version of EfficientNet that can be used is EfficientNet-B4, which has a resolution of 380 and a feature map size of 12×12×1792.

[0066] In step 120, based on a feature fusion module, the features of different scales in the feature map are adaptively fused to obtain a fused feature map, and the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network.

[0067] Adaptive feature pyramid (AFP) and multi-scale attention network (MANet) can be used as feature fusion modules to achieve adaptive fusion of features of different scales.

[0068] AFP is based on the feature pyramid of the spatial attention mechanism. According to different input images, it dynamically generates different feature pyramids to adapt to different target sizes and shapes. MANet is based on the multi-scale feature fusion network of the channel attention mechanism. According to different feature layers, it dynamically assigns different channel weights to enhance the expressiveness and discrimination of features. This step aims to fuse features at different levels to improve the accuracy and robustness of segmentation.

[0069] In step 130, instance segmentation is performed on the fused feature map based on an instance segmentation module to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0070] Based on SOLOv2 and CondInst as instance segmentation modules, faster and more accurate instance segmentation is achieved, avoiding the use of anchor boxes and region proposal networks. SOLOv2 is an instance segmentation module based on dynamic convolution without anchor boxes, which directly predicts the mask and category of each instance from the feature map without post-processing. CondInst is an instance segmentation module based on conditional convolution. According to the features of each instance, different convolution kernels are dynamically generated to improve the accuracy and efficiency of segmentation. This step aims to segment each tomato in the image based on the results of feature fusion and generate the mask and bounding box of the tomato.

[0071] The method for instance segmentation of greenhouse tomatoes in a complex background environment provided by the embodiment of the present invention fuses the features of different levels in the feature map of the tomato image to be segmented through a feature fusion module, thereby improving the expressiveness and distinguishing ability of the features. Based on the instance segmentation module, instance segmentation is performed on the fused feature map to obtain information of its mask and bounding box, effectively realizing the accurate segmentation of greenhouse tomato fruits, providing richer and more detailed image analysis results than semantic segmentation, and improving the accuracy of instance segmentation of greenhouse tomatoes in a complex background environment.

[0072] In one embodiment, based on a feature fusion module, the different scale features in the feature map are adaptively fused to obtain a fused feature map, including: processing the feature map based on an adaptive feature pyramid to obtain a feature pyramid containing different feature layers; a multi-scale feature fusion network based on a channel attention mechanism, dynamically allocating different channel weights according to different feature layers, and fusing the different feature layers based on the channel weights to obtain a fused feature map.

[0073] Adaptive feature pyramid (AFP) and multi-scale attention network (MANet) are used as feature fusion modules to achieve adaptive fusion of features of different scales. AFP is based on the feature pyramid of spatial attention mechanism. According to different input images, it dynamically generates different feature pyramids to adapt to different target sizes and shapes. MANet is a multi-scale feature fusion network based on channel attention mechanism. According to different feature layers, it dynamically assigns different channel weights to enhance the expressiveness and discrimination of features. This step aims to fuse features of different levels to improve the accuracy and robustness of segmentation.

[0074] The specific steps are as follows:

[0075] Adaptive Feature Pyramid (AFP) is based on the feature pyramid of the spatial attention mechanism. It dynamically generates different feature pyramids according to different input images to adapt to different target sizes and shapes.

[0076] The spatial attention mechanism is used to enhance the importance and discrimination of features. According to the local correlation of features, different spatial weights are dynamically assigned to highlight the key parts of features and suppress irrelevant parts of features. k Processing is performed to obtain the feature pyramid P k .

[0077] Among them, the core parameter configuration of AFP is shown in Table 3:

[0078] Table 3 AFP core parameter configuration table

[0079] Parameter name Parameter Value Parameter Explanation in_channels [40,112,320,1280] Number of channels of input features out_channels 256 The number of channels of output features num_levels 4 Number of layers of feature pyramid num_heads 4 Number of dynamic convolution heads num_bases 4 Cardinality of dynamic convolution

[0080] Specifically, for each feature map F k , using a bottleneck structure consisting of 1×1 convolution, batch normalization (BN) and activation function (ReLU), the number of channels is compressed to C″, and the compressed feature map F′ is obtained k The spatial attention module composed of 3×3 convolution, batch normalization (BN) and Sigmoid function is used to compress the feature map F′ k Processing is performed to obtain the spatial attention map A k Spatial Attention Map A k The size of the compressed feature map F′ k The same, that is, H′×W′×C″, where H′, W′, C″ represent the height, width and number of channels respectively. Spatial attention map A k The value of each element of is between 0 and 1, indicating the importance of the feature at that position. A bottleneck structure consisting of 1×1 convolution, batch normalization (BN) and activation function (ReLU) is used to compress the feature map F′ k The number of channels is restored to C′, and the restored feature map F″ is obtained k . The spatial attention map A k And the restored feature map F″ k Perform element-by-element multiplication to obtain the feature map F″′ after attention enhancement k . Using the bilinear interpolation method, the feature map F″′ after attention enhancement is k Adjust to different sizes to obtain different feature layers to form the feature pyramid P k The parameters of AFP used in the present invention are as follows: the number of compressed channels C″ is 256, the number of layers of the feature pyramid is 5, and the sizes of the feature pyramid are 6×6, 12×12, 24×24, 48×48, and 96×96.

[0081] The Multi-scale Attention Network (MANet) is a multi-scale feature fusion network based on the channel attention mechanism. According to different feature layers, different channel weights are dynamically assigned to enhance the expressiveness and discrimination of features.

[0082] The core parameter configuration of MANet is shown in Table 4:

[0083] Table 4. MANet core parameter configuration table

[0084] Parameter name Parameter Value Parameter Explanation in_channels 256 Number of channels of input features out_channels 256 The number of channels of output features num_levels 4 Number of layers of feature pyramid num_scales 4 Number of scales for multi-scale attention reduction_ratio 16 Dimensionality reduction ratio of attention mechanism

[0085] Specifically, the channel attention mechanism is used to enhance the importance and discrimination of features. According to the global relevance of features, different channel weights are dynamically assigned to highlight the key channels in the features and suppress irrelevant channels in the features. k Processing is performed to obtain the fused feature map G k .

[0086] Specifically, for each feature layer Using a bottleneck structure consisting of 1×1 convolution, batch normalization (BN) and activation function (ReLU), the number of channels is compressed to C″′ to obtain the compressed feature layer Use adaptive average pooling (AdaptiveAvgPool) and adaptive maximum pooling (AdaptiveMaxPool) to compress the feature layer Perform global pooling to obtain two vectors, representing the average feature and the maximum feature of the feature layer. Concatenate the two vectors to obtain a vector of length 2C″′, which represents the global feature of the feature layer. Use a channel attention module composed of a fully connected layer, batch normalization (BN) and an activation function (ReLU) to process the global features and obtain a channel attention vector Channel Attention Vector The length of is the same as the number of channels after compression C″′, and the value of each element is between 0 and 1, indicating the importance of the feature of the channel. With the compressed feature layer Perform element-by-element multiplication to obtain the feature layer after attention enhancement Using the bilinear interpolation method, the feature layer after attention enhancement Adjust to the same size as the largest feature layer, i.e. 96×96, to obtain the adjusted feature layer All the adjusted feature layers Perform element-by-element summation to obtain the fused feature map G k The parameters of MANet used in the present invention are as follows: the number of compressed channels C″′ is 256, and the output dimension of the fully connected layer is 128.

[0087] The feature fusion method based on fusion of different levels of features, using AFP and MANet as feature fusion modules, realizes adaptive fusion of features of different scales. The feature fusion method used in the present invention improves the accuracy and robustness of segmentation.

[0088] In one embodiment, based on the instance segmentation module, instance segmentation is performed on the fused feature map to determine the mask of the tomato and the bounding box of the tomato in the tomato image to be segmented, including: performing instance segmentation processing on the fused feature map based on SOLOv2 to obtain the mask and category of each instance in the fused feature map; performing instance segmentation processing on the mask of each instance and the category of each instance based on CondInst to obtain the mask of the tomato and the bounding box of the tomato in the tomato image to be segmented.

[0089] Specifically, SOLOv2 is an anchor-free instance segmentation module based on dynamic convolution, which directly predicts the mask and category of each instance from the feature map without post-processing. Dynamic convolution is used to generate different convolution kernels, which are dynamically generated according to the input features to adapt to different targets and scenarios.

[0090] Use SOLOv2 to fused feature map G k Processing is performed to obtain the mask of each instance and categories

[0091] Among them, the core parameter configuration of SOLOv2 is shown in Table 5:

[0092] Table 5 SOLOv2 core parameter configuration table

[0093] Parameter name Parameter Value Parameter Explanation num_classes 2 Number of categories num_grids [40,36,24,16,12] The number of grids in the feature map strides [8,8,16,32,32] The stride of the feature map scale_ranges [(1,96),(48,192),(96,384),(192,768),(384,2048)] The scale range of feature maps Sigma 0.2 Standard deviation of the Gaussian kernel num_masks 256 Number of masks mask_size 32 Mask size

[0094] Specifically, for each feature map G k , using a bottleneck structure consisting of 3×3 convolution, batch normalization (BN) and activation function (ReLU), the number of channels is compressed to C″″, and the compressed feature map G′ is obtained k The category prediction module composed of 1×1 convolution, batch normalization (BN) and Sigmoid function is used to compress the feature map G′ k Processing is performed to obtain the category prediction graph C k . Class Prediction Figure C k The size of is 96×96×K, where K represents the number of categories. K=2 is selected to represent background and tomato respectively.

[0095] Category prediction graph C k The value of each element of is between 0 and 1, indicating the probability that the pixel at that position belongs to a certain category. A mask prediction module consisting of 3×3 convolution, batch normalization (BN) and activation function (ReLU) is used to compress the feature map G′ k Processing is performed to obtain the mask prediction map M k . Mask prediction map M k The size is 96×96×S2 , where S represents the size of the mask, and in the present invention, S=32. Mask prediction graph M k The value of each element of is between 0 and 1, indicating the probability that the pixel at that position belongs to a certain mask. A dynamic convolution generation module consisting of 1×1 convolution, batch normalization (BN) and activation function (ReLU) is used to generate the compressed feature map G′ k Processing is performed to obtain the dynamic convolution kernel W k . Dynamic convolution kernel W k The size of W 2 ×S 2 ×K, where S and K are the same as above. Dynamic convolution kernel W k The value of each element of is a real number, which represents the weight of the convolution kernel at that position. Using dynamic convolution kernel W k Mask prediction map M k Perform dynamic convolution to obtain the dynamic mask map M′ k . Dynamic mask M′ k The size of is 96×96×K, where K is the same as above. k The value of each element of is between 0 and 1, indicating the probability that the pixel at that position belongs to a dynamic mask.

[0096] Using threshold T, class prediction graph C k and dynamic mask M′ k Filter and get the mask of each instance and categories

[0097] Specifically, for each category k, find the category prediction map C k The positions in which the pixel value is greater than the threshold value T are regarded as candidate pixels of this category. For each candidate pixel, find the dynamic mask M′ k The corresponding dynamic mask in is used as the candidate mask for the pixel. For each candidate mask, the number of candidate pixels it contains is calculated as the score of the mask. For each category k, according to the score of the mask, the non-maximum suppression (NMS) method is used to remove the masks with too high overlap to obtain the final mask of the category. and categories The parameters of SOLOv2 used in the present invention are as follows: the number of compressed channels C″″ is 256, the number of categories K is 2, the size of the mask S is 32, the threshold T is 0.5, and the threshold of the overlap is 0.5.

[0098] CondInst is an instance segmentation module based on conditional convolution. It dynamically generates different convolution kernels according to the characteristics of each instance to improve the accuracy and efficiency of segmentation. Conditional convolution is used to generate different convolution kernels. According to the input characteristics, it uses fully connected layers or convolution layers to dynamically generate different convolution kernels to adapt to different targets and scenarios.

[0099] Among them, the core parameter configuration of CondInst is shown in Table 6:

[0100] Table 6 Core parameter configuration table of CondInst

[0101] Parameter name Parameter Value Parameter Explanation num_classes 2 Number of categories strides [8,16,32,64,128] The stride of the feature map base_scale 4 Basic scale num_scales 5 Number of scales aspect_ratios [0.5,1.0,2.0] Aspect Ratio num_bases 15 The number of base frames num_convs 4 Number of dynamic convolution layers num_masks 8 Number of masks mask_size 32 Mask size

[0102] Mask for each instance based on CondInst and categories Processing is performed to obtain the mask of each instance and bounding box

[0103] Specifically, for each instance mask and categories Use adaptive average pooling (AdaptiveAvgPool) to its corresponding feature map G k Perform global pooling to obtain the feature vector of the instance Eigenvector The length of is C″″, where C″″ is the same as above. A conditional convolutional generation module consisting of a fully connected layer, batch normalization (BN) and an activation function (ReLU) is used to generate the feature vector Processing is performed to obtain the conditional convolution kernel

[0104] Conditional convolution kernel The size of is S×S, where S is the same as above. The value of each element of is a real number, which represents the weight of the convolution kernel at that position. Masking of instances Perform conditional convolution to obtain conditional mask Conditional Mask The size of is S×S, where S is the same as above. The value of each element of is between 0 and 1, indicating the probability that the pixel at that position belongs to the instance. Using the bilinear interpolation method, the conditional mask Adjust to the original image i″′ k The same size, that is, H×W, is used to obtain the adjusted conditional mask. Using the threshold T′, the adjusted conditional mask Binarize and obtain the binarized conditional mask Use the minimum enclosing rectangle method to binarize the conditional mask Surround it and get the bounding box of the instance The parameters of CondInst used in the present invention are as follows: the output dimension of the fully connected layer is 1024, the size S of the conditional convolution kernel is 32, and the threshold T′ is 0.5.

[0105] Based on the above instance segmentation method, faster and more accurate instance segmentation is achieved, and SOLOv2 and CondInst are used as instance segmentation modules to improve the shortcomings of anchor boxes and region proposal networks. This step proposes an instance segmentation method, which segments each tomato in the image according to the result of feature fusion, generates a mask and bounding box of the tomato, and obtains the recognition result of the tomato fruit.

[0106] In one embodiment, after determining the mask of the tomatoes and the bounding box of the tomatoes in the tomato image to be segmented, the method further includes: labeling the tomatoes in the tomato image to be segmented to obtain labeling information; evaluating the mask of the tomatoes and the bounding box of the tomatoes based on the mask of the tomatoes and the bounding box of the tomatoes, the labeling information and an evaluation model to determine the difference between the segmentation result and the true labeling, wherein the evaluation model is determined based on the mean average precision, the mean absolute error and the structural similarity index.

[0107] The segmentation results are quantitatively evaluated using segmentation evaluation indicators such as mean average precision (mAP), mean absolute error (MAE), and structural similarity index (SSIM). This step is designed to evaluate the effect of segmentation, and is used to evaluate the accuracy, error, and visual quality of segmentation, and to verify the effectiveness and superiority of the model.

[0108] The specific steps are as follows:

[0109] The mean average precision (mAP) is an indicator used to evaluate the accuracy of segmentation and measure the consistency between the segmentation result and the true annotation. The calculation method of mAP is as follows: for each category k, calculate its precision (Precision) and recall rate (Recall) curve, and then calculate the area under the curve, that is, the average precision (AP). The AP of all categories is averaged to get mAP.

[0110] The parameters of mAP used are as follows: Intersection over Union (IoU) is used as the matching criterion, the IoU threshold is 0.5, and the 11-point interpolation method is used to calculate AP.

[0111] The mean absolute error (MAE) is an indicator used to evaluate the segmentation error, measuring the difference between the segmentation result and the true annotation. The calculation method of MAE is as follows: for each image I″′ k , calculate the segmentation result Compared with the real annotation M k The absolute error of all images is averaged to get MAE.

[0112] The calculation formula of MAE used is as follows:

[0113]

[0114] Where N represents the number of images, H and W represent the height and width of the images, represents the pixel value of the segmentation result of the kth image in the i-th row and j-th column, M k (i,j) represents the pixel value of the true annotation of the k-th image in the i-th row and j-th column.

[0115] The structural similarity index (SSIM) is an indicator used to evaluate the visual quality of segmentation, which measures the similarity of structure, brightness and contrast between the segmentation result and the true annotation. The calculation method of SSIM is as follows: For each image I″′ k , calculate the segmentation result Compared with the real annotation M k The SSIM between the two images is then averaged to get the SSIM of all images.

[0116] The calculation formula of SSIM used in the present invention is as follows:

[0117]

[0118] Where N represents the number of images, Represent the mean of the segmentation result and the true annotation respectively, Represent the variance of the segmentation result and the true annotation respectively, Represents the covariance of the segmentation result and the true annotation, c1, c2 are constants added to avoid the denominator being zero, in this invention c1 = (0.01L) 2 , c2=(0.03L) 2 , where L represents the dynamic range of pixel values, and in the present invention, L=255.

[0119] Using the above segmentation evaluation indicators, the segmentation results of different methods are quantitatively evaluated. The comparison method used is as follows:

[0120] Mask R-CNN, this control model is an instance segmentation method based on anchor boxes and region proposal networks, using ResNet-50 as the backbone network, feature pyramid network (FPN) as the feature fusion module, and RoIAlign as the mask prediction module;

[0121] YOLACT, the control model is an instance segmentation method based on anchor-free boxes, using ResNet-50 as the backbone network, feature pyramid network (FPN) as the feature fusion module, and prototype network (ProtoNet) as the mask prediction module;

[0122] BlendMask, the control model is an instance segmentation method based on anchor-free boxes, using ResNet-50 as the backbone network, adaptive feature selection (AFS) and adaptive feature fusion (AFF) as feature fusion modules, and attention-based mask prediction module (AMPM) as the mask prediction module.

[0123] In one embodiment, the training process of the instance segmentation module includes: obtaining a tomato fruit image dataset, and annotating each tomato in the tomato fruit image dataset at the pixel level to obtain the annotated tomato fruit image dataset; based on a contrast limited adaptive histogram equalization method, a random erasing method, and a style transfer method, expanding the annotated tomato fruit image dataset to obtain an expanded dataset; based on the expanded dataset, training an initial instance segmentation module to obtain the instance segmentation module.

[0124] We obtain a dataset of greenhouse tomato fruit images, annotate each tomato at the pixel level, and generate a tomato mask. Then, we use image enhancement techniques such as contrast-limited adaptive histogram equalization (CLAHE), random erasing, and style transfer to expand the original dataset and generate more training samples. This aims to expand the diversity and quantity of training data, enhance the contrast of images, increase the diversity and difficulty of data by randomly removing some areas or integrating different styles into images, and improve the generalization ability of the model.

[0125] Using the greenhouse tomato fruit dataset, each tomato is annotated at the pixel level to generate a tomato mask. The greenhouse tomato fruit dataset is a set of greenhouse tomato fruit images collected by agricultural technicians. There are N images in total. The resolution of each image is H×W pixels, and the color value of each pixel is C bits. For each image, a binary matrix M∈{0,1} with the same size as the image is used. H×W As a mask, where M i,j =1 means the pixel in row i and column j belongs to tomato fruit, Mi,j = 0 means that the pixel in the i-th row and j-th column belongs to the background. Use manual or semi-automatic methods to accurately annotate each tomato at the pixel level and generate the corresponding mask. Take each image and its mask as a sample to form the original greenhouse tomato fruit dataset. Among them I k represents the kth image, M k represents the kth mask.

[0126] Image enhancement techniques such as contrast limited adaptive histogram equalization (CLAHE), random erasing and style transfer are used to expand the original dataset and generate more training samples.

[0127] For each sample (I k ,M k ), follow the steps below to perform data augmentation:

[0128] Contrast-limited adaptive histogram equalization (CLAHE) is used to enhance the contrast of an image. It dynamically adjusts the brightness and contrast of an image according to the local features of the image to make the details of the image clearer. k After processing, the enhanced image I' is obtained k Specifically, image I k Divide into P×Q sub-blocks of the same size. For each sub-block, calculate its histogram, and according to the given contrast limit parameter L, evenly distribute the part of the histogram exceeding L to other histogram intervals. Then calculate the cumulative distribution function (CDF) of the histogram to obtain the mapping function of each sub-block. For each sub-block, use its mapping function to transform its pixel value to obtain the enhanced sub-block. Finally, use the bilinear interpolation method to splice all sub-blocks into the enhanced image I k The parameters of CLAHE used in the present invention are: the size of the sub-block is 8×8 pixels, and the contrast limit parameter L is 40.

[0129] Random Erasing increases the diversity and difficulty of data by randomly selecting parts of the image and filling them with random color values ​​or mean values ​​to simulate occlusion or noise in the image. The present invention uses random erasing to perform random erasing on each enhanced image I′. k Processing is performed to obtain the erased image I″ k Specifically, for each image I′ k , with a given probability p, randomly select a rectangular area with an area of ​​S and an aspect ratio of r, and fill the area with a random color value or the mean value of the image to obtain the erased image I″k The parameters of random erasure used in the present invention are: probability p is 0.5, area S is 0.02 to 0.4 times of the image area, and aspect ratio r is 0.3 to 3.3.

[0130] Style transfer integrates different styles into an image, and generates an image with similar content to the original image but different style according to a given style image. The present invention uses style transfer to transfer each erased image I″ k After processing, the image I″′ after style transfer is obtained k Specifically, we use the VGG-19 pre-trained convolutional neural network to extract the content features and style features of the image. Content features refer to the information of objects and scenes in the image, and style features refer to the information of color, texture, brushstrokes, etc. For each image I″ k , use the high-level features of the network as content features, and use the low-level features of the network as style features. For each style image S l , use the low-level features of the network as style features. Use the L-BFGS optimization algorithm to generate a new image I″′ k , so that its content characteristics are consistent with I″ k The content features are similar to S l The style features of the present invention are similar. The parameters of style transfer used in the present invention are: the convolutional neural network is VGG-19, the layer of content features is relu4_2, the layers of style features are relu1_1, relu2_1, relu3_1, relu4_1, relu5_1, the weight of content features is 1, the weight of style features is 1000, and the style image S l For 10 different styles.

[0131] For each data augmented image I″′ k , use the same transformation method to transform its corresponding mask M k After processing, the mask M″′ after data enhancement is obtained k Specifically, for each image I″′ k , record the parameters of CLAHE, random erasure, and style migration, including the position of the sub-block, the erased area, the type of style, etc. For each mask M k , use the same parameters to perform the same transformation and obtain the mask M″′ after data enhancement k Note that for random erasing transformations, there is no need to fill the mask. Instead, the mask value corresponding to the erased area is set to 0, indicating that the area belongs to the background. For style transfer transformations, there is no need to process the mask. Instead, the mask needs to be kept at the same size and position as the image.

[0132] Each data-enhanced image I″′″ and its mask M″′ k As a new sample, add it to the original data set D to get the expanded data set Where N′ is the number of samples after expansion, N′>N. The data enhancement method used in the present invention increases the number of data sets by 10 times, that is, N′=10N.

[0133] The above data augmentation method can improve the generalization ability of the tomato fruit instance segmentation model in the greenhouse, enable it to adapt to complex background environments such as different lighting, occlusion, style, etc., and improve the accuracy and robustness of segmentation.

[0134] In one embodiment, after determining the mask of the tomato and the bounding box of the tomato in the tomato image to be segmented, the method further includes: extracting the shape information of the tomato, the texture information of the tomato, and the pest and disease information of the tomato based on the mask of the tomato and the bounding box of the tomato in the tomato image to be segmented; and fitting the shape information, texture information, and pest and disease information based on the CatBoost regression model to obtain the growth status information of the tomato.

[0135] Extract the shape information of the tomato and use the shape analysis method based on geometric features to perform mask analysis on each instance. Processing to obtain the shape descriptor of each tomato

[0136] Specifically, for each mask Use the Canny edge detection contour detection algorithm to find the edge of the mask and get the edge map The Freeman chain code contour tracing algorithm is used to convert the edge map Convert to a series of direction codes to get contour codes Use the Fourier Descriptor (FD) method to encode the contour Perform Fourier transform to get Fourier descriptor The Fourier descriptor was analyzed using the principal component analysis (PCA) method. Perform dimensionality reduction to obtain shape descriptors Shape Descriptor The length of is D, where D is the dimension after dimensionality reduction, and D=16 in the present invention. Shape descriptor The value of each element of is a complex number, which represents the amplitude and phase of the frequency component. The shape analysis method used in the present invention extracts the shape information of the tomato, and uses geometric features as shape descriptors to adapt to different rotations and scalings.

[0137] Extract the texture information of tomatoes, use the texture analysis method based on statistical features, and mask each instance Processing to obtain the texture descriptor of each tomato

[0138] Specifically, for each mask The Gray Level Co-occurrence Matrix (GLCM) method is used to calculate the co-occurrence probability of pixels in the mask at different directions and distances to obtain the gray level co-occurrence matrix Using Haralick feature texture feature extraction algorithm, from the gray level co-occurrence matrix Extract statistical features such as contrast, energy, entropy, and correlation to obtain texture descriptors Texture Descriptor The length of is L, where L is the number of extracted features, and L=8 in the present invention. Texture descriptor The value of each element of is a real number, which represents the value of the feature. The texture analysis method used in the present invention effectively extracts the texture information of tomatoes, uses statistical features as texture descriptors, and adapts to different illumination and noise.

[0139] To extract pest and disease information of tomatoes, the present invention uses a pest and disease identification method based on deep learning to identify the mask of each instance. Process and get the pest and disease label of each tomato

[0140] Specifically, for each mask Use the U-Net image segmentation network to classify the pixels in the mask and obtain the pest segmentation map Pest and disease segmentation map Size and mask The same, that is, H×W, where H and W represent the height and width respectively. The value of each element of is an integer, indicating the category of the pixel. It is assumed that there are 4 categories in the present invention (changed according to actual conditions), representing normal, leaf spot, powdery mildew, and aphids respectively. The maximum majority statistical analysis algorithm is used to segment the pest and disease map Count the pixels in and get the pest label Pest and disease labels The value is an integer, indicating the pest category of the tomato. The pest identification method used is used to extract pest information of tomatoes, and deep learning is used as the pest identification module to improve the accuracy and robustness of identification.

[0141] Construct a growth model for tomatoes in a greenhouse and use a growth prediction method based on machine learning to predict the shape descriptors of each tomato. Texture Descriptor Pest and disease labels Process and get the growth status of each tomato

[0142] Specifically, for each tomato shape descriptor Texture Descriptor Pest and disease labels Use CatBoost regression model to fit it and get the growth status Growth status The value of is a real number, indicating the growth degree of the tomato. The value of is between 0 and 1, 0 means immature and 1 means mature. Using the growth prediction method, the growth model of tomatoes in the greenhouse is effectively constructed, and machine learning is used as the growth prediction module to improve the accuracy and efficiency of the prediction.

[0143] Optionally, in order to predict more attributes of tomatoes, a deep learning-based attribute prediction method can be used to predict the shape descriptor of each tomato. Texture Descriptor Pest and disease labels Growth status Processing to obtain the attribute descriptor of each tomato

[0144] Specifically, for each tomato shape descriptor Texture Descriptor Pest and disease labels Growth status Use the Multi-Layer Perceptron (MLP) classification model to fit it and get the attribute descriptor Property Descriptors The length of is M, where M represents the number of attributes. It is assumed that M=3 in the present invention (change according to actual conditions), which represent variety, sugar content, and hardness respectively. The value of each element of is a real number, indicating the value of the attribute. In the present invention, the value of variety is between 1 and 5, indicating different tomato varieties such as cherry tomatoes and ox heart tomatoes; the value of sugar content is between 0 and 10, indicating the sweetness of tomatoes, the higher the sweeter; the value of hardness is between 0 and 10, indicating the hardness of tomatoes, the higher the hardness, the harder. The attribute prediction method used in the present invention effectively predicts more attributes of tomatoes, and uses deep learning as an attribute prediction module to improve the accuracy and robustness of prediction.

[0145] The results of fruit segmentation are applied to more growth monitoring and management of greenhouse tomatoes. Image analysis technologies such as deep learning, computer vision, and image processing are used to extract more information about tomatoes, build a more sophisticated growth model of greenhouse tomatoes, predict more properties of tomatoes, and provide more decision support for greenhouse tomato planting and harvesting. The comprehensive application method used by the present invention provides more decision support for greenhouse tomato planting and harvesting

[0146] Figure 2 The schematic diagram of the structure of the greenhouse tomato instance segmentation device under complex background environment provided by the present invention is as follows: Figure 2 The device comprises:

[0147] A feature extraction module 210 is used to extract features of the tomato image to be segmented based on a convolutional neural network EfficientNet to obtain a feature map of the tomato image to be segmented;

[0148] A feature map determination module 220, configured to adaptively fuse features of different scales in the feature map based on a feature fusion module to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network;

[0149] The segmentation module 230 is used to perform instance segmentation on the fused feature map based on the instance segmentation module to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0150] The greenhouse tomato instance segmentation device under complex background environment provided by the embodiment of the present invention fuses the features of different levels in the feature map of the tomato image to be segmented through the feature fusion module, thereby improving the feature expression and differentiation capabilities. Based on the instance segmentation module, the fused feature map is instance segmented to obtain the information of its mask and bounding box, effectively realizing the accurate segmentation of greenhouse tomato fruits, providing richer and more detailed image analysis results than semantic segmentation, and improving the accuracy of greenhouse tomato instance segmentation under complex background environment.

[0151] In one embodiment, the feature map determination module 220 is specifically used to:

[0152] Based on the feature fusion module, the different scale features in the feature map are adaptively fused to obtain a fused feature map, including:

[0153] Processing the feature map based on an adaptive feature pyramid to obtain a feature pyramid including different feature layers;

[0154] A multi-scale feature fusion network based on a channel attention mechanism dynamically allocates different channel weights according to different feature layers, and fuses the different feature layers based on the channel weights to obtain a fused feature map.

[0155] In one embodiment, the segmentation module 230 is specifically used to:

[0156] Based on the instance segmentation module, instance segmentation is performed on the fused feature map to determine the mask and bounding box of the tomato in the tomato image to be segmented, including:

[0157] Performing instance segmentation processing on the fused feature map based on SOLOv2 to obtain a mask and a category of each instance in the fused feature map;

[0158] Based on CondInst, instance segmentation processing is performed on the mask of each instance and the category of each instance to obtain the mask of the tomato and the bounding box of the tomato in the tomato image to be segmented.

[0159] In one embodiment, the segmentation module 230 is further specifically configured to:

[0160] After determining the mask of the tomato and the boundary box of the tomato in the tomato image to be segmented, the method further includes:

[0161] Marking tomatoes in the tomato image to be segmented to obtain marking information;

[0162] Based on the tomato mask and the tomato bounding box, the annotation information and the evaluation model, the tomato mask and the tomato bounding box are evaluated to determine the difference between the segmentation result and the true annotation, and the evaluation model is determined based on the average precision mean, the mean absolute error and the structural similarity index.

[0163] In one embodiment, the segmentation module 230 is further specifically configured to:

[0164] The training process of the instance segmentation module includes:

[0165] Acquire a tomato fruit image dataset, and annotate each tomato in the tomato fruit image dataset at the pixel level to obtain the annotated tomato fruit image dataset;

[0166] Based on the contrast-limited adaptive histogram equalization method, the random erasing method and the style transfer method, the annotated tomato fruit image dataset is expanded to obtain an expanded dataset.

[0167] Based on the expanded data set, an initial instance segmentation module is trained to obtain the instance segmentation module.

[0168] In one embodiment, the segmentation module 230 is further specifically configured to:

[0169] After determining the mask of the tomato and the boundary box of the tomato in the tomato image to be segmented, the method further includes:

[0170] Extracting shape information, texture information and pest and disease information of the tomatoes based on the masks of the tomatoes and the bounding boxes of the tomatoes in the tomato image to be segmented;

[0171] Based on the CatBoost regression model, the shape information, texture information and pest and disease information are fitted to obtain the growth status information of the tomato.

[0172] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the greenhouse tomato instance segmentation method under a complex background environment, and the method includes:

[0173] Based on the convolutional neural network EfficientNet, feature extraction is performed on the tomato image to be segmented to obtain a feature map of the tomato image to be segmented;

[0174] Based on a feature fusion module, adaptively fuse the features of different scales in the feature map to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network;

[0175] Based on the instance segmentation module, the fused feature map is subjected to instance segmentation to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0176] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0177] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the computer can execute the greenhouse tomato instance segmentation method under a complex background environment provided by the above methods, the method comprising:

[0178] Based on the convolutional neural network EfficientNet, feature extraction is performed on the tomato image to be segmented to obtain a feature map of the tomato image to be segmented;

[0179] Based on a feature fusion module, adaptively fuse the features of different scales in the feature map to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network;

[0180] Based on the instance segmentation module, the fused feature map is subjected to instance segmentation to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0181] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the above-mentioned greenhouse tomato instance segmentation method under the complex background environment, the method comprising:

[0182] Based on the convolutional neural network EfficientNet, feature extraction is performed on the tomato image to be segmented to obtain a feature map of the tomato image to be segmented;

[0183] Based on a feature fusion module, adaptively fuse the features of different scales in the feature map to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network;

[0184] Based on the instance segmentation module, the fused feature map is subjected to instance segmentation to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

[0185] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0186] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0187] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for segmenting greenhouse tomatoes in complex background environments, characterized in that: The method comprises: Based on the convolutional neural network EfficientNet, feature extraction is performed on the tomato image to be segmented to obtain a feature map of the tomato image to be segmented; Based on a feature fusion module, adaptively fuse the features of different scales in the feature map to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network; Based on the instance segmentation module, the fused feature map is subjected to instance segmentation to determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

2. The method for segmenting greenhouse tomatoes in complex background environments according to claim 1, characterized in that: Based on the feature fusion module, the features of different scales in the feature map are adaptively fused to obtain a fused feature map, including: Processing the feature map based on an adaptive feature pyramid to obtain a feature pyramid including different feature layers; A multi-scale feature fusion network based on a channel attention mechanism dynamically allocates different channel weights according to different feature layers, and fuses the different feature layers based on the channel weights to obtain a fused feature map.

3. The method for segmenting greenhouse tomatoes in complex background environments according to claim 1, characterized in that: The example segmentation module performs example segmentation on the fused feature map to determine a mask and a bounding box of a tomato in the tomato image to be segmented, including: Performing instance segmentation processing on the fused feature map based on SOLOv2 to obtain a mask and a category of each instance in the fused feature map; Based on CondInst, instance segmentation processing is performed on the mask of each instance and the category of each instance to obtain the mask of the tomato and the bounding box of the tomato in the tomato image to be segmented.

4. The method for segmenting greenhouse tomatoes in complex background environments according to claim 1, characterized in that: After determining the mask of the tomato and the boundary box of the tomato in the tomato image to be segmented, the method further includes: Marking tomatoes in the tomato image to be segmented to obtain marking information; Based on the tomato mask and the tomato bounding box, the annotation information and the evaluation model, the tomato mask and the tomato bounding box are evaluated to determine the difference between the segmentation result and the true annotation, and the evaluation model is determined based on the average precision mean, the mean absolute error and the structural similarity index.

5. The method for segmenting greenhouse tomatoes in complex background environment according to claim 1, characterized in that: The training process of the instance segmentation module includes: Acquire a tomato fruit image dataset, and annotate each tomato in the tomato fruit image dataset at the pixel level to obtain the annotated tomato fruit image dataset; Based on the contrast-limited adaptive histogram equalization method, the random erasing method and the style transfer method, the annotated tomato fruit image dataset is expanded to obtain an expanded dataset. Based on the expanded data set, an initial instance segmentation module is trained to obtain the instance segmentation module.

6. The method for segmenting greenhouse tomatoes in complex background environments according to claim 1, characterized in that: After determining the mask of the tomato and the boundary box of the tomato in the tomato image to be segmented, the method further includes: Extracting shape information, texture information and pest and disease information of the tomatoes based on the masks of the tomatoes and the bounding boxes of the tomatoes in the tomato image to be segmented; Based on the CatBoost regression model, the shape information, texture information and pest and disease information are fitted to obtain the growth status information of the tomato.

7. A greenhouse tomato instance segmentation device under complex background environment, characterized in that: include: A feature extraction module, used for performing feature extraction on the tomato image to be segmented based on a convolutional neural network EfficientNet, to obtain a feature map of the tomato image to be segmented; A feature map determination module, used for adaptively fusing features of different scales in the feature map based on a feature fusion module to obtain a fused feature map, wherein the feature fusion module is constructed based on an adaptive feature pyramid combined with a multi-scale attention network; The segmentation module is used to perform instance segmentation on the fused feature map based on the instance segmentation module, and determine the mask and bounding box of the tomato in the tomato image to be segmented. The instance segmentation module is constructed based on the instance segmentation algorithm SOLOv2 combined with the instance segmentation framework CondInst.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for segmenting greenhouse tomato instances in a complex background environment as claimed in any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for segmenting greenhouse tomato instances in a complex background environment as claimed in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for segmenting greenhouse tomato instances in a complex background environment as claimed in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Target fruit instance segmentation method and system

    CN114092487A

  • Image instance segmentation method and device, electronic equipment and storage medium

    CN114419322A

  • Infrared image small target detection method

    CN115546500A

  • Method for identifying real-time position of inspection robot and evaluating tomato counting yield

    CN116681964A

  • Tea garden growth vigor monitoring system and method based on unmanned aerial vehicle aerial photography

    CN117575835A