Fruit detection method, device and equipment and storage medium

CN119027937APending Publication Date: 2024-11-26WUHAN POLYTECHNIC UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410972392.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

[0006]本申请目的在于提供一种水果检测方法、装置、设备和存储介质,旨在解决如何准确地对水果进行检测的技术问题

Benefits of technology

[0048]Obtain a data set for fruit detection, and divide the data set into a training set and a test set; use a cross-scale context fusion module and a dynamic target detection head to optimize the initial detection model to obtain a reference detection model; use the training set to Perform training with reference to the detection model and adjust parameter weights to obtain a target detection model; test and verify the target detection model through the test set to obtain test results; when the test results meet the preset requirements, use the target detection model The model detects fruits. This application collects images containing different types of fruits and labels the location of each fruit to form a complete data set. Then, this data set is divided into a training set and a test set according to a certain proportion. By rationally dividing the data set, the effectiveness and reliability of model training and testing can be ensured. The training set is used for the model to learn features, and the test set is used to evaluate the model's performance on new data to avoid overfitting problems; in the initial target detection On the basis of the model, the cross-scale context fusion module (CCFM) and the dynamic target detection head (Dynamic Head) are used for optimization. CCFM is used to fuse features of different scales and enhance the model's detection ability of multi-scale targets. Dynamic Head improves the detection accuracy, adaptability and robustness of the model by adaptively adjusting the parameters of the detection head, and improves the model's detection accuracy for fruits of different sizes and shapes, making the detection results more accurate; using the training set to optimize the The reference detection model is trained, and the optimization algorithm is used to adjust the model parameters so that the model can accurately identify and locate fruits. By making full use of the data in the training set, the model can learn more features and improve the detection accuracy of fruits. At the same time, the parameter weights are adjusted to continuously optimize the model during the training process and improve the overall performance; use the test set to verify the trained target detection model, evaluate its performance on new data, judge the detection effect of the model, and verify it through testing , which can objectively evaluate the generalization ability of the model and ensure that the model has good performance in practical applications. The test results can help identify the shortcomings of the model and provide a basis for further optimization; if the test results meet the preset performance standards, this verified target detection model can be used for fruit detection in practical applications. By using the verified The high-performance model achieves accurate detection of fruits, improves the efficiency and reliability of the automated detection system, and meets the needs of practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119027937A_ABST
    Figure CN119027937A_ABST
Patent Text Reader

Abstract

The invention discloses a fruit detection method and device, equipment and a storage medium, and relates to the technical field of target detection, and the fruit detection method comprises the steps: obtaining a data set of fruit detection, and dividing the data set into a training set and a test set; optimizing the initial detection model by using a cross-scale context fusion module and a dynamic target detection head to obtain a reference detection model; training the reference detection model through the training set and adjusting a parameter weight to obtain a target detection model; performing test verification on the target detection model through the test set to obtain a test result; and when the test result meets a preset requirement, detecting the fruit by using the target detection model. Accurate detection of fruits is achieved, the efficiency and reliability of an automatic detection system are improved, and the actual application requirement is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of target detection technology, and in particular to a fruit detection method, device, equipment and storage medium. Background Art

[0002] Counting and locating fruits in orchards is an important task in agricultural automation. This not only helps farmers better manage and optimize resources, but also makes informed decisions during harvesting. Especially in the apple farming industry, apple detection and positioning is the predecessor of automated apple picking, which is one of the most labor-intensive processes in agriculture. With the acceleration of the global transformation of agriculture to intelligence, automated monitoring and management play an increasingly important role in increasing crop yields, optimizing resource allocation, and reducing labor costs. Therefore, fruit detection and counting have become key technologies in the field of agricultural automation, especially in the apple farming industry, where its direct impact on fruit quality is related to the economic benefits of fruit farmers.

[0003] Researchers have used a variety of sensor technologies and algorithms to solve the apple detection problem, but cameras and computer vision technologies are the most common. Although previous fruit detection technologies were mostly based on carefully designed features, recent research has gradually turned to the use of deep learning algorithms, which have shown great potential in automatically learning effective features. In particular, object detection technologies, such as the YOLO (You Only Look Once) series of algorithms, have been widely used in many fields due to their efficiency and accuracy. Although the standard YOLOv8 performs well on multiple datasets, its detection accuracy and robustness still need to be improved in the complex orchard background, especially for small and densely distributed apples.

[0004] Using computer vision technology in complex outdoor orchard environments brings a series of challenges: different lighting conditions, different appearances of fruits on the trees, fruits obscured by leaves, branches or other fruits, etc. Although the YOLOv8 algorithm performs well, its detection accuracy and robustness still need to be improved when dealing with complex lighting conditions and occlusion problems. In addition, the computational complexity and memory usage of the model limit its real-time application on edge computing devices. Furthermore, progress in this field is also constrained by the lack of widely recognized standardized data sets and specific quantitative detection accuracy evaluation criteria in precision agriculture, which limits the effectiveness of these advanced technologies in practical applications. Therefore, how to accurately detect fruits has become an urgent problem to be solved.

[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0006] The purpose of this application is to provide a fruit detection method, device, equipment and storage medium, aiming to solve the technical problem of how to accurately detect fruit.

[0007] To achieve the above objectives, the present application proposes a fruit detection method, which comprises:

[0008] Obtain a data set for fruit detection, and divide the data set into a training set and a test set;

[0009] Use the cross-scale context fusion module and the dynamic object detection head to optimize the initial detection model and obtain the reference detection model.

[0010] The reference detection model is trained by using the training set and parameter weights are adjusted to obtain a target detection model;

[0011] Testing and verifying the target detection model using the test set to obtain a test result;

[0012] When the test result meets the preset requirements, the object detection model is used to detect the fruit.

[0013] In one embodiment, the target detection model includes a backbone network, a neck network and a dynamic target detection head, wherein the neck network includes an attention-based intra-scale feature interaction module, a self-attention mechanism, a feedforward neural network and a cross-scale feature fusion module;

[0014] The step of using the target detection model to detect fruit comprises:

[0015] Extract features from the fruit image to be detected through the backbone network to obtain a first feature map, a second feature map and a third feature map;

[0016] Stretching the third feature map into a one-dimensional feature vector through the attention-based intra-scale feature interaction module;

[0017] Processing the feature vector through the self-attention mechanism and the feedforward neural network, and adjusting it to a two-dimensional state, to obtain a fourth feature map;

[0018] Processing the first feature map, the second feature map, and the fourth feature map by the cross-scale feature fusion module to obtain a feature tensor;

[0019] The feature tensor is processed using a separate attention mechanism in the dynamic target detection head to obtain a fruit detection result.

[0020] In one embodiment, the step of processing the first feature map, the second feature map, and the fourth feature map by the cross-scale feature fusion module to obtain a feature tensor includes:

[0021] Performing feature extraction, feature fusion, and feature enhancement on the first feature map and the second feature map by the cross-scale feature fusion module to obtain a processed first feature map;

[0022] Upsampling, downsampling and feature fusion are performed on the second feature map by the cross-scale feature fusion module to obtain a processed second feature map;

[0023] The cross-scale feature fusion module performs feature fusion on the processed first feature map, the processed second feature map, and the fourth feature map to obtain a feature tensor.

[0024] In one embodiment, the feature tensor includes a hierarchical dimension, a spatial dimension, and a channel dimension, and the dynamic target detection head includes scale-aware attention, spatial-aware attention, and task-aware attention;

[0025] The step of using a separate attention mechanism in the dynamic target detection head to process the feature tensor to obtain a fruit detection result comprises:

[0026] Performing global average pooling and global maximum pooling on the feature tensor in the hierarchical dimension, the spatial dimension, and the channel dimension through the dynamic target detection head to obtain a global description;

[0027] Processing the global description through a fully connected layer of the dynamic object detection head to obtain a scale-aware attention weight, a space-aware attention weight, and a task-aware attention weight;

[0028] Applying the scale-aware attention weight, the space-aware attention weight, and the task-aware attention weight to the feature tensor to obtain a target feature tensor;

[0029] The target feature tensor is subjected to target regression and classification to obtain a fruit detection result.

[0030] In one embodiment, the step of training the reference detection model using the training set and adjusting parameter weights to obtain the target detection model includes:

[0031] The total loss is obtained based on the bounding box regression loss, classification loss and object confidence loss;

[0032] The reference detection model is trained using the training set until the total loss is lower than a preset loss value, thereby obtaining a target detection model.

