Method and device for determining fresh weight of lettuce and electronic equipment
Through the combination of multi-modal images and convolutional neural network models, the problem of poor accuracy in determining the fresh weight of facility lettuce is solved, high-accuracy and automated fresh weight detection is achieved, and the complexity and cost of facility lettuce cultivation management are reduced.
Patent Information
- Application Number
- CN202410638725.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-05-22
AI Technical Summary
Existing methods for determining the fresh weight of lettuce in facilities have poor accuracy, traditional manual measurement is inefficient and destructive, and it is difficult to accurately estimate the fresh weight of 3D characteristics based on 2D visible light images.
Using multi-modal images (RGB images and depth images) combined with convolutional neural network models, by fusing feature models and fresh weight prediction models, attention feature maps and multi-modal feature maps are generated, which are mapped to the fresh weight of lettuce to improve estimation. accuracy.
It achieves high-accuracy detection of lettuce fresh weight, has a high degree of automation, reduces manual intervention, reduces cost and complexity, and improves the real-time and efficiency of facility lettuce cultivation management.
Smart Images

Figure CN118570793A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of agricultural data processing, and in particular to a method, a device and an electronic device for determining the fresh weight of lettuce. Background Art
[0002] Due to the short growth cycle of greenhouse lettuce, accurately obtaining the growth parameters of greenhouse lettuce and understanding the growth of lettuce are of great practical significance for farmers to take correct cultivation and management measures in a timely manner and improve the yield and quality of greenhouse lettuce. Fresh weight is a key parameter that characterizes the life activities of greenhouse lettuce and an important indicator of growth. It is also directly related to the yield of greenhouse lettuce. Therefore, the estimation of fresh weight of greenhouse lettuce is of great significance for growth monitoring and fine management. Traditional methods for obtaining growth parameters mainly rely on manual measurement. Although they can obtain more reliable results, they are inefficient, consume a lot of time and resources, are destructive, and the damage caused is irreversible, which makes it difficult to meet the needs of large-scale crop phenotypic information acquisition.
[0003] Currently, computer vision-based methods are widely used to estimate the fresh weight of greenhouse lettuce. However, as a parameter with 3D characteristics, it is difficult to accurately estimate fresh weight based on 2D visible light images alone.
[0004] In summary, the existing methods for determining the fresh weight of greenhouse lettuce have poor accuracy. Summary of the invention
[0005] The present invention provides a method, a device and an electronic device for determining the fresh weight of lettuce, which are used to solve the defect of poor accuracy in determining the fresh weight of lettuce in the prior art and improve the accuracy of determining the fresh weight of lettuce.
[0006] In a first aspect, the present invention provides a method for determining the fresh weight of lettuce, comprising: obtaining a multimodal image of lettuce to be detected, the multimodal image comprising an RGB image and a depth image; inputting the preprocessed multimodal image into at least one fusion feature model to obtain fusion feature information output by the fusion feature model; inputting the fusion feature information and the multimodal image into a fresh weight prediction model to obtain the fresh weight of the lettuce to be detected output by the fresh weight prediction model; wherein the fusion feature model is obtained by training based on a sample multimodal image on the basis of a first preset convolutional neural network model; the fresh weight prediction model is obtained by training based on sample fusion feature information, sample multimodal images and labels of sample fresh weight on the basis of a second preset convolutional neural network model, a unimodal feature extractor of the second preset convolutional neural network model is constructed based on an encoder of the fusion feature model, the fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image, generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to fresh weight, the attention feature map comprising a spatial attention feature map and a channel attention feature map.
[0007] According to the method for determining the fresh weight of lettuce provided by the present invention, the encoder of the fusion feature model includes an RGB feature encoder and a deep feature encoder, and the fresh weight prediction model is obtained based on the following steps: using the RGB feature encoder as an RGB unimodal feature extractor of a second preset convolutional neural network model, and using the deep feature encoder as a deep unimodal feature extractor of the second preset convolutional neural network model; constructing the second preset convolutional neural network model based on the input layer, the RGB unimodal feature extractor, the deep unimodal feature extractor, the multimodal feature fusion module and the output layer; taking the sample fresh weight as the third label, obtaining a third training sample according to the third label, the sample multimodal image and the matching sample fusion feature information, the matching sample fusion feature information is the sample fusion feature information matched with the sample multimodal image; training the second preset convolutional neural network model based on the third training sample to obtain the fresh weight prediction model.
[0008] According to the method for determining the fresh weight of lettuce provided by the present invention, the sample multimodal image includes a sample depth image and a sample RGB image, the fusion feature model includes an RGB fusion feature model and a depth fusion feature model, the first preset convolutional neural network model includes a preset RGB model and a preset depth model, and the fusion feature model is obtained based on the following steps: taking the sample depth image as a first label, obtaining a first training sample according to the first label and the sample RGB image, training the preset RGB model based on the first training sample, and obtaining an RGB fusion feature model; taking the sample RGB image as a second label, obtaining a second training sample according to the second label and the sample depth image, training the preset depth model based on the second training sample, and obtaining a depth fusion feature model.
[0009] According to the method for determining the fresh weight of lettuce provided by the present invention, the fused feature information includes multiple RGB feature maps and multiple depth feature maps, and the fused feature model is used to generate the fused feature information: a depth feature encoder based on the RGB fusion feature model sequentially performs multiple depth feature extractions on the RGB image, and obtains a depth feature map based on the result of each depth feature extraction to obtain multiple depth feature maps; an RGB feature extractor based on the depth fusion feature model sequentially performs multiple RGB feature extractions on the depth image, and obtains an RGB feature map based on the result of each RGB feature extraction to obtain multiple RGB feature maps.
[0010] According to the method for determining the fresh weight of lettuce provided by the present invention, the spatial attention feature map includes an RGB spatial attention feature map and a deep spatial attention feature map, and the fresh weight prediction model is used to generate the spatial attention feature map: multiple RGB feature maps are numbered based on the feature extraction order, the last RGB feature map is average pooled to obtain a first average feature, the last RGB feature map is maximum pooled to obtain a first maximum feature, the first maximum feature and the first average feature are concatenated, convolved and activated to obtain a first weight, and the RGB spatial attention feature map is obtained based on the first weight and the last RGB image, the last RGB image is obtained by performing convolution feature extraction based on the previous RGB unimodal feature map, and the previous RGB unimodal feature map is based on the sum of the previous RGB channel attention feature map and the previous RGB spatial attention feature map. The previous RGB spatial attention feature map is the previous feature map adjacent to the RGB spatial attention feature map; multiple depth feature maps are numbered based on the feature extraction order, the last depth feature map is average pooled to obtain the second average feature, the last depth feature map is maximum pooled to obtain the second maximum feature, the second maximum feature and the second average feature are concatenated, convolved and activated to obtain the second weight, and the depth spatial attention feature map is obtained based on the second weight and the last depth image. The last depth image is obtained by convolution feature extraction based on the previous depth unimodal feature map, the previous depth unimodal feature map is obtained based on the sum of the previous depth channel attention feature map and the previous depth spatial attention feature map, and the previous depth spatial attention feature map is the previous feature map adjacent to the depth spatial attention feature map.
[0011] According to the method for determining the fresh weight of lettuce provided by the present invention, the channel attention feature map includes an RGB channel attention feature map and a depth channel attention feature map, and the fresh weight prediction model is used to generate the channel attention feature map: coordinate attention extraction is performed on the final RGB image to obtain an initial RGB channel attention feature map, and coordinate attention extraction is performed on the final depth image to obtain an initial depth channel attention feature map; based on the fusion result of the initial RGB channel attention feature map and the initial depth channel attention feature map, an RGB channel attention feature map and a depth channel attention feature map are obtained.
[0012] According to the method for determining the fresh weight of lettuce provided by the present invention, the fresh weight prediction model is used to generate a multimodal feature map: based on the sum of the RGB channel attention feature map and the RGB space attention feature map, an RGB unimodal feature map is obtained, and the RGB unimodal feature map is convolved and globally averaged pooled to obtain a target RGB feature map; based on the sum of the depth channel attention feature map and the depth space attention feature map, a depth unimodal feature map is obtained, and the depth unimodal feature map is convolved and globally averaged pooled to obtain a target depth feature map; the target RGB feature map and the target depth feature map are spliced and convolved to obtain a multimodal feature map.
[0013] According to the method for determining the fresh weight of lettuce provided by the present invention, the preprocessed multimodal image is obtained based on the following steps: cropping the multimodal image to obtain a cropped image, the cropped image is centered on the lettuce to be detected and includes the complete lettuce to be detected; based on the cropped image, the minimum pixel value of the lettuce area of the cropped image and the maximum pixel value of the lettuce area of the cropped image, the cropped image is standardized to obtain the preprocessed multimodal image, the lettuce area is the image area including the lettuce to be detected.
[0014] In a second aspect, the present invention provides a device for determining the fresh weight of lettuce, comprising: a multimodal image acquisition module, used to acquire a multimodal image of the lettuce to be detected, the multimodal image comprising an RGB image and a depth image; a fusion feature information determination module, used to input the preprocessed multimodal image into at least one fusion feature model, and acquire the fusion feature information output by the fusion feature model; a fresh weight prediction module, used to input the fusion feature information and the multimodal image into the fresh weight prediction model, and acquire the fresh weight of the lettuce to be detected output by the fresh weight prediction model; wherein the fusion feature model is obtained by training based on sample multimodal images on the basis of a first preset convolutional neural network model; the fresh weight prediction model is obtained by training based on sample fusion feature information, sample multimodal images and labels of sample fresh weight on the basis of a second preset convolutional neural network model, the unimodal feature extractor of the second preset convolutional neural network model is constructed based on an encoder of the fusion feature model, the fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image, generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to fresh weight, the attention feature map comprising a spatial attention feature map and a channel attention feature map.
[0015] In a third aspect, the present invention 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 program, any of the above-mentioned methods for determining the fresh weight of lettuce is implemented.
[0016] The method, device and electronic device for determining the fresh weight of lettuce provided by the present invention obtain a multimodal image of lettuce to be detected, wherein the multimodal image includes an RGB image and a depth image; the preprocessed multimodal image is input into at least one fusion feature model to obtain fusion feature information output by the fusion feature model; the fusion feature information and the multimodal image are input into a fresh weight prediction model to obtain the fresh weight of the lettuce to be detected output by the fresh weight prediction model; wherein the fusion feature model is obtained by training based on a sample multimodal image on the basis of a first preset convolutional neural network model; the fresh weight prediction model is obtained by training based on sample fusion feature information, sample multimodal images and labels of sample fresh weight on the basis of a second preset convolutional neural network model, the unimodal feature extractor of the second preset convolutional neural network model is constructed based on an encoder of the fusion feature model, the fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image, generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to fresh weight, wherein the attention feature map includes a spatial attention feature map and a channel attention feature map. The present invention realizes accurate fusion of RGB image and depth image of lettuce by fusing feature model and fresh weight prediction model, which is beneficial to improve the accuracy of obtaining fresh weight of lettuce. Fresh weight is automatically obtained by fresh weight prediction model, and artificial intelligence technology is used for detection, which has a high degree of automation, can effectively reduce manual intervention in facility lettuce cultivation management, reduce application cost and complexity, and effectively improve the accuracy and real-time performance of facility lettuce fresh weight estimation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are 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.
[0018] Figure 1 This is one of the flow charts of the method for determining the fresh weight of lettuce provided by the present invention;
[0019] Figure 2 This is the second flow chart of the method for determining the fresh weight of lettuce provided by the present invention;
[0020] Figure 3 It is a schematic diagram of the training process of the fusion feature model and the fresh weight prediction model provided by the present invention;
[0021] Figure 4 It is a structural schematic diagram of a device for determining the fresh weight of lettuce provided by the present invention;
[0022] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0023] 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.
[0024] Combine the following Figure 1-Figure 5 The present invention describes a method, device and electronic device for determining the fresh weight of lettuce provided in an embodiment of the present invention.
[0025] Figure 1 FIG. 1 is one of the flow charts of the method for determining the fresh weight of lettuce provided by the present invention, such as Figure 1 As shown, the method for determining the fresh weight of lettuce includes steps S100 to S300, and each step is specifically as follows:
[0026] S100: Acquire a multimodal image of lettuce to be detected.
[0027] Multimodal images include RGB images and depth images.
[0028] It should be noted that the execution subject of the embodiments of the present application can be a server, a computer device, such as a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc.
[0029] The lettuce to be tested in the embodiment of the present invention includes facility lettuce. The depth image can effectively characterize the vertical structural information of facility lettuce, and further fusion with the RGB image (red, green and blue image) can improve the accuracy of fresh weight estimation. However, in different application scenarios, the contribution of RGB images and depth images to fresh weight estimation is different. The existing equivalent stacking fusion method ignores the complementary information between RGB images and depth images, and cannot realize the effective mining and utilization of multimodal images.
[0030] like Figure 1 As shown, a multimodal image of greenhouse lettuce 14 days after transplanting is obtained. The multimodal image includes an RGB image and a depth image, and each RGB image or each depth image contains only one lettuce.
[0031] The preprocessed multimodal image is obtained based on the following steps: cropping the multimodal image to obtain a cropped image, wherein the cropped image is centered on the lettuce to be detected and includes the complete lettuce to be detected; based on the cropped image, the minimum pixel value of the lettuce area of the cropped image, and the maximum pixel value of the lettuce area of the cropped image, the cropped image is standardized to obtain the preprocessed multimodal image, wherein the lettuce area is the image area including the lettuce to be detected.
[0032] Image preprocessing includes: cropping the multimodal image with the lettuce as the center, ensuring that the cropped multimodal image can contain complete lettuce information, and obtaining a cropped image. The cropped image is standardized, and the steps of the standardization process are:
[0033]
[0034] Among them, x' is the preprocessed multimodal image, x is the multimodal image, min(x l ) is the minimum pixel value of the lettuce area in the cropped image, max(x l ) is the maximum pixel value of the lettuce area in the cropped image.
[0035] Furthermore, the size of the preprocessed multimodal image is adjusted, for example, the size of the preprocessed multimodal image is adjusted to 224 pixels×224 pixels.
[0036] S200: Inputting the preprocessed multimodal image into at least one fusion feature model to obtain fusion feature information output by the fusion feature model.
[0037] The fused feature information includes multiple RGB feature maps and multiple depth feature maps. The fused feature model is used to generate the fused feature information: the depth feature encoder based on the RGB fusion feature model performs multiple depth feature extractions on the RGB image in sequence, and obtains a depth feature map based on the result of each depth feature extraction to obtain multiple depth feature maps; the RGB feature encoder based on the depth fusion feature model performs multiple RGB feature extractions on the depth image in sequence, and obtains an RGB feature map based on the result of each RGB feature extraction to obtain multiple RGB feature maps.
[0038] The fusion feature model includes an RGB fusion feature model and a depth fusion feature model. For example, there are 4 depth feature maps. The first depth feature extraction is performed on the RGB image based on the RGB fusion feature model to obtain the first depth feature map (for example, the size is 56×56×64, where 56 is the height, 56 is the width, and 64 is the number of channels or features). Based on the first depth feature map, the second depth feature extraction is performed in sequence to obtain the second depth feature map (for example, the size is 56×56×64), and so on, to obtain the third depth feature map (for example, the size is 28×28×128) and the fourth depth feature map (for example, the size is 14×14×256).
[0039] For example, there are 4 RGB feature maps. The first RGB feature extraction is performed on the depth image based on the deep fusion feature model to obtain the first RGB feature map (for example, the size is 112×112×16). Based on the first RGB feature map, the second RGB feature extraction is performed in sequence to obtain the second RGB feature map (for example, the size is 28×28×24), and so on, to obtain the third RGB feature map (for example, the size is 14×14×40) and the fourth RGB feature map (for example, the size is 7×7×96).
[0040] S300: Inputting the fused feature information and the multimodal image into a fresh weight prediction model to obtain the fresh weight of the lettuce to be tested output by the fresh weight prediction model.
[0041] Among them, the fusion feature model is obtained based on the first preset convolutional neural network model and trained based on the sample multimodal images; the fresh weight prediction model is obtained based on the second preset convolutional neural network model and trained based on the sample fusion feature information, the sample multimodal images and the sample fresh weight labels. The unimodal feature extractor of the second preset convolutional neural network model is constructed based on the encoder of the fusion feature model. The fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image, and generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to fresh weight. The attention feature map includes a spatial attention feature map and a channel attention feature map.
[0042] The spatial attention feature map includes an RGB spatial attention feature map and a deep spatial attention feature map. The fresh weight prediction model is used to generate the spatial attention feature map: multiple RGB feature maps are numbered based on the feature extraction order, the last RGB feature map is average pooled to obtain the first average feature, the last RGB feature map is max pooled to obtain the first maximum feature, the first maximum feature and the first average feature are concatenated, convolved and activated to obtain the first weight, and the RGB spatial attention feature map is obtained based on the first weight and the last RGB image. The last RGB image is obtained by convolution feature extraction based on the previous RGB unimodal feature map, the previous RGB unimodal feature map is obtained based on the sum of the previous RGB channel attention feature map and the previous RGB spatial attention feature map, and the previous RGB The B spatial attention feature map is the previous feature map adjacent to the RGB spatial attention feature map; multiple depth feature maps are numbered based on the feature extraction order, the last depth feature map is average pooled to obtain a second average feature, the last depth feature map is maximum pooled to obtain a second maximum feature, the second maximum feature and the second average feature are concatenated, convolved and activated to obtain a second weight, and a deep spatial attention feature map is obtained based on the second weight and the final depth image. The final depth image is obtained by convolution feature extraction based on the previous deep unimodal feature map, the previous deep unimodal feature map is obtained based on the sum of the previous deep channel attention feature map and the previous deep spatial attention feature map, and the previous deep spatial attention feature map is the previous feature map adjacent to the deep spatial attention feature map.
[0043] The calculation formula of the spatial attention feature map is:
[0044]
[0045] in, is the first weight, is the second weight, SF R is the RGB spatial attention feature map, SF D is the deep spatial attention feature map, is the final RGB image, is the final depth image, is the previous RGB unimodal feature map, is the previous deep unimodal feature map, Conv is the convolution operation, Conv3 is the convolution layer with a convolution kernel of 3×3, Cat is the concatenation process, MaxPool is the maximum pooling process, and AvgPool is the average pooling process. is the last RGB feature map, This is the last deep feature map.
[0046] The channel attention feature map includes the RGB channel attention feature map and the depth channel attention feature map. The fresh weight prediction model is used to generate the channel attention feature map: coordinate attention extraction is performed on the final RGB image to obtain the initial RGB channel attention feature map, and coordinate attention extraction is performed on the final depth image to obtain the initial depth channel attention feature map; based on the fusion result of the initial RGB channel attention feature map and the initial depth channel attention feature map, the RGB channel attention feature map and the depth channel attention feature map are obtained.
[0047] The calculation formula of the channel attention feature map is:
[0048]
[0049] Among them, CA is coordinate attention extraction, MIF is fusion (multimodal fusion attention mechanism), is the final depth image, is the final RGB image, EF D is the initial depth channel attention feature map, EF R is the initial RGB channel attention feature map, CF D Deep channel attention feature map, CF R It is the RGB channel attention feature map.
[0050] The fresh weight prediction model is used to generate a multimodal feature map: based on the sum of the RGB channel attention feature map and the RGB spatial attention feature map, an RGB unimodal feature map is obtained, and the RGB unimodal feature map is convolved and globally averaged pooled to obtain a target RGB feature map; based on the sum of the depth channel attention feature map and the depth spatial attention feature map, a depth unimodal feature map is obtained, and the depth unimodal feature map is convolved and globally averaged pooled to obtain a target depth feature map; the target RGB feature map and the target depth feature map are concatenated and convolved to obtain a multimodal feature map.
[0051] The calculation formula of the multimodal feature map is:
[0052]
[0053] in, is the RGB single-mode feature map, SF R is the RGB spatial attention feature map, CF R is the RGB channel attention feature map, is the deep unimodal feature map, SF D is the deep spatial attention feature map, CF Dis the deep channel attention feature map, CBR is the combination of convolution with a convolution kernel of 3×3, normalization and rectified linear unit ReLU layers, FCBR is the combination of convolution with a convolution kernel of 1×1, normalization and rectified linear unit ReLU layers, Cat is the concatenation process, F is the multimodal feature map, and GAP is the global average pooling process.
[0054] A first weight is obtained according to the first RGB feature map, and a first RGB spatial attention feature map is obtained according to the first weight and the first RGB image (the RGB image input to the fresh weight prediction model for the first time is obtained by performing convolution feature extraction). A second weight is obtained according to the first depth feature map, and a first depth spatial attention feature map is obtained according to the second weight and the first depth image (the depth image input to the fresh weight prediction model for the first time is obtained by performing convolution feature extraction).
[0055] Perform coordinate attention extraction on the first RGB image to obtain the first initial RGB channel attention feature map. Perform coordinate attention extraction on the first depth image to obtain the first initial depth channel attention feature map. Perform multimodal fusion attention mechanism fusion on the first initial RGB channel attention feature map and the first initial depth channel attention feature map to obtain the first RGB channel attention feature map and the first depth channel attention feature map.
[0056] Based on the sum of the first RGB channel attention feature map and the first RGB spatial attention feature map, the first RGB unimodal feature map is obtained. Perform convolution feature extraction on the first RGB unimodal feature map to obtain the second RGB image. Based on the sum of the first depth channel attention feature map and the first depth spatial attention feature map, the first depth unimodal feature map is obtained. Perform convolution feature extraction on the first depth unimodal feature map to obtain the second depth image. Repeat the above operation until the previous RGB unimodal feature map is obtained. And the previous deep unimodal feature map Perform convolution feature extraction on the previous RGB single-modal feature map to obtain the final depth image Perform convolution feature extraction on the previous deep single-modal feature map to obtain the final RGB image
[0057] Based on the above steps, a multimodal feature map is obtained according to the last depth image, the last RGB image, the last RGB feature map and the last depth feature map. The fresh weight prediction model further maps the multimodal feature map to fresh weight.
[0058] The method for determining the fresh weight of lettuce provided by an embodiment of the present invention comprises the following steps: obtaining a multimodal image of the lettuce to be detected, wherein the multimodal image comprises an RGB image and a depth image; inputting the preprocessed multimodal image into at least one fusion feature model to obtain fusion feature information output by the fusion feature model; inputting the fusion feature information and the multimodal image into a fresh weight prediction model to obtain the fresh weight of the lettuce to be detected output by the fresh weight prediction model; wherein the fusion feature model is obtained by training based on a sample multimodal image on the basis of a first preset convolutional neural network model; the fresh weight prediction model is obtained by training based on sample fusion feature information, sample multimodal images and labels of sample fresh weight on the basis of a second preset convolutional neural network model; a unimodal feature extractor of the second preset convolutional neural network model is constructed based on an encoder of the fusion feature model; the fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image; based on the attention feature map, a multimodal feature map is generated; the multimodal feature map is mapped to fresh weight; the attention feature map comprises a spatial attention feature map and a channel attention feature map. The present invention realizes accurate fusion of RGB image and depth image of lettuce by fusing feature model and fresh weight prediction model, which is beneficial to improve the accuracy of obtaining fresh weight of lettuce. Fresh weight is automatically obtained by fresh weight prediction model, and artificial intelligence technology is used for detection, which has a high degree of automation, can effectively reduce manual intervention in facility lettuce cultivation management, reduce application cost and complexity, and effectively improve the accuracy and real-time performance of facility lettuce fresh weight estimation.
[0059] Based on the above embodiment, the encoder of the fusion feature model includes an RGB feature encoder and a depth feature encoder, and the fresh weight prediction model is obtained based on the following steps:
[0060] S400: Using the RGB feature encoder as the RGB unimodal feature extractor of the second preset convolutional neural network model, and using the depth feature encoder as the depth unimodal feature extractor of the second preset convolutional neural network model.
[0061] S500: Construct a second preset convolutional neural network model based on the input layer, the RGB unimodal feature extractor, the deep unimodal feature extractor, the multimodal feature fusion module and the output layer.
[0062] S600: Taking the sample fresh weight as a third label, obtaining a third training sample according to the third label, the sample multimodal image and the matching sample fusion feature information, where the matching sample fusion feature information is the sample fusion feature information matched with the sample multimodal image.
[0063] S700: Training a second preset convolutional neural network model based on the third training sample to obtain a fresh weight prediction model.
[0064] like Figure 3As shown, a second preset convolutional neural network model is constructed, and the second preset convolutional neural network model includes 1 input layer, 1 multimodal feature extractor and 1 output layer. The multimodal feature extractor includes 2 parallel unimodal feature extractors (deep unimodal feature extractor and RGB unimodal feature extractor) and a multimodal feature fusion module. The deep unimodal feature extractor adopts the deep feature encoder part of the RGB fusion feature model. The RGB unimodal feature extractor adopts the RGB feature encoder part of the deep fusion feature model.
[0065] When training the second preset convolutional neural network model, the sample fresh weight is used as the third label. The sample fusion feature information and the sample multimodal image corresponding to the sample fusion feature information are labeled according to the third label to obtain a third training sample carrying the label. The second preset convolutional neural network model is trained according to the third training sample until the output error of the second preset convolutional neural network model is less than the third set threshold, and the training is terminated to obtain a fresh weight prediction model.
[0066] The present invention realizes accurate fusion of RGB feature map and depth feature map through a fresh weight prediction model, and predicts fresh weight according to the fusion result, thereby improving the accuracy and efficiency of predicting fresh weight.
[0067] Based on the above embodiment, the fusion feature model includes an RGB fusion feature model and a depth fusion feature model, the first preset convolutional neural network model includes a preset RGB model and a preset depth model, and the fusion feature model is obtained based on the following steps:
[0068] S800: Taking the sample depth image as the first label, obtaining a first training sample according to the first label and the sample RGB image, and training a preset RGB model based on the first training sample to obtain an RGB fusion feature model;
[0069] S900: Taking the sample RGB image as the second label, obtaining a second training sample according to the second label and the sample depth image, and training a preset depth model based on the second training sample to obtain a depth fusion feature model.
[0070] Both the RGB fusion feature model and the deep fusion feature model use an encoder-decoder architecture similar to Unet. For example, the preset RGB model uses a Unet structure with Squeeze-and-Excitation ResNet-18 (SeResnet18) as the encoder. The preset deep model uses a Unet structure with MobileNetV3_Large as the encoder.
[0071] like Figure 3As shown, an RGB fusion feature model and a depth fusion feature model are constructed through bidirectional modeling training. When training the preset RGB model, the sample depth image is used as the first label. The sample RGB image is labeled according to the first label to obtain a first training sample with the label. The preset RGB model is trained according to the first training sample until the output error of the preset RGB model is less than the first set threshold, and the training is terminated to obtain the RGB fusion feature model.
[0072] When training the preset depth model, the sample RGB image is used as the second label, and the sample depth image is labeled according to the second label to obtain a second training sample with the label. The preset depth model is trained according to the second training sample until the output error of the preset depth model is less than the second set threshold, and the training is terminated to obtain a deep fusion feature model.
[0073] The present invention realizes efficient feature extraction of RGB images and depth images of lettuce by training a fusion feature model.
[0074] The embodiment of the present invention also provides a device for determining the fresh weight of lettuce, such as Figure 4 As shown, Figure 4 It should be noted that the device for determining the fresh weight of lettuce provided in the embodiment of the present invention can execute the method for determining the fresh weight of lettuce described in any of the above embodiments during specific operation, which will not be described in detail in this embodiment.
[0075] Reference Figure 4 , an embodiment of the present invention provides a device for determining the fresh weight of lettuce, comprising:
[0076] The multimodal image acquisition module 401 is used to acquire a multimodal image of the lettuce to be detected, where the multimodal image includes an RGB image and a depth image.
[0077] The fusion feature information determination module 402 is used to input the preprocessed multimodal image into at least one fusion feature model to obtain the fusion feature information output by the fusion feature model.
[0078] The fresh weight prediction module 403 is used to input the fused feature information and the multimodal image into the fresh weight prediction model, and obtain the fresh weight of the lettuce to be tested output by the fresh weight prediction model; wherein, the fused feature model is obtained based on the first preset convolutional neural network model and trained based on the sample multimodal image; the fresh weight prediction model is obtained based on the second preset convolutional neural network model and trained based on the sample fused feature information, the sample multimodal image and the sample fresh weight label, the unimodal feature extractor of the second preset convolutional neural network model is constructed based on the encoder of the fused feature model, the fresh weight prediction model generates an attention feature map based on the fused feature information and the multimodal image, generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to fresh weight, and the attention feature map includes a spatial attention feature map and a channel attention feature map.
[0079] The fresh weight determination device of lettuce provided by the embodiment of the present invention obtains a multimodal image of lettuce to be detected, wherein the multimodal image includes an RGB image and a depth image; the preprocessed multimodal image is input into at least one fusion feature model to obtain fusion feature information output by the fusion feature model; the fusion feature information and the multimodal image are input into a fresh weight prediction model to obtain the fresh weight of the lettuce to be detected output by the fresh weight prediction model; wherein the fusion feature model is obtained by training based on sample multimodal images on the basis of a first preset convolutional neural network model; the fresh weight prediction model is obtained by training based on sample fusion feature information, sample multimodal images and labels of sample fresh weight on the basis of a second preset convolutional neural network model, the unimodal feature extractor of the second preset convolutional neural network model is constructed based on an encoder of the fusion feature model, the fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image, generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to fresh weight, wherein the attention feature map includes a spatial attention feature map and a channel attention feature map. The present invention realizes accurate fusion of RGB image and depth image of lettuce by fusing feature model and fresh weight prediction model, which is beneficial to improve the accuracy of obtaining fresh weight of lettuce. Fresh weight is automatically obtained by fresh weight prediction model, and artificial intelligence technology is used for detection, which has a high degree of automation, can effectively reduce manual intervention in facility lettuce cultivation management, reduce application cost and complexity, and effectively improve the accuracy and real-time performance of facility lettuce fresh weight estimation.
[0080] In one embodiment, the encoder of the fusion feature model includes an RGB feature encoder and a deep feature encoder, and the fresh weight prediction module 403 is used to: use the RGB feature encoder as an RGB unimodal feature extractor of the second preset convolutional neural network model, and use the deep feature encoder as a deep unimodal feature extractor of the second preset convolutional neural network model; construct the second preset convolutional neural network model based on the input layer, the RGB unimodal feature extractor, the deep unimodal feature extractor, the multimodal feature fusion module and the output layer; use the sample fresh weight as the third label, and obtain the third training sample according to the third label, the sample multimodal image and the matching sample fusion feature information, the matching sample fusion feature information is the sample fusion feature information matched with the sample multimodal image; train the second preset convolutional neural network model based on the third training sample to obtain a fresh weight prediction model.
[0081] In one embodiment, the sample multimodal image includes a sample depth image and a sample RGB image, the fusion feature model includes an RGB fusion feature model and a depth fusion feature model, the first preset convolutional neural network model includes a preset RGB model and a preset depth model, and the fusion feature information determination module 402 is used to: use the sample depth image as the first label, obtain a first training sample based on the first label and the sample RGB image, train the preset RGB model based on the first training sample, and obtain an RGB fusion feature model; use the sample RGB image as the second label, obtain a second training sample based on the second label and the sample depth image, train the preset depth model based on the second training sample, and obtain a depth fusion feature model.
[0082] In one embodiment, the fused feature information includes multiple RGB feature maps and multiple depth feature maps, and the fused feature information determination module 402 is used to: perform multiple depth feature extractions on the RGB image in sequence based on a depth feature encoder based on an RGB fusion feature model, and obtain a depth feature map based on the result of each depth feature extraction to obtain multiple depth feature maps; and perform multiple RGB feature extractions on the depth image in sequence based on an RGB feature extractor based on a depth fusion feature model, and obtain an RGB feature map based on the result of each RGB feature extraction to obtain multiple RGB feature maps.
[0083] In one embodiment, the spatial attention feature map includes an RGB spatial attention feature map and a depth spatial attention feature map, and the fresh weight prediction module 403 is used to: number multiple RGB feature maps based on the feature extraction order, perform average pooling processing on the last RGB feature map to obtain a first average feature, perform maximum pooling processing on the last RGB feature map to obtain a first maximum feature, concatenate, convolve and activate the first maximum feature and the first average feature to obtain a first weight, and obtain an RGB spatial attention feature map based on the first weight and the last RGB image, the last RGB image is obtained by performing convolution feature extraction based on the previous RGB unimodal feature map, the previous RGB unimodal feature map is obtained based on the sum of the previous RGB channel attention feature map and the previous RGB spatial attention feature map, and the previous RGB The GB spatial attention feature map is the previous feature map adjacent to the RGB spatial attention feature map; multiple depth feature maps are numbered based on the feature extraction order, the last depth feature map is average pooled to obtain a second average feature, the last depth feature map is maximum pooled to obtain a second maximum feature, the second maximum feature and the second average feature are concatenated, convolved and activated to obtain a second weight, and a deep spatial attention feature map is obtained based on the second weight and the final depth image. The final depth image is obtained by convolution feature extraction based on the previous deep unimodal feature map, the previous deep unimodal feature map is obtained based on the sum of the previous deep channel attention feature map and the previous deep spatial attention feature map, and the previous deep spatial attention feature map is the previous feature map adjacent to the deep spatial attention feature map.
[0084] In one embodiment, the channel attention feature map includes an RGB channel attention feature map and a depth channel attention feature map, and the fresh weight prediction module 403 is used to: perform coordinate attention extraction on the final RGB image to obtain an initial RGB channel attention feature map, perform coordinate attention extraction on the final depth image to obtain an initial depth channel attention feature map; based on the fusion result of the initial RGB channel attention feature map and the initial depth channel attention feature map, obtain the RGB channel attention feature map and the depth channel attention feature map.
[0085] In one embodiment, the fresh weight prediction module 403 is used to: obtain an RGB unimodal feature map based on the sum of the RGB channel attention feature map and the RGB spatial attention feature map, perform convolution and global average pooling on the RGB unimodal feature map, and obtain a target RGB feature map; obtain a depth unimodal feature map based on the sum of the depth channel attention feature map and the depth spatial attention feature map, perform convolution and global average pooling on the depth unimodal feature map, and obtain a target depth feature map; concatenate and convolve the target RGB feature map and the target depth feature map to obtain a multimodal feature map.
[0086] In one embodiment, the fusion feature information determination module 402 is used to: crop the multimodal image to obtain a cropped image, wherein the cropped image is centered on the lettuce to be detected and includes the complete lettuce to be detected; based on the cropped image, the minimum pixel value of the lettuce area of the cropped image, and the maximum pixel value of the lettuce area of the cropped image, the cropped image is standardized to obtain a preprocessed multimodal image, wherein the lettuce area is the image area including the lettuce to be detected.
[0087] Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor (processor) 510, a communication interface (CommunicationsInterface) 520, a memory (memory) 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call the logic instructions in the memory 530 to execute the method for determining the fresh weight of lettuce, which includes: obtaining a multimodal image of the lettuce to be detected, the multimodal image including an RGB image and a depth image; inputting the preprocessed multimodal image into at least one fusion feature model to obtain the fusion feature information output by the fusion feature model; inputting the fusion feature information and the multimodal image into the fresh weight prediction model to obtain the fresh weight of the lettuce to be detected output by the fresh weight prediction model; wherein the fusion feature model is obtained by training based on the sample multimodal image on the basis of the first preset convolutional neural network model; the fresh weight prediction model is obtained by training based on the sample fusion feature information, the sample multimodal image and the label of the sample fresh weight on the basis of the second preset convolutional neural network model, the unimodal feature extractor of the second preset convolutional neural network model is constructed based on the encoder of the fusion feature model, the fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image, generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to fresh weight, and the attention feature map includes a spatial attention feature map and a channel attention feature map.
[0088] In addition, the logic instructions in the above-mentioned memory 530 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 is essentially 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 to enable 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.
[0089] 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.
[0090] 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.
[0091] 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 determining the fresh weight of lettuce, characterized in that: include: Acquire a multimodal image of the lettuce to be detected, wherein the multimodal image includes an RGB image and a depth image; Inputting the preprocessed multimodal image into at least one fusion feature model to obtain fusion feature information output by the fusion feature model; Inputting the fused feature information and the multimodal image into a fresh weight prediction model, and obtaining the fresh weight of the lettuce to be detected output by the fresh weight prediction model; Among them, the fusion feature model is obtained based on the first preset convolutional neural network model and trained based on the sample multimodal image; the fresh weight prediction model is obtained based on the second preset convolutional neural network model and trained based on the sample fusion feature information, the sample multimodal image and the sample fresh weight label. The unimodal feature extractor of the second preset convolutional neural network model is constructed based on the encoder of the fusion feature model. The fresh weight prediction model generates an attention feature map based on the fusion feature information and the multimodal image, and generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to the fresh weight. The attention feature map includes a spatial attention feature map and a channel attention feature map.
2. The method for determining the fresh weight of lettuce according to claim 1, characterized in that: The encoder of the fusion feature model includes an RGB feature encoder and a depth feature encoder, and the fresh weight prediction model is obtained based on the following steps: Using the RGB feature encoder as an RGB unimodal feature extractor of the second preset convolutional neural network model, and using the deep feature encoder as a deep unimodal feature extractor of the second preset convolutional neural network model; Constructing the second preset convolutional neural network model based on the input layer, the RGB unimodal feature extractor, the deep unimodal feature extractor, the multimodal feature fusion module and the output layer; Taking the sample fresh weight as a third label, obtaining a third training sample according to the third label, the sample multimodal image and matching sample fusion feature information, wherein the matching sample fusion feature information is sample fusion feature information matched with the sample multimodal image; The second preset convolutional neural network model is trained based on the third training sample to obtain the fresh weight prediction model.
3. The method for determining the fresh weight of lettuce according to claim 1, characterized in that: The sample multimodal image includes a sample depth image and a sample RGB image, the fusion feature model includes an RGB fusion feature model and a depth fusion feature model, the first preset convolutional neural network model includes a preset RGB model and a preset depth model, and the fusion feature model is obtained based on the following steps: Taking the sample depth image as a first label, obtaining a first training sample according to the first label and the sample RGB image, and training the preset RGB model based on the first training sample to obtain the RGB fusion feature model; The sample RGB image is used as a second label, a second training sample is obtained according to the second label and the sample depth image, and the preset depth model is trained based on the second training sample to obtain the depth fusion feature model.
4. The method for determining the fresh weight of lettuce according to claim 3, characterized in that: The fused feature information includes multiple RGB feature maps and multiple depth feature maps, and the fused feature model is used to generate the fused feature information: The depth feature encoder based on the RGB fusion feature model sequentially performs multiple depth feature extractions on the RGB image, and obtains the depth feature map based on the result of each depth feature extraction, so as to obtain multiple depth feature maps; The RGB feature extractor based on the depth fusion feature model performs multiple RGB feature extractions on the depth image in sequence, and obtains the RGB feature map based on the result of each RGB feature extraction, so as to obtain multiple RGB feature maps.
5. The method for determining the fresh weight of lettuce according to claim 4, characterized in that: The spatial attention feature map includes an RGB spatial attention feature map and a depth spatial attention feature map, and the fresh weight prediction model is used to generate the spatial attention feature map: Numbering the plurality of RGB feature maps based on a feature extraction order, performing average pooling processing on the last RGB feature map to obtain a first average feature, performing maximum pooling processing on the last RGB feature map to obtain a first maximum feature, performing splicing, convolution and activation processing on the first maximum feature and the first average feature to obtain a first weight, and obtaining the RGB spatial attention feature map based on the first weight and the last RGB image, wherein the last RGB image is obtained by performing convolution feature extraction based on a previous RGB unimodal feature map, the previous RGB unimodal feature map is obtained by adding a previous RGB channel attention feature map and a previous RGB spatial attention feature map, and the previous RGB spatial attention feature map is a previous feature map adjacent to the RGB spatial attention feature map; The multiple depth feature maps are numbered based on the feature extraction order, the last depth feature map is average pooled to obtain a second average feature, the last depth feature map is maximum pooled to obtain a second maximum feature, the second maximum feature and the second average feature are concatenated, convolved and activated to obtain a second weight, and the depth spatial attention feature map is obtained based on the second weight and the last depth image, the last depth image is obtained by convolution feature extraction based on the previous depth unimodal feature map, the previous depth unimodal feature map is obtained based on the sum of the previous depth channel attention feature map and the previous depth spatial attention feature map, and the previous depth spatial attention feature map is the previous feature map adjacent to the depth spatial attention feature map.
6. The method for determining the fresh weight of lettuce according to claim 5, characterized in that: The channel attention feature map includes an RGB channel attention feature map and a depth channel attention feature map, and the fresh weight prediction model is used to generate the channel attention feature map: Performing coordinate attention extraction on the final RGB image to obtain an initial RGB channel attention feature map, and performing the coordinate attention extraction on the final depth image to obtain an initial depth channel attention feature map; Based on the fusion result of the initial RGB channel attention feature map and the initial depth channel attention feature map, the RGB channel attention feature map and the depth channel attention feature map are obtained.
7. The method for determining the fresh weight of lettuce according to claim 6, characterized in that: The fresh weight prediction model is used to generate the multimodal feature map: Based on the sum of the RGB channel attention feature map and the RGB spatial attention feature map, an RGB unimodal feature map is obtained, and convolution and global average pooling are performed on the RGB unimodal feature map to obtain a target RGB feature map; Based on the sum of the deep channel attention feature map and the deep spatial attention feature map, a deep unimodal feature map is obtained, and convolution and global average pooling are performed on the deep unimodal feature map to obtain a target deep feature map; The target RGB feature map and the target depth feature map are concatenated and convolved to obtain the multimodal feature map.
8. The method for determining the fresh weight of lettuce according to claim 1, characterized in that: The preprocessed multimodal image is obtained based on the following steps: Cropping the multimodal image to obtain a cropped image, wherein the cropped image is centered on the lettuce to be detected and includes the entire lettuce to be detected; Based on the cropped image, the minimum pixel value of the lettuce region of the cropped image and the maximum pixel value of the lettuce region of the cropped image, the cropped image is standardized to obtain the preprocessed multimodal image, wherein the lettuce region is an image region including the lettuce to be detected.
9. A device for determining the fresh weight of lettuce, characterized in that: include: A multimodal image acquisition module, used to acquire a multimodal image of the lettuce to be detected, wherein the multimodal image includes an RGB image and a depth image; A fusion feature information determination module, used to input the preprocessed multimodal image into at least one fusion feature model to obtain fusion feature information output by the fusion feature model; A fresh weight prediction module is used to input the fused feature information and the multimodal image into a fresh weight prediction model, and obtain the fresh weight of the lettuce to be detected output by the fresh weight prediction model; wherein the fused feature model is obtained by training based on a sample multimodal image on the basis of a first preset convolutional neural network model; the fresh weight prediction model is obtained by training based on sample fused feature information, sample multimodal images and sample fresh weight labels on the basis of a second preset convolutional neural network model, the unimodal feature extractor of the second preset convolutional neural network model is constructed based on the encoder of the fused feature model, the fresh weight prediction model generates an attention feature map based on the fused feature information and the multimodal image, generates a multimodal feature map based on the attention feature map, and maps the multimodal feature map to the fresh weight, the attention feature map includes a spatial attention feature map and a channel attention feature map.
10. 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 determining the fresh weight of lettuce according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Target detection method based on cross-modal multi-scale feature fusion
CN108734210A
Weight measurement method, device, equipment and storage medium
CN116263949A
RGB-D saliency target detection method based on depth quality weighting
CN116310396A
Leaf vegetable growth state detection method based on RGB-D image recognition
CN117935055A
