One-stage multi-mode bad weather fruit detection method
By collecting multimodal data in agricultural scenarios and building a deep learning detection model, the problems of low image denoising efficiency, inappropriate and poor generalization in existing bad weather fruit detection technology are solved, and efficient and accurate detection of bad weather fruits is achieved.
Patent Information
- Application Number
- CN202510133515.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-06
- Publication Date
- 2025-05-30
AI Technical Summary
The existing severe weather fruit detection technology has problems such as low image denoising efficiency, inadequate suitable for agricultural scenarios, poor generalization caused by relying on image quality and two-stage detection methods.
A one-stage multimodal detection method is adopted to collect fruit images and point cloud data on the spot in agricultural scenarios, perform data preprocessing and feature extraction, and build a multimodal bad weather fruit detection model, directly detect on the image, reduce pre-processing steps, and improve detection effect through deep learning modular convolutional neural network.
It realizes accurate detection without image preprocessing in bad weather, simplifies training steps, improves the adaptability and generalization of the model, is suitable for fruit detection in agricultural scenarios, and significantly improves detection performance.
Smart Images

Figure CN120071311A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of agricultural science and technology, and particularly relates to a one-stage multi-modal fruit detection method under bad weather. Background Art
[0002] Automated picking requires the drive of computer vision technology. In this process, sensors are affected by weather factors when perceiving fruits, that is, the introduction of bad weather conditions brings greater difficulties to the target detection task in agricultural scenarios. Traditional target detection algorithms mainly rely on manually extracting features, manually selecting regions of interest, classifying features in regions that may contain targets, and finally detecting the features. With the progress of technology, the computing power of computers can already handle the intensive calculations required for feature extraction in target detection tasks, and target detection algorithms based on deep learning have developed rapidly, forming two-stage methods based on the anchor mechanism, single-stage methods based on the anchor mechanism, and algorithms that do not rely on the anchor mechanism (Anchor-free). Algorithms that rely on the anchor mechanism have problems such as poor adaptability, low detection ability for targets of different sizes, and low computational efficiency. Therefore, the method that does not rely on the anchor mechanism is adopted at the beginning of the design of the present invention. For target detection under bad weather, current various improvement methods usually adopt a two-stage form, that is, first use a denoising module to improve the image quality under the influence of bad weather, and then detect on the image with higher quality to improve the detection accuracy. Although the means of improving image quality can slightly improve the detection accuracy, it only solves the problem of slightly reducing the impact of noise on the detection model, and the existing detection models for bad weather are not applicable to agricultural scenarios.
[0003] There are some imperfections in the existing bad weather fruit detection technologies: (1) The preprocessing stage of the existing method for denoising images to improve image quality has low efficiency and reduces real-time performance; (2) The existing methods only consider the impact of weather factors on the detection performance of the model, and do not consider the adaptability of the model to specific agricultural scenarios; (3) Most of the existing methods are two-stage detection methods, with cumbersome steps, poor generalization, and strong dependence on picture data; (4) The existing methods are single-modal methods. Single-modal methods can only rely on the features contained in the image when solving problems. The present invention constructs a multi-modal method by introducing additional information as a supplement to the image features, improving the applicability and reliability of the detection method. Therefore, it is necessary to propose a one-stage multi-modal bad weather fruit detection method to solve the above problems. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a one-stage multi-modal fruit detection method for bad weather, which can perform accurate detection without pre-processing the image, reducing the training time and cumbersome steps. For the module with poor generalization of the existing method for low visibility, and for the problem that the existing method is not applicable to agricultural scenarios, corresponding coding methods are designed. Before designing the detection framework, a dataset LVScene4K containing images and point clouds of different crop fruits is collected and data augmentation is performed on it to verify the reliability of the detection method under different conditions, and a fruit detection benchmark for agricultural scenarios in bad weather is established based on the verification results of the dataset.
[0005] To achieve the above technical effects, the technical solution adopted by the present invention is as follows: A one-stage multi-modal fruit detection method for bad weather, comprising the following steps: S1, collecting fruit image data and point cloud data on-site in agricultural scenarios; the agricultural scenarios specifically include farmlands of individual business operators, commercial farms, university experimental fields, and large-scale planting bases on-site; when collecting the dataset, data is acquired by moving at equal distances and rotating at equal angles based on the sensor component. S2, performing data preprocessing on the collected image data and point cloud data, including data format conversion, data cleaning, data annotation, and data augmentation; S3, performing feature extraction and pseudo-feature map creation on the fruit point cloud data after data preprocessing; S4, inputting the fruit image and the point cloud pseudo-feature map to construct a multi-modal bad weather fruit detection model; S5, detecting the fruits in the image through the constructed multi-modal bad weather fruit detection model and outputting a detection result mask; S6, comprehensively evaluating the model.
[0006] Preferably, step S2 includes: S201, naming the image data obtained in step S1 in sequence and converting the point cloud into the pcd format readable by the model; S202, deleting the images and point clouds that do not meet the task requirements; S203, labeling the fruits in the image as binary mask pictures as the ground truth; S204, degrading the image quality, adding challenging weather conditions such as rain, snow, and fog to the image, taking the original dataset as the "easy" sample, and the dataset after data augmentation as the "difficult" sample, and performing the same training set and test set division.
[0007] Preferably, step S3 includes using PointNet++ to extract features from the point cloud data, and then projecting the point cloud features onto the image according to the position of the center point by the projection method to generate a pseudo-feature map. The specific method is as follows: The point cloud features are output by the point cloud encoder , in order to utilize the point cloud features extracted by the point cloud encoder, first project the point cloud onto the image coordinate system. Before that, the calibration and alignment between the camera and the lidar are performed to define an accurate projection; Given a point cloud , for the points in the point cloud , calculate the 2D coordinates on the image corresponding to the point coordinates through the camera's internal and external parameters, and create a point feature map based on this; As shown in Equation (1), project the point features onto the image based on the feature center point coordinates to create a pseudo-image, and finally obtain the pseudo-image feature as : ; (1) where , are the internal and external parameters of the camera respectively; , respectively represent the original three-dimensional coordinates and the projected two-dimensional coordinates of the point .
[0008] Preferably, in step S4, input the fruit image and the point cloud pseudo-feature map. Constructing a multi-modal fruit detection model in bad weather includes inputting the preprocessed image data and the point cloud pseudo-feature map, and constructing a multi-modal fruit detection model to learn and predict the binary mask of the fruit position, which specifically includes an encoding stage, a fusion stage, a decoding stage, and an iterative stage; in the encoding stage, use the PVT Pyramid Vision Transformer and the improved Spatial Pyramid Pooling MSPP structure to obtain the multi-scale features of the image, enabling the model to learn the target features from multiple scales; concatenate the input image and the pseudo-feature map on the batch dimension, and the features obtained after encoding by PVT and MSPP are: ; In the formula, represents different-sized features, n represents different-sized feature levels, R represents the feature shape, B represents the number of images in the batch input, C represents the number of feature channels, and H and W respectively represent the width and height of the features.
[0009] Preferably, in the fusion stage, use the CMF module based on the cross-attention mechanism to enable the model to dynamically capture the correlation between the two modalities; During the initialization process of the module, use three convolutional layers to convert the input image and point features into queries , keys Sum value Characterize; for each query That is, the image feature, calculates the attention affinity matrix with the key through the inner product and uses function for normalization; The attention affinity matrix weights and aggregates the values containing point features Add the aggregated point cloud information to the original image feature element by element, and after layer normalization, obtain the point-guided image feature. The output weighted feature set is expressed as: ; Through attention weighting, enable the model to better align and highlight the most relevant point features and image features during the learning process; connect these features, and at the same time use element-wise addition and element-wise multiplication for feature aggregation; to avoid the model over-focusing on one modality due to the direct element-wise addition method. This ensures that the fused features can make full use of the complementarity of the two modalities while emphasizing their common points; the feature aggregation formula is as follows: ; (2) where represents element-wise addition, represents element-wise multiplication; after obtaining the preliminary fused feature continue to apply the attention mechanism including channel attention and global texture attention to explore the valuable information in the two-modal features. The final fused feature is expressed as: ; (3) where represents the channel attention module, represents the global texture attention module.
[0010] Preferably, the decoding stage includes local detail attention, global texture attention and global adaptive attention, which are respectively used to explore the features of the target and adaptively adjust the discriminative ability of the model for the target under bad weather, specifically as follows: The local detail attention is as follows: To solve the noise brought by low visibility conditions, this scheme uses local detail attention LDA to explore the features of the target at the pixel level; for the input feature , first through a convolutional layer, the local detail attention performs max pooling and average pooling on the convolved feature respectively to explore the most significant local features and the feature average value; Then connect the two parts of feature values along the channel dimension, pass through a convolutional layer and add them to the original input and then output; the local detail attention is specifically expressed as: ; (4) In the formula, Represents max pooling, Indicates average pooling, Indicates the convolutional layer, Indicates concatenation on channels, Indicates the final output of the LDA module; The global texture attention is as follows: To explore the texture information of the target under low visibility interference, this solution designs a global texture attention module (GTA). Even if the low visibility noise degrades the target features, the texture features of the most prominent objects that are different from the background and noise can still be extracted from the pooling operations row by row and column by column; for the input features , first pass through a convolutional layer to swap the dimensions of the input features to obtain the features and ; the convolutional kernel and the pooling kernel respectively repeat the above local detail attention in the features , and along the channel, row, and column directions to obtain the channel-wise, row-wise, and column-wise feature vectors, and then restore the feature vectors to the size of the input features at the original positions. After adding the two parts of the feature maps element by element, perform channel attention on the sum feature to dynamically change the weights of the features in each channel; specifically, ; (5) Among them, represents local detail attention, , , respectively represent the features obtained by performing local detail attention along the channel, row, and column directions of the feature, represents the sigmoid function, represents the output feature of the global texture attention; finally, connect the outputs of the attention modules LDA and GTA that explore the local and global details in the image, and the final output is expressed as: ; (6) The global adaptive attention strength is as follows: To enable the model to adaptively cope with various combinations of low visibility conditions, after completing the exploration of the local and global features of the feature map, an additional global adaptive attention is set to integrate the features and help the model automatically focus on the important regions and target features; for the input features , divide it into two parts from the channel dimension, one part is subjected to Gaussian normalization, the other part is processed through a convolutional layer, and finally the two parts are concatenated in the channel dimension and added element-wise with the original input and the result after passing through the convolutional layer as the final decoder output; specifically, ; (7) Among them, and respectively represent the input features for Gaussian normalization and the convolutional layer, represents splitting along the channel dimension, represents parameter - learnable Gaussian normalization, and respectively represent the input features of global adaptive attention and the input features of global texture attention; represents the rough prediction map of each - scale feature.
[0011] Preferably, the iterative stage includes that after iterative optimization at each step, the output features are decoded by LVD to obtain the rough prediction map of this step ; the network will perform backpropagation. In order not to lose the detailed information contained in the low - level features, the upper - scale features will be upsampled and connected to the next scale, and continue to be decoded to obtain the rough prediction map; the final prediction result will fuse the bottom - level features and the optimal rough prediction map to obtain the final result R: ; (8) Among them represents the feature fusion module, which is composed of MSPP. Its role is to achieve multi - scale feature fusion, represents downsampling, downsampling to the size of ; the finally fused result is upsampled and convolved to output the final fine prediction result.
[0012] Preferably, loss supervision is set in the encoding stage, specifically as follows: In the decoding stage, multi - scale feature extraction is adopted. Each scale outputs its own rough prediction map. By setting the loss function to supervise the loss of the rough prediction maps of multiple - step iterations and the loss of the final prediction map R to ensure that each link can accurately predict; in order to accurately evaluate the loss so that the model can accurately detect difficult targets, weighted binary cross - entropy loss and weighted intersection - over - union loss are used to supervise these prediction results, and the prediction loss is ; for the rough prediction maps in the iterative optimization stage, different weights are applied to different stages to achieve balance; given the weight parameter , the final loss function is defined as follows: ; (9) In the formula, R is the final prediction map, GT represents the ground truth, represents the prediction output of each - level decoder, represents the weight parameter, and i represents the decoder level corresponding to the prediction map.
[0013] Preferably, step S5 includes: Input the image and the point cloud pseudo-feature map into the model for training, and predict and output a binary mask image for the fruit images in the test set; For the simultaneous input of the image and the point cloud pseudo-feature map, concatenate them in the batch dimension to obtain the input feature as , B represents the number of images input in a batch, C represents the number of channels of the feature, H and W represent the height and width of the input feature. In this solution, B = 8, C = 3, H = W = 704. In each feature downsampling, their width and height will be downsampled to half of the original. After training is completed, test the trained model. The input size of the model during testing is also , and the input batch is 2, that is, the concatenated feature of the image and the point cloud feature map.
[0014] Preferably, step S6 includes using IOU and metrics for comprehensive evaluation, specifically: ; (10) ; (11) where TP represents the number of samples that are actually positive classes and are predicted as positive classes, FN represents the number of samples that are actually positive classes and are predicted as negative classes, TN represents the number of samples that are actually negative classes and are predicted as negative classes, and FP represents the number of samples that are actually negative classes and are predicted as positive classes.
[0015] The beneficial effects of the present invention are as follows: 1. The present invention applies a modular convolutional neural network of the deep learning method to achieve a better detection effect. Each module is for a specific task, and they are combined into an overall detection method in the most suitable order. Through the learning of the deep learning deep network for image features in this solution, it is ensured that the model can accurately detect the target only in one stage, solving the problem that the existing methods rely on image quality for detection and simplifying the training steps; the cooperation of each module in this solution enables the model to adapt to various harsh weather scenarios and has strong generalization; the design of this solution and the dataset are closely related to the agricultural scenario, so the proposed solution is completely suitable for fruit detection in the agricultural scenario. The proposed one-stage multi-modal harsh weather fruit method effectively solves various inadaptability problems of the existing methods in the agricultural scenario under harsh weather, and finally achieves a better detection effect.
[0016] 2. The present invention is optimized for agricultural scenarios. At the beginning of the scheme design, the agricultural scenario is taken as the main research target. A dataset is collected on-site, cleaned, labeled, and data-augmented to obtain the dataset LVScene4K. "Simple" samples and "difficult" samples are provided to test the performance of the model under different difficulties. A complete detection method is designed, including a multi-scale encoder, multi-modal feature fusion, a decoder for adverse weather, and an iterative mechanism, which can effectively detect fruit targets in agricultural scenarios under adverse weather. The present invention also provides a detection benchmark for fruit detection in agricultural scenarios under adverse weather. This scheme uses IOU and F 1 as indicators to evaluate the effectiveness and reliability of the detection method, and verifies that this scheme can achieve the best detection performance, and the model has the smallest performance degradation in the conversion from "simple" samples to "difficult" samples. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a schematic flowchart of the present invention; Figure 2 is a schematic structural diagram of the multi-modal adverse weather fruit detection model PGSNet in an embodiment of the present invention; Figure 3 is a schematic structural diagram of the decoder LVD in an embodiment of the present invention; Figure 4 is a schematic diagram of the comparison between other methods and the method of the present invention in an embodiment of the present invention; Figure 4 In Figure 4 a and Figure 4 c are other methods, Figure 4 b and Figure 4 d are the methods of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0018] Embodiment 1: As Figure 1 shown, a one-stage multi-modal adverse weather fruit detection method includes the following steps: S1. Collect fruit image data and point cloud data on-site in the agricultural scenario. The agricultural scenario specifically includes farmlands of individual operators, commercial farms, experimental fields of universities, and large-scale planting bases. When collecting the dataset, data is acquired by moving at equal distances and rotating at equal angles based on the sensor component; S2. Perform data preprocessing on the collected image data and point cloud data, including data format conversion, data cleaning, data annotation, and data augmentation; S3. Perform feature extraction and pseudo feature map creation on the fruit point cloud data after data preprocessing; S4. Input the fruit image and the point cloud pseudo feature map to construct a multi-modal adverse weather fruit detection model; S5. Detect the fruits in the image through the constructed multi-modal bad weather fruit detection model, and output the detection result mask; S6. Conduct a comprehensive evaluation of the model.
[0019] Preferably, step S2 includes: S201. Name the image data obtained in step S1 in sequence, and convert the point cloud into the pcd format that can be read by the model; S202. Delete the images and point clouds that do not meet the task requirements; S203. Label the fruits in the image as binary mask pictures as the ground truth; S204. Degrade the image quality, add challenging weather conditions such as rain, snow, and fog to the image. Take the original data set as the "easy" samples, and the data-augmented data set as the "difficult" samples, and perform the same division of the training set and test set.
[0020] Preferably, step S3 includes using PointNet++ to extract features from the point cloud data, and then projecting the point cloud features onto the image according to the position of the center point according to the projection method to generate a pseudo-feature map. The specific method is as follows: Obtain the point cloud features output by the point cloud encoder . In order to utilize the point cloud features extracted by the point cloud encoder, first project the point cloud into the image coordinate system. Before that, perform the calibration and alignment between the camera and the lidar to define an accurate projection; Given a point cloud . For the points in the point cloud , calculate the 2D coordinates on the image corresponding to the point coordinates through the camera's internal and external parameters, and create a point feature map based on this; As shown in Equation (1), project the point features onto the image based on the feature center point coordinates to create a pseudo-image, and finally obtain the pseudo-image feature as : ; (1) Where , are the internal and external parameters of the camera respectively; , respectively represent the original three-dimensional coordinates and projected two-dimensional coordinates of the point .
[0021] Such as Figure 2As shown, in step S4, the fruit image and the point cloud pseudo-feature map are input, and the multi-modal adverse weather fruit detection model is constructed, including the pre-processed image data and the point cloud pseudo-feature map. The multi-modal adverse weather fruit detection model learns and predicts the binary mask of the fruit position, specifically including an encoding stage, a fusion stage, a decoding stage, and an iterative stage; in the encoding stage, the PVT Pyramid Vision Transformer and the improved Spatial Pyramid Pooling (MSPP) structure are used to obtain multi-scale features of the image, enabling the model to learn object features from multiple scales; the input image and pseudo-feature map are concatenated on the batch dimension, and the features obtained after encoding by PVT and MSPP are: ; In the formula, represents features of different sizes, n represents different feature size levels, R represents the feature shape, B represents the number of images in the batch input, C represents the number of feature channels, and H and W respectively represent the width and height of the features.
[0022] Preferably, in the fusion stage, the CMF module based on the cross-attention mechanism is used, enabling the model to dynamically capture the correlation between the two modalities; During the module initialization process, the input image and point features are respectively converted into queries , keys and values through three convolutional layers; for each query , that is, the image feature, the attention affinity matrix with the key is calculated through inner product, and is normalized using the function; The attention affinity matrix weights and aggregates the values containing point features, and the aggregated point cloud information is added element-wise to the original image features. After layer normalization, the point-guided image features are obtained, and the output weighted feature set is expressed as: ; Through attention weighting, the model can better align and highlight the most relevant point features and image features during the learning process; these features are connected, and feature aggregation is performed using element-wise addition and element-wise multiplication; to avoid the model over-focusing on one modality due to the direct element-wise addition method. This ensures that the fused features can fully utilize the complementarity of the two modalities while emphasizing their common points; the feature aggregation formula is as follows: ; (2) Among them, represents element-wise addition, represents element-wise multiplication; the preliminary fused feature After that, continue to apply the attention mechanism including channel attention and global texture attention to explore the valuable information in the two-modal features. Finally, the fused feature representation is: ; (3) where represents the channel attention module, represents the global texture attention module.
[0023] As Figure 3 shown, the decoding stage includes local detail attention, global texture attention and global adaptive attention, which are used to explore the features of the target and adaptively adjust the discriminative ability of the model for the target under bad weather, specifically as follows: The local detail attention is as follows: To solve the noise brought by low visibility conditions, this scheme uses local detail attention (LDA) to explore the features of the target at the pixel level; for the input feature , first through a convolutional layer, the local detail attention performs max pooling and average pooling on the convolved feature respectively to explore the most significant local features and the feature average value; Then connect the two parts of feature values along the channel dimension, pass through a convolutional layer and add them to the original input and then output; the local detail attention is specifically represented as: ; (4) In the formula, represents max pooling, represents average pooling, represents the convolutional layer, represents connection on the channel, represents the final output of the LDA module; The global texture attention is as follows: To explore the texture information of the target under low visibility interference, this scheme designs a global texture attention module (GTA). Even if the low visibility noise degrades the target features, the most significant texture features of the object that are different from the background and noise can still be extracted from the pooling operations row by row and column by column; for the input feature , first through a convolutional layer, exchange the dimensions of the input feature to get the features and ; the convolutional kernel and pooling kernel repeat the above local detail attention along the channel, row and column directions on the features , and respectively, to obtain the feature vectors channel by channel, row by row and column by column, then restore the feature vectors to the size of the input feature at the original position, add the two parts of feature maps element by element, and then perform channel attention on the sum feature to dynamically change the weights of each channel feature; specifically, ; (5) Among them, represents local detail attention, , , respectively represent the features for performing local detail attention along the channel, row, and column directions of the feature, represents the sigmoid function, represents the output feature of global texture attention; finally, the outputs of the attention modules LDA and GTA that explore local and global details in the image are connected, and the final output is expressed as: ; (6) Global Adaptive Attention (GGA) is as follows: To enable the model to adaptively handle various combinations of low visibility conditions, after exploring the local and global features of the feature map, an additional global adaptive attention is set to integrate the features and help the model automatically focus on important regions and target features; for the input feature , it is divided into two parts along the channel dimension, one part is subjected to Gaussian normalization, the other part is processed through a convolutional layer, and finally the two parts are connected along the channel dimension. After passing through the convolutional layer, it is element-wise added to the original input as the final decoder output; specifically: ; (7) Among them, and respectively represent the input features for Gaussian normalization and the convolutional layer, represents splitting along the channel dimension, represents parameter-learnable Gaussian normalization, and respectively represent the input feature of global adaptive attention and the input feature of global texture attention; represents the rough prediction map of each scale feature.
[0024] Preferably, the iterative stage includes that after iterative optimization at each step, the output feature is decoded by LVD to obtain the rough prediction map of this step ; The network will perform backpropagation. In order not to lose the details contained in the low-level features, the upper-scale features will be upsampled and connected to the next scale, and continue to be decoded to obtain the rough prediction map; the final prediction result will fuse the bottom-level feature and the optimal rough prediction map to obtain the final result R: ; (8) Among them Denotes the feature fusion module, which is composed of MSPP. Its function is to achieve multi-scale feature fusion. Denotes downsampling, which downsamples to the size of ; The final fused result is upsampled and convolved to output the final refined prediction result.
[0025] Preferably, loss supervision is set in the encoding stage, specifically as follows: In the decoding stage, multi-scale feature extraction is adopted. Coarse prediction maps are output at different scales, and the losses of the coarse prediction maps in multiple steps of iteration are supervised by setting loss functions and the loss of the final prediction map R to ensure accurate prediction in each link; In order to accurately evaluate the loss and enable the model to accurately detect difficult targets, weighted binary cross-entropy loss and weighted intersection over union loss are used to supervise these prediction results, and the prediction loss is ; For the rough prediction maps in the iterative optimization stage, different weights are applied to different stages to achieve balance; Given the weight parameter , the final loss function is defined as follows: ; (9) In the formula, R is the final prediction map, GT represents the ground truth, represents the prediction output of each level of decoder, represents the weight parameter, and i represents the decoder level corresponding to the prediction map.
[0026] Preferably, step S5 includes: Input the image and the point cloud pseudo-feature map into the model for training, and predict the fruit image in the test set and output the binary mask image; For the simultaneous input of the image and the point cloud pseudo-feature map, they are concatenated in the batch dimension to obtain the input feature as , B represents the number of images input in a batch, C represents the number of channels of the feature, H and W represent the height and width of the input feature. In this scheme, B = 8, C = 3, H = W = 704. In each feature downsampling, their width and height will be downsampled to half of the original. After training, the trained model is tested, and the input size of the model during testing is also , and the input batch is 2, that is, the concatenated feature of the image and the point cloud feature map.
[0027] Preferably, in step S6, in order to evaluate the performance of the model, Intersection over Union (IOU), F1-measure ( ) are used for comprehensive evaluation, and the formula is specifically: ; (10) ; (11) The confusion matrix is shown in Table 1 below: Table 1: Confusion matrix;
[0028] Among them, TP represents the number of samples that are actually positive and predicted as positive, FN represents the number of samples that are actually positive and predicted as negative, TN represents the number of samples that are actually negative and predicted as negative, and FP represents the number of samples that are actually negative and predicted as positive.
[0029] Example 2: To objectively test the fruit detection method in bad weather of the present invention, in this example, "simple" samples and "difficult" samples after field collection and data augmentation are used to verify the reliability of this method under various conditions. The ratio of the training set to the test set is set to 8:2. The data in the training set and the test set are randomly allocated, but it is ensured that the "simple" and "difficult" samples are allocated in the same way.
[0030] At the same time, to verify the superiority of this method, in this example, comparative experiments are designed respectively with (A) the currently best detection model; (B) the denoising model + the best detection model; (C) the target segmentation method dedicated to bad weather. The experimental results are shown in Table 2: Table 2: Results of comparative experiments;
[0031] It can be seen from the experimental data in Table 2 that compared with the existing methods, all indicators of this solution are significantly improved, achieving the best detection performance, and the performance degradation from "simple" samples to "difficult" samples is the smallest, which proves the superiority of this solution.
[0032] Figure 4 Show the comparison of the detection results of the method in this article and other methods, Figure 4 a is the detection result based on B1 - AODNet, Figure 4 c is the detection result based on B2 - EPFN, Figure 4 b and Figure 4 d are the detection results of the method adopted in this example; it can be seen that the method in this article can still accurately detect fruits in extremely challenging pictures, and the cases of missed detection and false detection are significantly reduced.
[0033] Aiming at the problems of low real-time performance, poor generalization, and unsuitability for agricultural scenarios in existing methods, the present invention proposes to design a one-stage multi-modal fruit detection method suitable for agricultural scenarios. Through multi-scale feature encoding, feature fusion, targeted feature decoding, and an iterative mechanism, a robust and reliable bad weather detection method is proposed. A large number of experimental results show that the one-stage multi-modal bad weather fruit detection method proposed by the present invention can effectively solve the problems of poor generalization of existing models and unsuitability for agricultural scenarios. Compared with existing methods, it can detect fruits with the highest performance in extremely challenging scenarios, and in the face of the conversion of scenarios from simple to difficult, this solution achieves the lowest performance degradation; it does not require pre-processing of images and achieves good results in terms of accuracy and speed, providing a reliable solution for fruit detection in bad weather agricultural scenarios.
Claims
1. A one-stage multi-modal method for detecting fruits in bad weather, characterized in that: The following steps are involved: S1, collect fruit image data and point cloud data in agricultural scenes; agricultural scenes specifically include farmland of individual business owners, commercial farms, university experimental fields and large-scale planting bases; when collecting data sets, the sensor components are moved at equal distances and rotated at equal angles to obtain data; S2, data preprocessing of the collected image data and point cloud data, including data format conversion, data cleaning, data labeling and data enhancement; S3, performing feature extraction and pseudo feature map creation on the fruit point cloud data after data preprocessing; S4, input fruit images and point cloud pseudo feature maps to build a multimodal severe weather fruit detection model; S5, detecting the fruits in the image by using the constructed multimodal severe weather fruit detection model, and outputting a detection result mask; S6, conduct a comprehensive evaluation of the model.
2. A one-stage multi-modal bad weather fruit detection method according to claim 1, characterized in that: Step S2 includes: S201, naming the image data acquired in step S1 in order, and converting the point cloud into a pcd format readable by the model; S202, deleting images and point clouds that do not meet the task requirements; S203, marking the fruit in the image as a binary mask image as a true value; S204, degrades image quality, adds challenging weather conditions such as rain, snow and fog to the image, takes the original dataset as the "easy" sample, and the dataset after data enhancement as the "difficult" sample, and performs the same training set and test set division.
3. A one-stage multi-modal bad weather fruit detection method according to claim 1, characterized in that: Step S3 includes using PointNet++ to extract features from the point cloud data, and then projecting the point cloud features onto the image according to the position of the center point according to the projection method to generate a pseudo feature map. The specific method is: Point cloud features are obtained by outputting the point cloud encoder ,In order to utilize the point cloud features extracted by the point cloud encoder, the point cloud is ,first projected to the image coordinate system, before which the calibration and ,alignment between the camera and the lidar are performed to define the ,accurate projection; Given a point cloud , for a point in the point cloud , calculate the 2D coordinates on the image corresponding to the point coordinates through the camera's internal and external parameters, and create a point feature map based on this; As shown in formula (1), the point feature is projected onto the image based on the coordinates of the feature center point to create a pseudo image. The final pseudo image feature is: : ;(1) in , They are the intrinsic and extrinsic parameters of the camera respectively; , Respectively indicate points The original three-dimensional coordinates and projected two-dimensional coordinates of .
4. A one-stage multi-modal bad weather fruit detection method according to claim 1, characterized in that: In step S4, inputting the fruit image and the point cloud pseudo feature map, and constructing the multimodal severe weather fruit detection model includes inputting the preprocessed image data and the point cloud pseudo feature map, and constructing the multimodal severe weather fruit detection model to learn and predict the binary mask of the fruit position, which specifically includes an encoding stage, a fusion stage, a decoding stage, and an iteration stage; the encoding stage adopts the PVT pyramid visual Transformer and the improved spatial pyramid pooling MSPP structure to obtain multi-scale features of the image, so that the model learns target features from multi-scales; The input image and pseudo feature map are concatenated in the batch dimension, and the features obtained after PVT and MSPP encoding are: ; In the formula, Represents features of different sizes, n represents the level of features of different sizes, R represents the feature shape, B represents the number of images input in a batch, C represents the number of feature channels, H and W represent the width and height of the feature respectively.
5. A one-stage multi-modal bad weather fruit detection method according to claim 4, characterized in that: The fusion stage uses a CMF module based on a cross-attention mechanism, which enables the model to dynamically capture the correlation between the two modalities; During the module initialization process, three convolutional layers are used to convert the input image and point features into query features respectively. ,key Sum Characterization; for each query That is, the image features are calculated by inner product and key The attention affinity matrix and use The function is normalized; The attention affinity matrix contains the value of the point feature Weighted and aggregated, the aggregated point cloud information is added element by element to the original image features, and the point-guided image features are obtained after layer normalization. The output weighted feature set is expressed as: ; Through attention weighting, the model can better align and highlight the most relevant point features and image features during the learning process; connect these features and use element-wise addition and element-wise multiplication to aggregate features; feature The aggregation formula is as follows: ;(2) in, represents element-by-element addition, Indicates element-by-element multiplication; get the initial fusion features After that, we continue to apply the attention mechanism including channel attention and global texture attention to explore the valuable information in the two-modal features. The final fusion feature is expressed as: ;(3) in represents the channel attention module, Represents the global texture attention module.
6. A one-stage multi-modal bad weather fruit detection method according to claim 5, characterized in that: The decoding stage includes local detail attention, global texture attention, and global adaptive attention, which are used to explore the characteristics of the target and adaptively adjust the model's ability to identify targets in bad weather, as follows: The local detail attention is as follows: For the input features First, through a convolution layer, the local detail attention performs maximum pooling and average pooling on the convolutional features to explore the most significant local features and feature averages; Then the two parts of the feature values are connected along the channel dimension, passed through a convolutional layer and added to the original input before output; the local detail attention is specifically expressed as: ;(4) In the formula, represents maximum pooling, represents average pooling, represents the convolutional layer, Indicates that the channel is connected. Represents the final output of the LDA module; The global texture attention is as follows: For the input features First, through a convolutional layer, the input feature dimension is exchanged to obtain the feature and ; The convolution kernel and pooling kernel are respectively in the feature , and Repeat the above local detail attention along the channel, row and column directions to obtain channel-by-channel, row-by-row and column-by-column feature vectors, then restore the feature vectors to the size of the input features according to the original position, add the two parts of the feature map element by element, perform channel attention on the sum feature, and dynamically change the weight of each channel feature; specifically, ;(5) in, Indicates local detail attention, , , Respectively represent the features of performing local detail attention along the channel, row, and column directions of the feature, represents the sigmoid function, Represents the output features of global texture attention; finally, the outputs of the attention modules LDA and GTA that explore local and global details in the image are connected, and the final output is expressed as: ;(6) The global adaptive attention strength is as follows: For the input features , divided into two parts from the channel dimension, one part is Gaussian normalized, and the other part is processed by a convolution layer. Finally, the two parts are connected in the channel dimension, and after passing through the convolution layer, they are added with the original input and the most element-wise as the final decoder output; specifically, ;(7) in, and Represent the input features of Gaussian normalization and convolution layer respectively, represents splitting along the channel dimension, represents Gaussian normalization with learnable parameters, and They represent the input features of global adaptive attention and global texture attention respectively; Represents the coarse prediction map of each scale feature.
7. A one-stage multi-modal bad weather fruit detection method according to claim 6, characterized in that: The iteration phase includes that after each step of iterative optimization, the output features are decoded by LVD to obtain the rough prediction map of this step. The network will In the backward propagation, in order not to lose the detailed information contained in the low-level features, the upper-level scale features will be upsampled and connected to the next scale, and continue to decode to obtain a rough prediction map; the final prediction result will be the bottom-level features and the optimal rough prediction map The final result R is obtained by fusion: ;(8) in It represents the feature fusion module, which is composed of MSPP. Its function is to realize multi-scale feature fusion. represents downsampling, Downsample to The final fused result is upsampled and convolved to output the final refined prediction result.
8. A one-stage multi-modal bad weather fruit detection method according to claim 7, characterized in that: Loss supervision is set during the encoding phase as follows: The decoding stage uses multi-scale feature extraction, and each scale outputs its own rough prediction map. The loss function is set to supervise the rough prediction map of multiple steps. The loss of and the loss of the final prediction graph R are used to ensure that each link can be accurately predicted; in order to accurately evaluate the loss so that the model can accurately detect difficult targets, a weighted binary cross entropy loss is applied. and weighted intersection-over-union loss Supervising these predictions, the prediction loss is ; For the rough prediction graph in the iterative optimization phase, different weights are applied to different phases to seek balance; given the weight parameter , the final loss function is defined as follows: ;(9) In the formula, R is the final prediction graph, GT represents the true value, represents the predicted output of each level of decoder, represents the weight parameter, and i represents the decoder level corresponding to the prediction graph.
9. A one-stage multi-modal bad weather fruit detection method according to claim 1, characterized in that: Step S5 includes: Input the image and point cloud pseudo feature map into the model for training, and predict and output the binary mask image for the fruit image in the test set; For the input images and point cloud pseudo feature maps, they are concatenated in the batch dimension to obtain the input features: , B represents the number of images input in a batch, C represents the number of channels of the feature, H and W represent the height and width of the input feature. In each feature downsampling, the width and height are downsampled to half of the original. After the training is completed, the trained model is tested. During the test, the input size of the model is also the concatenated feature of the image and point cloud feature map.
10. A one-stage multi-modal bad weather fruit detection method according to claim 1, characterized in that: Step S6 includes using IOU and The indicators are comprehensively evaluated, specifically: ;(10) ;(11) Among them, TP represents the number of samples that are actually positive and predicted to be positive, FN represents the number of samples that are actually positive and predicted to be negative, TN represents the number of samples that are actually negative and predicted to be negative, and FP represents the number of samples that are actually negative and predicted to be positive.
Citation Information
Cited By
Image restoration method and system coping with various severe weather environment factors
CN120355607A