[0033] In one embodiment, the step of dividing the data set into a training set and a test set includes:

[0034] splicing the images in the data set, and scaling and translating them according to a first preset ratio to obtain an intermediate data set;

[0035] Adjusting the position and size of the target detection frame in the image in the intermediate data set to obtain a target data set;

[0036] The target data set is divided into a training set and a test set according to a second preset ratio.

[0037] In one embodiment, when the test result meets the preset requirements, before the step of using the target detection model to detect the fruit, the method further includes:

[0038] When the test result does not meet the preset requirement, the target detection model is trained using the training set and parameter weights are adjusted until the test result meets the preset requirement.

[0039] In addition, to achieve the above-mentioned purpose, the present application also proposes a fruit detection device, which comprises:

[0040] A data acquisition module, used to acquire a data set for fruit detection and divide the data set into a training set and a test set;

[0041] A model improvement module is used to optimize the initial detection model using a cross-scale context fusion module and a dynamic object detection head to obtain a reference detection model;

[0042] A model training module, used to train the reference detection model through the training set and adjust parameter weights to obtain a target detection model;

[0043] A test verification module, used to test and verify the target detection model through the test set to obtain a test result;

[0044] The fruit detection module is used to detect the fruit using the target detection model when the test result meets the preset requirements.

[0045] In addition, to achieve the above objectives, the present application also proposes a fruit detection device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the fruit detection method described above.

[0046] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the fruit detection method described above are implemented.

[0047] One or more technical solutions proposed in this application have at least the following technical effects:

[0048] Obtain a dataset for fruit detection, and divide the dataset into a training set and a test set; use a cross-scale context fusion module and a dynamic target detection head to optimize the initial detection model to obtain a reference detection model; train the reference detection model through the training set and adjust the parameter weights to obtain a target detection model; test and verify the target detection model through the test set to obtain a test result; when the test result meets the preset requirements, use the target detection model to detect the fruit. This application collects images containing different types of fruits and marks the position of each fruit to form a complete dataset. Then, this dataset is divided into a training set and a test set in a certain proportion. By reasonably dividing the data set, the effectiveness and reliability of model training and testing can be ensured. The training set is used for model learning features, and the test set is used to evaluate the performance of the model on new data to avoid overfitting problems. Based on the initial target detection model, the cross-scale context fusion module (CCFM) and dynamic target detection head (Dynamic Head) are used for optimization. CCFM is used to fuse features of different scales to enhance the model's ability to detect multi-scale targets. Dynamic Head improves the detection accuracy, adaptability and robustness of the model by adaptively adjusting the parameters of the detection head, and improves the model's detection accuracy for fruits of different sizes and shapes, making the detection results more accurate. The optimized reference detection model is trained using the training set, and the model parameters are adjusted using the optimization algorithm, so that the model can accurately identify and locate fruits. By making full use of the data in the training set, the model can learn more features and improve the detection accuracy of fruits. At the same time, the parameter weights are adjusted to continuously optimize the model during the training process, improving the overall performance. The trained target detection model is verified using the test set to evaluate its performance on new data and judge the detection effect of the model. Through test verification, the generalization ability of the model can be objectively evaluated to ensure that the model has good performance in practical applications. The test results can help identify the deficiencies of the model and provide a basis for further optimization. If the test results meet the preset performance standards, this verified object detection model can be used to perform fruit detection in actual applications. By using a verified high-performance model, accurate detection of fruits can be achieved, which improves the efficiency and reliability of the automated detection system and meets the needs of actual applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0050] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0051] Figure 1 A schematic diagram of a process flow provided for the first embodiment of the fruit detection method of the present application;

[0052] Figure 2 A schematic diagram of the structure of a cross-scale context fusion module provided in Example 1 of the fruit detection method of this application;

[0053] Figure 3 A schematic diagram of the structure of an attention-based intra-scale feature interaction module provided in Example 1 of the fruit detection method of the present application;

[0054] Figure 4 A schematic diagram of the structure of a dynamic target detection head module provided in Example 1 of the fruit detection method of this application;

[0055] Figure 5 A schematic diagram of the reference detection model structure provided in Example 1 of the fruit detection method of this application;

[0056] Figure 6 A schematic diagram of a training curve of a target detection model provided in Example 1 of the fruit detection method of the present application;

[0057] Figure 7 A schematic diagram of a flow chart provided for the second embodiment of the fruit detection method of the present application;

[0058] Figure 8 This is a schematic diagram of the module structure of the fruit detection device according to an embodiment of the present application;

[0059] Fig. 9 This is a schematic diagram of the device structure of the hardware operating environment involved in the fruit detection method in the embodiment of the present application.

[0060] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0061] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0062] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0063] Counting and locating fruits in orchards is the key to improving the efficiency of agricultural automation and resource management. Although deep learning algorithms such as YOLOv8 perform well in target detection, their detection accuracy and robustness still need to be improved when facing complex orchard environments (such as different lighting conditions, differences in fruit appearance, and occlusion problems). In addition, the computational complexity and memory usage of the model limit its real-time application on edge computing devices, and the lack of standardized data sets and quantitative evaluation criteria further restricts the effective application of these technologies.

[0064] The main solution of the embodiment of the present application is: first, collect and annotate image data sets containing different types of fruits, and then divide them into training sets and test sets in proportion to ensure the effectiveness of model training and testing; then, apply the cross-scale context fusion module (CCFM) and dynamic target detection head (Dynamic Head) to the initial target detection model to optimize the model to enhance the detection capability and accuracy of multi-scale targets; then, use the training set to train the optimized model, and adjust the model parameters through the loss function and optimization algorithm to improve the fruit detection accuracy; finally, use the test set to verify the model performance to ensure the generalization ability and performance of the model in practical applications, thereby realizing an efficient and reliable fruit detection system.

[0065] It should be noted that the execution subject of the embodiment of the present application can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, an agricultural robot, a drone, etc. The following takes an agricultural robot as an example to illustrate this embodiment and the following embodiments.

[0066] Based on this, the present application embodiment provides a fruit detection method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the fruit detection method of the present application.

[0067] In this embodiment, the fruit detection method includes steps S10 to S50:

[0068] Step S10, obtaining a data set for fruit detection, and dividing the data set into a training set and a test set;

[0069] It should be noted that a dataset refers to a set of fruit images and their corresponding labels. These images and labels are used to train and test the object detection model so that the model can learn to recognize different types of fruits. The training set is a part of the data divided from the entire dataset and used to train the object detection model. The main purpose of the training set is to adjust the parameter weights of the model through the model training process so that it can accurately recognize and classify different fruit images. The test set is another part of the data divided from the entire dataset, which is used to evaluate the performance and generalization ability of the trained model. The image data in the test set does not participate in the model training process, but is only used to evaluate the model after the training is completed to determine how the model performs on unseen data.

[0070] It can be understood that first, a large number of image datasets containing various fruits are collected. Each image needs to be accompanied by detailed annotation information, which includes the specific location of each fruit in the image (usually represented by a bounding box) and the category of the fruit (such as apple, banana, orange, etc.). The collected images are then preprocessed, including resizing, denoising, etc., to ensure image quality and consistency. At the same time, the accuracy of the annotation information is verified to ensure that the bounding box and category annotations of each fruit are correct. Finally, these data are divided into training sets and test sets according to a certain ratio (such as 70% for training and 30% for testing). The training set is used to train the target detection model to help the model learn how to identify and locate different types of fruits, while the test set is used to evaluate the performance of the model after the training is completed to verify its detection ability and accuracy on unseen data.

[0071] As an example, the step of dividing the data set into a training set and a test set includes: splicing the images in the data set, and scaling and translating them according to a first preset ratio to obtain an intermediate data set; adjusting the position and size of the target detection box in the image in the intermediate data set to obtain a target data set; dividing the target data set into a training set and a test set according to a second preset ratio.

[0072] The first preset ratio refers to the ratio used when stitching, scaling and translating images. This ratio is used to adjust the size and position of the image for subsequent processing; the intermediate data set refers to the temporary data set obtained by applying the first preset ratio for stitching, scaling and translation, in which the image has been simply transformed; the target detection box refers to the rectangular box annotated in the image, which is used to locate and identify the fruit in the image. These boxes show the position and size of the fruit in the image; the target data set refers to the data set obtained after adjusting the position and size of the target detection box. These adjustments may include correcting or adjusting the original annotation box to more accurately reflect the position and boundary of the fruit; the second preset ratio refers to the ratio of dividing the target data set into a training set and a test set according to a specified ratio in the final data set processing stage. Assuming that there is an original image set, each image has a resolution of 1024x1024 pixels. For ease of processing, these images are scaled to 512x512 pixels and appropriately translated to ensure that the target (i.e., fruit) is still visible in the image. For example, the first preset ratio can be 0.5, which means reducing the size of the image by half and appropriately adjusting the position in the process to keep the target detection box in the image. Assuming that there are 1000 processed images in the target data set, these images are divided into a training set and a test set. The usual practice is to use most of the data for training and a small part for testing to evaluate the performance of the model. For example, the second preset ratio can be 80:20, which means that 800 images (80%) are used for training and 200 images (20%) are used for testing. First, the images in the data set are spliced ​​and scaled and translated according to the first preset ratio (such as 2:1) to obtain an intermediate data set; then, the position and size of the target detection box in each image in the intermediate data set are adjusted to ensure that the detection box of the target (such as fruit) in the image is accurate, and the target data set is obtained; finally, the target data set is divided into a training set and a test set according to a second preset ratio (such as 70% training set and 30% test set) for model training and performance evaluation.

[0073] This embodiment uses mosaic data augmentation technology to preprocess the data set, usually randomly selecting 4 images and stitching them into a new large image. Each small image will be placed in a quadrant of the large image. In this way, parts of each image will be surrounded by parts of other images, creating a complex background and target distribution; each small image may undergo random scaling and translation before being stitched into the large image to add more diversity. This means that even the same image may appear in different forms in the mosaic image in different training batches; when the images are stitched, the position and size of the original target detection box need to be adjusted accordingly to match the new image coordinate system. This ensures that even after the image is segmented and reorganized, the target detection box still correctly marks the target position; because multiple images are stitched together, targets that originally belonged to different images may now appear in the same image. This requires the model to be able to handle more complex and crowded scenes, thereby improving its performance in practical applications. This embodiment also introduces a special mosaic enhancement method in the YOLO v8 model, namely, integrating negative samples in the mosaic image, which helps to solve the problem of false detection. By ensuring that there are examples of falsely detected images in each round of training, the model can better learn how to distinguish between real targets and backgrounds. These enhanced images are then used to train the YOLO v8 model, helping it to learn a wider range of target and background patterns, thereby performing more stably and accurately during testing. Through mosaic data enhancement, the YOLO v8 model can obtain more information from a limited data set, which is critical to improving the detection performance of the model and reducing overfitting.

[0074] Step S20, using a cross-scale context fusion module and a dynamic target detection head to optimize the initial detection model to obtain a reference detection model;

[0075] It should be noted that the Cross-scale Context Fusion Module (CCFM) is a module that fuses features from different scales to better capture the features of objects of different sizes in the image. This cross-scale fusion can improve the performance of the model when processing objects of various sizes and ensure that the model can grasp the global and local information of the image as a whole; please refer to Figure 2 , Figure 2The schematic diagram of the cross-scale context fusion module structure provided for the first embodiment of the fruit detection method of the present application shows how to extract and fuse features from feature maps (S3, S4, S5) of different scales to enhance the detection capability of the model. The specific description and explanation are as follows: (1) Input feature map: S3, S4 and S5 are three layers of feature maps of different scales extracted from the fruit image to be detected. S3, S4 and S5 are preliminarily processed by the convolution layer (Conv) respectively. (2) Feature map fusion and enhancement: S3 path: After convolution processing, S3 is directly concatenated (concat) with S4 after upsampling (UPSample) and convolution processing. Then, the concatenated result is processed by the Rep3 module to obtain an enhanced feature map (Rep3 refers to a structure containing three repeated modules, which is RepC3, that is, Rep3 is actually a combination of three RepC3 modules, each module performs the above-mentioned convolution and connection operations). S4 path: After S4 is processed by the convolution and Rep3 modules, it is concatenated with S5 after upsampling and convolution. The concatenated result is convolved and concatenated again to obtain an enhanced feature map, which is then further processed by the Rep3 module. S5 path: After S5 is processed by the AIFI module, it is convolved and upsampled again, and the result is concatenated with S4 after convolution. Then, it is concatenated again and processed by the Rep3 module to obtain the final feature map. (3) RepC3 module: The RepC3 module is a convolution module that contains multi-layer convolution (conv), repeated convolution (repconv) and concatenation (concat) operations. Its purpose is to perform multi-level convolution processing and fusion on the input features to further enhance the feature expression capability. This module uses feature maps of different scales for fusion processing, which can better capture target information of different sizes and shapes. Through cross-scale feature fusion, the model can improve the detection ability of multi-scale targets; through operations such as convolution, splicing, upsampling and Rep3 modules, the feature maps are enhanced at multiple levels, especially the Rep3 module and RepC3 module, which can increase the expressiveness of the feature maps and extract richer feature information; the AIFI (attention-based intra-scale feature interaction module) mentioned in the figure processes S5, which shows that the module can enhance the key information in the feature map through the attention mechanism and improve the detection accuracy.

[0076] The dynamic target detection head is a detection head that can dynamically adjust its detection strategy according to the content of the input image, and can dynamically adjust and optimize the target detection process according to the content and features of the input image. It usually includes a dynamic convolution or attention mechanism, so as to adjust its detection strategy according to the position, size and context information of the target in the detection stage. Its main purpose is to improve the accuracy and efficiency of the target detection model by intelligently processing the features of different targets. The initial detection model in this embodiment uses the YOLOv8 model. As a basic target detection model that has not been optimized, YOLOv8 is a deep learning model commonly used for real-time target detection, which is famous for its efficient detection speed and good accuracy; the reference detection model refers to the optimized detection model. In this embodiment, through the joint action of the attention-based intra-scale feature interaction module (Attention-based Intra-scale Feature Interaction, AIFI) and the cross-scale context fusion module (Cross-scale Context Fusion Module, CCFM), as well as the dynamic target detection head, the initial YOLOv8 model is optimized into a reference detection model with better performance.

[0077] The AIFI module is a module designed to enhance the interaction between feature maps at the same scale. By introducing the attention mechanism, AIFI can capture important local and global information in feature maps at the same scale, focusing on the significant parts of the image. This module can effectively extract and fuse fine-grained features, allowing the model to more accurately identify and locate targets. Its design purpose is to improve detection performance while ensuring efficient calculations, especially in image processing with rich details, to enhance the interaction between feature maps at the same scale, thereby more effectively capturing local and global contextual information, while reducing computational complexity and increasing detection speed. Please refer to Figure 3 , Figure 3The following is a structural diagram of the attention-based intra-scale feature interaction module provided in the first embodiment of the fruit detection method of the present application: (1) Input feature map: The input of the module is the third feature map, marked as S5, which has deeper, higher-level and richer semantic features. (2) Feature expansion: S5 is stretched into a one-dimensional feature vector through the processing of the AIFI module and combined with the spatial position encoder to retain the spatial position information. (3) Self-attention mechanism: The feature vector is input into the multi-head self-attention mechanism, in which the query, key and value are generated through the feature vector. The self-attention mechanism captures the long-range dependency between different positions by calculating the correlation between the feature vectors. (4) Addition and normalization: The feature vector after self-attention processing is added and normalized (add&norm) to ensure stability and efficiency. (5) Feedforward neural network (FFN): The normalized feature vector is input into the feedforward neural network for further nonlinear transformation and feature extraction. (6) Addition and normalization again: The features processed by the feedforward neural network are added and normalized again to generate the final feature representation. (7) Output feature map (F5): The final feature representation generates a new feature map F5 through the AIFI module, which contains rich multi-scale feature information and is ready to be input into the next processing module. By processing feature maps of different scales, the AIFI module effectively integrates multi-level feature information and improves the model's ability to detect multi-scale targets; the self-attention mechanism can capture long-range dependencies in the feature map, allowing the model to perform better when dealing with large-scale changes; through multi-layer processing and nonlinear transformation of the feedforward neural network, the feature representation is enhanced, which helps to improve the detection accuracy and robustness of the model.

[0078] The CCFM module is responsible for fusing feature maps from different scales in order to capture multi-scale contextual information. By combining feature maps of different scales, CCFM can utilize the complementarity of features at each scale to enhance the recognition of targets. Feature maps of different scales contain semantic information at different levels. Through context fusion, this information can be more fully understood and utilized during the detection process. This module plays a key role in improving the robustness and detection accuracy of the model, especially for multi-scale and diverse target detection tasks. Please refer to Figure 4 , Figure 4The following is a schematic diagram of the structure of the dynamic target detection head module provided in the first embodiment of the fruit detection method of the present application. The following is a description and explanation of the module: (1) Input feature map: The input of the module is a multi-scale feature map (Features) extracted from the image. (2) General view: These feature maps are integrated into a general view (General view) and represented as a multi-dimensional tensor. (3) Scale-aware attention: Scale-aware processing is performed on the feature map to identify features of different scales and ensure the model's ability to detect multi-scale targets; it includes operations such as hard sigmoid, ReLU (relu), convolution (conv) and average pooling (avg pool) to ultimately generate scale-aware features. (4) Spatial-aware attention: Spatial-aware processing is performed on the feature map to identify features at different spatial positions in the image and enhance the model's sensitivity to spatial information; it includes offset, convolution (conv), index (index) and sigmoid operations to generate spatial-aware features. (5) Task-aware Attention: Task-aware processing of feature maps is performed to optimize feature maps to adapt to different detection tasks, including classification, bounding box regression, and center point regression. (6) Output module: The final output is three branches, which are used for classification (classifier), bounding box regression (Box regression), and center point regression (Center regression); it contains operations such as normalization, fully connected layer (fc), ReLU, and average pooling (avgpool), and generates task-aware features, and performs final feature fusion through weight vectors (e.g., 1, 0, 0, 0). First, the input multi-scale feature maps are integrated into an overall perspective, and then the scale-aware attention module uses hard sigmoid, ReLU, convolution, and average pooling operations to adjust and enhance features of different scales; then, through the spatial-aware attention module, convolution, offset, and sigmoid operations are applied to capture the spatial dependencies of features; then, the task-aware attention module uses fully connected layers, ReLU, average pooling, and normalization operations to adjust the feature representation according to the requirements of different tasks (classification, bounding box regression, and center regression). Finally, these processed feature maps are used for classification, bounding box regression, and center regression, thereby improving the accuracy and robustness of object detection. The entire process achieves fine analysis and effective use of complex image information through multi-level processing of feature maps by various levels of attention mechanisms.

[0079] It can be understood that by using the cross-scale context fusion module to enhance the interaction between features of different scales, ensuring that the model can better capture local and global context information, and using the dynamic target detection head to dynamically adjust the detection strategy according to the image content to adapt to the characteristics and positions of different targets, the initial detection model is optimized to obtain the reference detection model. This process aims to improve the accuracy and efficiency of target detection. Please refer to Figure 5 , Figure 5 The reference detection model structure diagram provided for the fruit detection method embodiment 1 of the present application shows the complete process from input image to output detection result. First, the input 640x640x3 image is subjected to feature extraction through a series of convolutional layers (Conv) and C2f (convolution to full connection) modules. Next, the feature map is input into the DynamicHead (dynamic target detection head) module, and after the overall perspective integration, it is processed by the scale-aware attention (Scale-aware Attention), spatial-aware attention (Spatial-aware Attention) and task-aware attention (Task-aware Attention) modules in turn, and finally outputs the features for classification, border regression and center regression. At the same time, CCFM (cross-scale context fusion module) fuses the features of different levels through convolution and upsampling operations, and realizes the multi-scale fusion processing of features through Rep3 (repeated three times) module and concatenation (concat) operation. Finally, the fused features are further processed through the DynamicHead module again, and the final detection result is output. The whole process realizes efficient and accurate target detection through the application of multi-level feature extraction, fusion and attention mechanism. Among them, the C2f module is used to connect the output of the convolutional layer to the fully connected layer to enhance the feature representation capability; the Rep3 module repeats certain operations or layers three times to increase the depth and complexity of the model; the concatenation operation (concat) is used to concatenate multiple feature maps in the channel dimension to integrate information from different levels.

[0080] Step S30, training the reference detection model using the training set and adjusting parameter weights to obtain a target detection model;

[0081] It should be noted that the target detection model refers to the final model that can effectively detect and identify various fruit targets in the image after training and parameter adjustment. In this embodiment, this model is based on the initial YOLOv8 model. By learning and optimizing weights in the training set, it finally has the ability to accurately identify and locate different fruits.

[0082] It can be understood that the reference detection model is trained by using the training set. The specific operations include inputting the fruit images and corresponding annotation data in the training set into the model, calculating the prediction results through forward propagation, and comparing them with the actual annotations to calculate the loss value; then, the parameters and weights of the model are adjusted through the back propagation algorithm to reduce the error between the prediction results and the actual annotations; after multiple iterative training and parameter optimization, the performance of the reference detection model is gradually improved, and finally a target detection model that can efficiently and accurately detect and identify various fruits is obtained.

[0083] As an example, the reference detection model is trained by the training set and parameter weights are adjusted to obtain the target detection model, including: obtaining the total loss based on the bounding box regression loss, classification loss and target confidence loss; and the reference detection model is trained using the training set until the total loss is lower than a preset loss value to obtain the target detection model.

[0084] Bounding box regression loss refers to the position difference between the bounding box predicted by the detection model and the real bounding box. Commonly used measurement methods include L1 norm loss (L1Norm Loss, L1) and L2 norm loss (L2Norm Loss, L2), or more complex ones such as IoU (Intersection over Union) The target confidence loss refers to the difference between the target existence probability predicted by the model and the actual target existence, which is usually measured by the cross entropy loss. This loss measures the accuracy of the model in judging whether there is a target at a certain position. The total loss refers to the weighted sum of the above three losses, which is used to comprehensively evaluate the overall performance of the model. The smaller the total loss, the better the overall performance of the model in bounding box regression, classification and target confidence prediction. The preset loss value refers to a threshold set during the training process. When the total loss drops below this value, the training process can be stopped and the model is considered to have reached the expected performance standard. For example, in an object detection task, the preset loss value can be set to 2.5, which means that when the total loss of the model (calculated by the weighted sum of bounding box regression loss, classification loss and target confidence loss) drops below 2.5, the training can be stopped and the model is considered to be good enough. For example, if the total loss of the model is 10 during the initial training, and through multiple iterations of training, it gradually drops below 2.5, then the model can be considered to have achieved the expected results. First, the total loss is calculated based on the bounding box regression loss (measures the difference between the bounding box position and size predicted by the model and the actual target bounding box), the classification loss (measures the accuracy of the model's prediction of the target category), and the target confidence loss (measures the model's confidence in the existence of the target). Next, the parameter weights of the model are continuously optimized using the data in the training set to minimize the total loss. During the training process, the model will be iteratively adjusted until the total loss value is lower than the preset threshold (for example, 2.5), at which point the model is considered to have achieved satisfactory performance, and ultimately a target detection model that can effectively perform target detection is obtained. Please refer to Figure 6 , Figure 6The training curve diagram of the target detection model provided for the first embodiment of the fruit detection method of the present application includes a bounding box regression loss curve diagram, a target confidence loss curve diagram, a classification loss curve diagram, a precision curve diagram, a recall rate curve diagram, an average precision curve diagram, and a mean average precision curve diagram. The train / box_loss (training set bounding box regression loss) curve diagram shows the change of the bounding box regression loss during the training process. It can be seen from the figure that the bounding box regression loss gradually decreases with the increase of the number of training iterations, indicating that the performance of the model on the bounding box regression task is constantly improving. The train / cls_loss (training set classification loss) curve diagram shows the change of the classification loss during the training process. It can be seen from the figure that the classification loss also gradually decreases with the increase of the number of training iterations, indicating that the performance of the model on the classification task is also constantly improving. The train / dfl_loss (training set target confidence loss) curve diagram shows the change of the target confidence loss during the training process. As the training progresses, the target confidence loss gradually decreases, indicating that the model's prediction of the target confidence is becoming more and more accurate. The val / box_loss (validation set bounding box regression loss) graph shows the change of bounding box regression loss during the validation process. The bounding box regression loss of the validation set also decreases with the increase of training iterations, indicating that the model also has good bounding box regression performance on unseen data. The val / cls_loss (validation set classification loss) graph shows the change of classification loss during the validation process. The classification loss of the validation set gradually decreases, indicating that the model also has good classification performance on unseen data. The val / dfl_loss (validation set target confidence loss) graph shows the change of target confidence loss during the validation process. The target confidence loss of the validation set is also gradually decreasing, further proving that the confidence prediction performance of the model is improving. The metrics / precision (precision) graph shows the change of the model's precision during the training process. It can be seen that the precision gradually increases with the increase of training iterations, indicating that the model's prediction results are becoming more and more accurate. The metrics / recall (recall rate) graph shows the change of the model's recall rate during the training process. The recall rate also gradually increases, indicating that the number of real targets that the model can detect is increasing. The metrics / mAP50 (mean average precision, IOU threshold is 0.5) graph shows the change of the mean average precision (mAP) of the model under the condition of IOU threshold of 0.5. The mean average precision gradually increases, indicating that the detection performance of the model on different categories continues to improve. The metrics / mAP50-95 (mean average precision, IOU threshold is 0.5 to 0.95) graph shows the change of the mean average precision (mAP) of the model under the condition of IOU threshold from 0.5 to 0.95.As the training progresses, the average accuracy continues to improve, further proving that the comprehensive detection performance of the model is improving. Overall, these training curves show the changes in various losses and performance indicators of the model during the training and verification process, indicating that the model is constantly optimizing and has achieved good results in various tasks.

[0085] Step S40, testing and verifying the target detection model using the test set to obtain a test result;

[0086] It should be noted that the test results refer to the performance evaluation results of the target detection model on the test set, including the target position and category predicted by the model on the test data, and the accuracy indicators after comparison with the actual annotations. These indicators may include: Accuracy, the proportion of correct predictions by the model; Recall, the proportion of actual targets that the model can detect; Precision, the correct proportion of targets predicted by the model; F1 Score, the harmonic mean of precision and recall; Mean Average Precision (mAP), an indicator that comprehensively considers the detection precision and recall, and is often used to measure the overall performance of the detection model.

[0087] It can be understood that the images in the test set are input into the target detection model, the model detects the target on the image, outputs the predicted target position and category, and compares it with the real annotations in the test set. The model performance is calculated based on evaluation indicators such as accuracy, recall, precision, F1 score and average precision, and finally the test results are obtained to evaluate the effect and reliability of the model in practical applications. The evaluation indicators used for verification include Map average precision, which is expressed as:

[0088]

[0089] in,

[0090] In the formula, P represents precision, R represents recall, TP represents the number of positive predictions that are actually positive, FP represents the number of positive predictions that are actually negative, FN represents the number of negative predictions that are actually positive, and AP represents the average precision.

[0091] Step S50, when the test result meets the preset requirements, the fruit is detected using the target detection model.

[0092] It should be noted that the preset requirements refer to the specific standards and thresholds set for the performance of the target detection model during the test phase. These standards are used to evaluate the performance of the model on the test data to ensure that it reaches the expected performance level. These standards usually include the following aspects: Accuracy: the proportion of the number of correctly detected fruits to the total number of detected fruits; Precision: the proportion of samples predicted to be a certain fruit that are actually this fruit; Recall: the proportion of samples that are actually a certain fruit that are correctly predicted to be this fruit; F1 score: the harmonic mean of precision and recall, used to comprehensively evaluate the accuracy and comprehensiveness of the model; Bounding box regression error (such as L1 or L2 loss): the position difference between the predicted bounding box and the true bounding box. For example, the preset requirements can be that the F1 score must reach above 0.90, the precision and recall rates must exceed 0.85, and the bounding box regression error must be less than 0.5. If the test results meet or exceed these preset requirements, the model performance is considered to be up to standard and can be used for actual fruit detection tasks.

[0093] It can be understood that when the test results meet the preset requirements, it indicates that the target detection model has reached the set standards in accuracy and performance. At this time, the model can be applied to actual scenes to detect and identify fruit images, thereby automatically identifying and locating the position and type of fruit.

[0094] As an example, when the test result meets the preset requirements, before the step of using the target detection model to detect the fruit, it also includes: when the test result does not meet the preset requirements, training the target detection model through the training set and adjusting the parameter weights until the test result meets the preset requirements.

[0095] When the test results do not meet the preset requirements, the target detection model needs to be further trained through the training set, and the parameters and weights of the model need to be adjusted. This process includes repeatedly calculating the total loss (including bounding box regression loss, classification loss, and target confidence loss), and using optimization algorithms (such as gradient descent) to update the parameters of the model. The training process continues until the performance of the model on the test set meets the preset standards, such as the total loss is lower than a certain set threshold or the accuracy, recall rate, and F1 score meet specific requirements. Once the test results of the model meet the preset requirements, this optimized target detection model can be used to detect fruits and achieve accurate identification and positioning of fruits.

[0096] This embodiment provides a fruit detection method, which obtains a data set for fruit detection and divides the data set into a training set and a test set; uses a cross-scale context fusion module and a dynamic target detection head to optimize the initial detection model to obtain a reference detection model; trains the reference detection model through the training set and adjusts the parameter weights to obtain a target detection model; tests and verifies the target detection model through the test set to obtain a test result; when the test result meets the preset requirements, the target detection model is used to detect the fruit. This embodiment collects images containing different types of fruits and marks the position of each fruit to form a complete data set. Then, this data set is divided into a training set and a test set according to a certain ratio. For example, 80% of the images are used to train the model (training set), and 20% of the images are used to verify the performance of the model (test set). By reasonably dividing the data set, the effectiveness and reliability of model training and testing can be ensured. The training set is used for model learning features, and the test set is used to evaluate the performance of the model on new data to avoid overfitting problems. Based on the initial target detection model (such as YOLOv8), the cross-scale context fusion module (CCFM) and dynamic target detection head (Dynamic Head) are used for optimization. CCFM is used to fuse features of different scales to enhance the model's detection ability for multi-scale targets. Dynamic Head improves the detection accuracy, adaptability and robustness of the model by adaptively adjusting the parameters of the detection head, and improves the model's detection accuracy for fruits of different sizes and shapes, making the detection results more accurate. The optimized reference detection model is trained using the training set. By repeatedly calculating loss functions (such as bounding box regression loss, classification loss and target confidence loss), and using optimization algorithms to adjust model parameters, the model can accurately identify and locate fruits. By making full use of the data in the training set, the model can learn more features and improve the detection accuracy of fruits. At the same time, adjusting the parameter weights enables the model to be continuously optimized during the training process, improving the overall performance; using the test set to verify the trained target detection model, evaluate its performance on new data, and judge the detection effect of the model by calculating indicators such as accuracy, recall, and F1 score. Through test verification, the generalization ability of the model can be objectively evaluated to ensure that the model has good performance in practical applications. The test results can help identify the shortcomings of the model and provide a basis for further optimization; if the test results meet the preset performance standards, such as the accuracy and F1 score reaching a specific threshold, this verified target detection model can be used for fruit detection in practical applications. By using a verified high-performance model, accurate detection of fruits is achieved, the efficiency and reliability of the automated detection system are improved, and practical application needs are met.

[0097] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 7 , Figure 7 This is a flow chart of the second embodiment of the fruit detection method of the present application. Step S50 of the fruit detection method includes steps S51 to S55:

[0098] The target detection model includes a backbone network, a neck network and a dynamic target detection head, wherein the neck network includes an attention-based intra-scale feature interaction module, a self-attention mechanism, a feedforward neural network and a cross-scale feature fusion module;

[0099] Step S51, extracting features from the fruit image to be detected through the backbone network to obtain a first feature map, a second feature map and a third feature map;

[0100] It should be noted that the first feature map is one of the feature maps extracted by the backbone network, corresponding to the shallower layer in the network, usually containing more local detail information and a smaller receptive field. This feature map is marked as S3 in this embodiment; the second feature map is the intermediate layer feature map extracted by the backbone network, combining more local and global information, and the receptive field is larger than the first feature map, corresponding to S4 in this embodiment; the third feature map is the deep feature map extracted by the backbone network, containing more high-level semantic information and a larger receptive field, corresponding to S5 in this embodiment. The backbone network is the core part of the target detection model, responsible for extracting basic features from the input image. Usually, the backbone network consists of a series of convolutional layers, pooling layers and nonlinear activation functions, which can capture edges, textures and other low-level features in the image. The neck network is located between the backbone network and the detection head, responsible for further processing and fusing the feature maps output from the backbone network. Its main function is to fuse and enhance multi-scale features through different modules to improve the accuracy and robustness of detection. The neck network can integrate features from different levels, so that the model can better capture the contextual information and details of the target object. The self-attention mechanism is a technology used to improve the model's ability to capture global information. It calculates the similarity between each position in the input sequence and assigns different weights to features at different positions, thereby emphasizing important features and suppressing irrelevant information. This mechanism can establish long-distance dependencies between the various parts of the feature map, which helps the model better understand the overall structure and local details of the image. A feedforward neural network (FNN) is an artificial neural network in which information flows unidirectionally from the input layer to the output layer without loops or feedback paths. FNNs are usually composed of multiple fully connected layers, and nonlinear transformations are performed between each layer through activation functions. In target detection models, feedforward neural networks are often used to further process and classify the extracted features to generate the final detection results. This network structure is simple but powerful, and can efficiently process and transform input features.

[0101] It is understandable that, first, the image passes through the backbone feature extraction network to generate three features, S3, S4, and S5. Because in the previous feature fusion module, feature maps from multiple scales will be flattened into a very long vector, which will bring huge computational complexity and computational time, causing the model detection speed to become very slow, and the S5 feature has deeper, more advanced, and richer semantic features than the S4 and S3 features, which is very important for distinguishing the features of objects. Therefore, in the neck network, the encoder only acts on the S5 feature, rather than feature maps of all sizes, which helps to significantly reduce the computational complexity and computational speed of the model without affecting the accuracy. The target detection model extracts feature maps of different levels through the backbone network, which can effectively capture the multi-scale and multi-level information in the fruit image. The first feature map, the second feature map and the third feature map represent different levels of visual information respectively. After being processed and fused by the neck network, the detection model can improve its recognition ability for fruits of various sizes and shapes. By combining the attention-based intra-scale feature interaction module, the self-attention mechanism, the feedforward neural network and the cross-scale feature fusion module, the accuracy and efficiency of feature extraction can be further enhanced, making the final detection result more accurate and robust.

[0102] Step S52, stretching the third feature map into a one-dimensional feature vector through the attention-based intra-scale feature interaction module;

[0103] It should be noted that the feature vector is a numerical representation extracted from an image, which aims to capture the key information of the image. Specifically, the feature vector is a one-dimensional array, in which each element represents a numerical feature of a certain aspect of the image. By stretching the third feature map into a one-dimensional feature vector, subsequent feature processing and analysis can be conveniently performed.

[0104] It can be understood that the third feature map (the feature map containing deep, high-level semantic information) is converted into a one-dimensional feature vector through the attention-based intra-scale feature interaction module. This process helps to simplify the feature representation and reduce the computational complexity. The feature vector, as a compact numerical representation, can be more efficiently input into the subsequent detection head for classification and positioning tasks. This conversion and processing method can improve the performance of the model and make the final target detection more accurate and efficient.

[0105] Step S53, processing the feature vector through the self-attention mechanism and the feedforward neural network, and adjusting it to a two-dimensional state to obtain a fourth feature map;

[0106] It should be noted that the two-dimensional state usually refers to the dimension of the feature map being expressed as two dimensions, width and height. That is, each element of the feature map not only contains channel information, but also has a clear position in space. By adjusting the one-dimensional feature vector to a two-dimensional state, the feature map will be converted from a one-dimensional vector back into a matrix form, which is convenient for subsequent spatial operations and convolution processing.

[0107] It can be understood that the fourth feature map is a feature map with a two-dimensional state obtained after processing by the self-attention mechanism and the feedforward neural network. It is a feature map generated by further feature enhancement and context information fusion on the basis of the third feature map mentioned above. This feature map contains richer semantic information and spatial relationships, and can better support positioning and classification in target detection tasks.

[0108] Step S54, processing the first feature map, the second feature map and the fourth feature map by the cross-scale feature fusion module to obtain a feature tensor;

[0109] It should be noted that the feature tensor refers to a multidimensional array generated by processing and integrating feature maps of different scales (first feature map, second feature map and fourth feature map) through a cross-scale feature fusion module. This feature tensor integrates information of different scales and levels, contains rich semantic and spatial information, and provides a comprehensive feature representation for further processing of the target detection model. By fusing multiple feature maps into a feature tensor, the model can more effectively capture and utilize various features of the target, thereby improving the accuracy and robustness of detection. In this embodiment, the feature tensor is a three-dimensional tensor obtained by processing the first feature map, the second feature map and the fourth feature map through a cross-scale feature fusion module. The structure of the three-dimensional feature tensor can be expressed as (level*space*channel). Level: feature level, that is, the number of feature maps of different scales or levels. This includes the first feature map, the second feature map and the fourth feature map; space: the spatial dimension of the feature map, expressed as the width-height product (H*W) of the feature map. This reflects the spatial resolution in each feature map; channel: the number of channels, the number of channels in each feature map, indicating the number of features contained in the spatial position. The result of the fusion is a three-dimensional feature tensor, which not only retains the spatial information of different scales, but also integrates the features of each scale, providing a richer and more comprehensive feature representation.

[0110] It can be understood that the first feature map, the second feature map and the fourth feature map are processed and fused through the cross-scale feature fusion module, and their features of different scales and levels are integrated into a three-dimensional feature tensor (level*space*channel). This feature tensor integrates spatial information and features of various scales to form a richer and more comprehensive feature representation for subsequent target detection tasks.

[0111] As an example, the step of processing the first feature map, the second feature map and the fourth feature map by the cross-scale feature fusion module to obtain a feature tensor includes: performing feature extraction, feature fusion and feature enhancement on the first feature map and the second feature map by the cross-scale feature fusion module to obtain a processed first feature map; upsampling, downsampling and feature fusion on the second feature map by the cross-scale feature fusion module to obtain a processed second feature map; performing feature fusion on the processed first feature map, the processed second feature map and the fourth feature map by the cross-scale feature fusion module to obtain a feature tensor.

[0112] Feature extraction refers to extracting useful information from the input image or feature map, usually through convolution operations to capture features such as edges, textures, and shapes in the image; feature fusion refers to combining features from different levels or scales to combine the advantages of features at each level and enhance the model's expressiveness and detection accuracy; feature enhancement refers to further enhancing the expressiveness of features through additional processing steps (such as attention mechanisms, convolution operations, etc.) to make them more suitable for subsequent detection tasks; upsampling refers to increasing the spatial resolution of feature maps, usually achieved through methods such as interpolation or deconvolution, so as to expand low-resolution feature maps to the same resolution as high-resolution feature maps. Figure 1 Downsampling refers to reducing the spatial resolution of the feature map, which is usually achieved through pooling or convolution operations, so as to reduce the high-resolution feature map to a smaller size, improve computational efficiency or match feature maps of different resolutions. First, useful feature information is extracted from the first feature map and the second feature map through feature extraction; then feature fusion is performed to integrate feature information from different sources; then feature enhancement is performed to improve the quality of the feature by increasing or adjusting the representation ability of the feature; the second feature map is upsampled and downsampled to change its spatial resolution and retain its semantic information; finally, the processed first feature map, the processed second feature map, and the fourth feature map are cross-scale fused to obtain a comprehensive feature tensor. The feature tensor generated in this way contains multi-level and multi-scale information, which helps the target detection model to more accurately capture the key features in the fruit image at different scales, thereby improving detection accuracy and robustness.

[0113] CCFM accepts S3, S4, and S5 features after AIFI processing. For S3 features, the S3 branch first passes through a convolutional layer (Conv) to extract more abstract feature representations from the input features. Immediately after the convolutional layer, the branch combines its own features or features of other branches through a concatenation operation (Concat) to fuse different feature information. Next, the data passes through one or more repeated blocks (Rep3), which contain multiple layers of convolution, normalization, and activation functions for feature enhancement. For S4 features, similar to S3, the S4 branch also starts from a convolutional layer. The uniqueness of S4 is that it contains two consecutive processing stages, each of which includes convolution operations and concatenation. The first processing stage is followed by a second convolution and concatenation, which means that the S4 branch fuses multiple features at different stages to gradually refine and enhance the feature representation. It is worth noting that there is no direct connection between the two repeated blocks, which indicates that each stage is processed independently before the fusion or transmission of features. S5 starts with a special processing unit - the AIFI module. This module uses the attention mechanism to enhance the feature interaction within the feature map, improve the relevance and importance of the features, and then the data is upsampled twice, each followed by a convolutional layer, which helps to gradually restore the resolution of the feature map while integrating high-level semantic information. Finally, the output of the S5 branch is fused with the outputs of the S3 and S4 branches through a concatenation operation. This step integrates feature information of different scales to form a comprehensive feature representation, which is conducive to improving the model's ability to recognize or segment objects of different scales. The fused features are fed into a shared repetitive block (as shown in the rightmost part of the figure) to further refine these cross-scale features and then serve as the final output.

[0114] Step S55, using a separate attention mechanism in the dynamic target detection head to process the feature tensor to obtain a fruit detection result.

[0115] It should be noted that the decoupled attention mechanism is a method that separates the traditional attention mechanism into different branches to process different types of feature information. The decoupled attention mechanism can process spatial features and channel features separately, thereby capturing important local and global information more accurately. It optimizes feature representation by independently calculating spatial attention and channel attention, and improves the detection ability and performance of the model. The fruit detection result refers to the final output result of the target detection model, including the category, location and corresponding confidence of the fruit. Specifically, the detection result usually includes one or more bounding boxes and corresponding classification labels, indicating where the fruit is detected in the image, and indicating the types of these fruits and their detection confidence.

[0116] It can be understood that in the dynamic target detection head, the separated attention mechanism is first used to independently process the spatial features and channel features of the feature tensor, focus on important areas in the image by calculating spatial attention, and emphasize important feature channels by channel attention, so that local and global information can be captured more accurately; then, these processed features are comprehensively analyzed to generate detection results containing the category, position and confidence of each fruit, thereby achieving high-precision fruit detection. The features fused by the CCFM module are input into the DynamicHead detection head, which is a three-dimensional Tensor (feature tensor) (level*space*channel), where level is the feature level, space is the width-height product (HW) of the feature map, and channel is the number of channels. Then, through the separated attention mechanism, attention operations are performed on each independent dimension in the feature.

[0117] As an example, the feature tensor includes a hierarchical dimension, a spatial dimension and a channel dimension, and the dynamic target detection head includes scale-aware attention, spatial-aware attention and task-aware attention; the step of using a separate attention mechanism in the dynamic target detection head to process the feature tensor to obtain a fruit detection result includes: performing global average pooling and global maximum pooling on the feature tensor in the hierarchical dimension, the spatial dimension and the channel dimension by the dynamic target detection head to obtain a global description; processing the global description by a fully connected layer of the dynamic target detection head to obtain scale-aware attention weights, spatial-aware attention weights and task-aware attention weights; applying the scale-aware attention weights, the spatial-aware attention weights and the task-aware attention weights to the feature tensor to obtain a target feature tensor; performing target regression and classification on the target feature tensor to obtain a fruit detection result.

[0118] Layer dimension: In the feature tensor, the features of different levels are represented from different levels in the feature extraction network (such as YOLOv8), which can represent different details and semantic information of the image; in the YOLOv8 model, the first feature map (S3), the second feature map (S4), and the third feature map (S5) correspond to features of different levels. Spatial dimension: The spatial dimension in the feature tensor refers to the width and height of the feature map. These dimensions reflect the spatial resolution of the image; if the size of the feature map is 32x32, then its spatial dimension is 32x32. Channel dimension: The channel dimension in the feature tensor refers to the number of channels in the feature map, representing different feature types. If the feature map has 256 channels, then its channel dimension is 256. Scale-aware attention: The scale-aware attention mechanism focuses on the importance of features at different levels, so that it can better capture and fuse multi-scale feature information. In YOLOv8, scale-aware attention can better integrate features from S3, S4, and S5 levels. Spatial-aware attention: The spatial-aware attention mechanism focuses on the importance of features at different spatial positions, so that it can better capture spatial context information; through spatial-aware attention, the model can more accurately focus on the spatial area where the fruit is located. Task-aware attention: The task-aware attention mechanism focuses on the importance of features in a specific task, so that it can better complete specific target detection tasks (such as classification or regression). In the fruit detection task, task-aware attention can enhance features related to identifying fruit types. Global average pooling: It is a pooling operation that performs a global average on each channel of the feature map to generate a global feature vector. Performing global average pooling on a 32x32 feature map will result in a 1x1x256 feature vector. Global maximum pooling: It is a pooling operation that performs a global maximum operation on each channel of the feature map to generate a global feature vector. Performing global maximum pooling on a 32x32 feature map will result in a 1x1x256 feature vector. Global description: It combines the results of global average pooling and global maximum pooling to form a global feature representation of the feature tensor. The global description can be a vector obtained by concatenating the feature vectors of global average pooling and global maximum pooling. Fully connected layer: It is a layer structure of a neural network that maps input features to output features. Each input feature is connected to each output feature. In the YOLOv8 model, the fully connected layer can be used to process the global description vector and generate attention weights. Scale-aware attention weights: The weights obtained after processing the global description through the fully connected layer represent the importance of features at different levels and are used to adjust the features of the first feature map (S3), the second feature map (S4), and the third feature map (S5). Spatial-aware attention weights: The weights obtained after processing the global description through the fully connected layer represent the importance of features at different spatial locations and are used to adjust the feature responses at different locations in the feature map.Task-aware attention weight: The weight obtained after processing the global description through the fully connected layer, which indicates the importance of the feature in the specific task and is used to adjust the features related to the classification or regression task. Target feature tensor: The feature tensor after applying the scale-aware attention weight, space-aware attention weight and task-aware attention weight is the feature map processed by the attention mechanism and is used for the final target detection task.

[0119] First, global average pooling and global maximum pooling operations are performed on the hierarchical dimension, spatial dimension, and channel dimension of the feature tensor to extract and integrate the global description information of the feature tensor. Subsequently, these global descriptions are processed by the fully connected layer of the dynamic object detection head to generate scale-aware attention weights, spatial-aware attention weights, and task-aware attention weights, which can capture the importance of the feature tensor at different levels, different spatial positions, and different task contexts. Then, the obtained scale-, spatial-, and task-aware attention weights are applied to the feature tensor to enhance the representation ability of the feature tensor in these dimensions and form the final target feature tensor. Finally, the target feature tensor is used for target regression and classification tasks to obtain accurate fruit detection results. This process effectively optimizes the perception and expression of features by introducing a separate attention mechanism, and improves the accuracy and robustness of the model for fruit detection in complex scenes.

[0120] Scale-aware attention is performed on the level dimension. Feature maps at different levels correspond to different target scales. Increasing attention at the level level can enhance the scale-aware ability of target detection, denoted as π L (.) Spatial perception attention is performed in the spatial dimension. Different spatial positions correspond to the geometric transformation of the target. Increasing attention in the spatial dimension can enhance the spatial position perception ability of the target detector, which is denoted as π S (.). Task-aware attention is performed on the channel dimension. Different channels correspond to different tasks. Adding attention on the channel dimension can enhance the object detection's ability to perceive different tasks, denoted by π C (.). The scale-aware attention module fuses features of different scales based on their semantic importance.

[0121]

[0122] Where f is a linear function, using 1*1 convolution approximation, is the hard-sigmoid function.

[0123] The spatial perception attention module focuses on the discrimination ability of different spatial positions; considering the high dimensionality of S, this module needs to be decoupled in two steps: first, use variable convolution to learn sparsification, and then aggregate features across levels at the same spatial position.

[0124]

[0125] Where K is the number of sparse sampling locations, p k +Δp k A position shift is made to focus on the discriminative area, Δm k is a relation about position p k The self-learnable importance metric factor can be learned from the input features of the intermediate level of F. Task-aware attention can jointly learn the generalization of target representations, which dynamically turns on / off feature channels to select different tasks.

[0126] π c (F).F=max(α 1 (F).F c +β 1 (F),α 2 (F).F c +β 2 (F)

[0127] Among them, [α 1 , β 1 , α 2 , β 2 ] T =θ(.) is a hyperfunction used to learn the activation threshold. It first performs global pooling in the dimension of L×S, then uses two fully connected layers, a normalization layer, and finally uses the shifted sigmoid function to normalize the output. The above three attention methods are based on W(F)=π c (π s (π l (F).F).F).F method for serialized stacking.

[0128] In this embodiment, features are extracted from the fruit image to be detected through the backbone network to obtain a first feature map, a second feature map and a third feature map; the third feature map is stretched into a one-dimensional feature vector through the attention-based intra-scale feature interaction module; the feature vector is processed through the self-attention mechanism and the feedforward neural network and adjusted to a two-dimensional state to obtain a fourth feature map; the first feature map, the second feature map and the fourth feature map are processed through the cross-scale feature fusion module to obtain a feature tensor; the feature tensor is processed using a separate attention mechanism in the dynamic target detection head to obtain a fruit detection result. In this embodiment, features are first extracted from the fruit image to be detected through the backbone network to obtain feature maps of multiple levels (first feature map, second feature map and third feature map). These feature maps capture information of different abstract levels in the image, such as edges, textures and overall structures, and provide multi-scale information for subsequent detection; next, the third feature map is processed by the attention-based intra-scale feature interaction module, and it is stretched into a one-dimensional feature vector, which enhances the interaction between different positions within the same feature map, improves the local and global information capture capabilities, and helps to express features more finely; then, the feature vector extracted from the third feature map is processed by the self-attention mechanism and the feedforward neural network, and it is adjusted to a two-dimensional state to form the first feature map. The four feature maps help introduce more complex spatial relationships and semantic information into the feature representation, and improve the expressiveness and anti-interference ability of the features; then, the first feature map, the second feature map and the fourth feature map are comprehensively processed by the cross-scale feature fusion module to obtain a unified feature tensor, which integrates feature information of different scales and abstract levels, and enhances the richness and expressiveness of the feature tensor in multiple dimensions; finally, the separated attention mechanism is applied in the dynamic target detection head to further process the feature tensor to generate the final fruit detection result. The separated attention mechanism can adjust the importance of the feature tensor in multiple dimensions, helping the model to locate and classify fruits more accurately, thereby improving the accuracy and robustness of the detection. In summary, this embodiment combines a variety of advanced feature extraction, enhancement and fusion technologies to effectively improve the performance and effect of the target detection model in the fruit detection task.

[0129] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the fruit detection method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0130] This application also provides a fruit detection device, please refer to Figure 8 , the fruit detection device comprises:

[0131] A data acquisition module 10 is used to acquire a data set for fruit detection and divide the data set into a training set and a test set;

[0132] A model improvement module 20, used to optimize the initial detection model using a cross-scale context fusion module and a dynamic target detection head to obtain a reference detection model;

[0133] A model training module 30, used to train the reference detection model through the training set and adjust parameter weights to obtain a target detection model;

[0134] A test verification module 40 is used to test and verify the target detection model through the test set to obtain a test result;

[0135] The fruit detection module 50 is used to detect the fruit using the target detection model when the test result meets the preset requirements.

[0136] The fruit detection device provided by the present application adopts the fruit detection method in the above embodiment, which can solve the technical problem of how to accurately detect fruits. Compared with the prior art, the beneficial effects of the fruit detection device provided by the present application are the same as the beneficial effects of the fruit detection method provided by the above embodiment, and other technical features in the fruit detection device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0137] The present application provides a fruit detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the fruit detection method in the above-mentioned embodiment 1.

[0138] Reference below Fig. 9 , which shows a schematic diagram of the structure of a fruit detection device suitable for implementing the embodiment of the present application. The fruit detection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig. 9 The fruit detection device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0139] like Fig. 9As shown, the fruit detection device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the fruit detection device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the fruit detection device to communicate wirelessly or wired with other devices to exchange data. Although the fruit detection device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0140] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0141] The fruit detection device provided by the present application adopts the fruit detection method in the above embodiment, which can solve the technical problem of how to accurately detect fruits. Compared with the prior art, the beneficial effects of the fruit detection device provided by the present application are the same as the beneficial effects of the fruit detection method provided by the above embodiment, and other technical features in the fruit detection device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0142] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0143] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0144] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the fruit detection method in the above-mentioned embodiment.

[0145] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0146] The computer-readable storage medium may be included in the fruit detection device; or may exist independently without being assembled into the fruit detection device.

[0147] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by a fruit detection device, the fruit detection device: obtains a data set for fruit detection, and divides the data set into a training set and a test set; uses a cross-scale context fusion module and a dynamic target detection head to optimize the initial detection model to obtain a reference detection model; trains the reference detection model through the training set and adjusts parameter weights to obtain a target detection model; tests and verifies the target detection model through the test set to obtain a test result; when the test result meets the preset requirements, uses the target detection model to detect the fruit.

[0148] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0149] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0150] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0151] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned fruit detection method, and can solve the technical problem of how to accurately detect fruits. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the fruit detection method provided in the above-mentioned embodiment, and will not be repeated here.

[0152] The present application also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of the fruit detection method as described above are implemented.

[0153] The computer program product provided by the present application can solve the technical problem of how to accurately detect fruits. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the fruit detection method provided by the above embodiment, which will not be repeated here.

[0154] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A fruit detection method, characterized in that: The method comprises: Obtain a data set for fruit detection, and divide the data set into a training set and a test set; Use the cross-scale context fusion module and the dynamic object detection head to optimize the initial detection model and obtain the reference detection model. The reference detection model is trained by using the training set and parameter weights are adjusted to obtain a target detection model; Testing and verifying the target detection model using the test set to obtain a test result; When the test result meets the preset requirements, the object detection model is used to detect the fruit.

2. The method according to claim 1, characterized in that The target detection model includes a backbone network, a neck network and a dynamic target detection head, wherein the neck network includes an attention-based intra-scale feature interaction module, a self-attention mechanism, a feedforward neural network and a cross-scale feature fusion module; The step of using the target detection model to detect fruit comprises: Extract features from the fruit image to be detected through the backbone network to obtain a first feature map, a second feature map and a third feature map; Stretching the third feature map into a one-dimensional feature vector through the attention-based intra-scale feature interaction module; Processing the feature vector through the self-attention mechanism and the feedforward neural network, and adjusting it to a two-dimensional state, to obtain a fourth feature map; Processing the first feature map, the second feature map, and the fourth feature map by the cross-scale feature fusion module to obtain a feature tensor; The feature tensor is processed using a separate attention mechanism in the dynamic target detection head to obtain a fruit detection result.

3. The method according to claim 2, characterized in that The step of processing the first feature map, the second feature map and the fourth feature map by the cross-scale feature fusion module to obtain a feature tensor comprises: Performing feature extraction, feature fusion, and feature enhancement on the first feature map and the second feature map by the cross-scale feature fusion module to obtain a processed first feature map; Upsampling, downsampling and feature fusion are performed on the second feature map by the cross-scale feature fusion module to obtain a processed second feature map; The cross-scale feature fusion module performs feature fusion on the processed first feature map, the processed second feature map, and the fourth feature map to obtain a feature tensor.

4. The method according to claim 2, characterized in that The feature tensor includes a hierarchical dimension, a spatial dimension and a channel dimension, and the dynamic target detection head includes scale-aware attention, spatial-aware attention and task-aware attention; The step of using a separate attention mechanism in the dynamic target detection head to process the feature tensor to obtain a fruit detection result comprises: Performing global average pooling and global maximum pooling on the feature tensor in the hierarchical dimension, the spatial dimension, and the channel dimension through the dynamic target detection head to obtain a global description; Processing the global description through a fully connected layer of the dynamic object detection head to obtain a scale-aware attention weight, a space-aware attention weight, and a task-aware attention weight; Applying the scale-aware attention weight, the space-aware attention weight, and the task-aware attention weight to the feature tensor to obtain a target feature tensor; The target feature tensor is subjected to target regression and classification to obtain a fruit detection result.

5. The method according to claim 1, characterized in that The step of training the reference detection model through the training set and adjusting parameter weights to obtain the target detection model comprises: The total loss is obtained based on the bounding box regression loss, classification loss and object confidence loss; The reference detection model is trained using the training set until the total loss is lower than a preset loss value, thereby obtaining a target detection model.

6. The method according to claim 1, characterized in that The step of dividing the data set into a training set and a test set comprises: splicing the images in the data set, and scaling and translating them according to a first preset ratio to obtain an intermediate data set; Adjusting the position and size of the target detection frame in the image in the intermediate data set to obtain a target data set; The target data set is divided into a training set and a test set according to a second preset ratio.

7. The method according to claim 1, characterized in that When the test result meets the preset requirements, before the step of using the target detection model to detect the fruit, the method further includes: When the test result does not meet the preset requirement, the target detection model is trained using the training set and parameter weights are adjusted until the test result meets the preset requirement.

8. A fruit detection device, characterized in that: The device comprises: A data acquisition module, used to acquire a data set for fruit detection and divide the data set into a training set and a test set; A model improvement module is used to optimize the initial detection model using a cross-scale context fusion module and a dynamic object detection head to obtain a reference detection model; A model training module, used to train the reference detection model through the training set and adjust parameter weights to obtain a target detection model; A test verification module, used to test and verify the target detection model through the test set to obtain a test result; The fruit detection module is used to detect the fruit using the target detection model when the test result meets the preset requirements.

9. A fruit detection device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the fruit detection method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the fruit detection method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Fruit hardness detection method and system, terminal and storage medium

    CN120071030A