Fruit maturity and surface defect detection method and system
By improving the YOLOv8n object detection model, combining SPD-Conv, DWRSeg module and EIoU loss function, the problem of fruit maturity and surface defect detection is solved, efficient detection on fruit trees is achieved, and detection accuracy and robustness are improved.
Patent Information
- Application Number
- CN202411248215.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-27
AI Technical Summary
In the prior art, fruit maturity and surface defect detection are mainly carried out in the processing and classification stage after picking. It is not possible to simultaneously detect maturity and surface defect detection on the fruit tree, resulting in difficult time detection and feedback on fruit maturity and surface defects.
Using the improved YOLOv8n object detection model, the SPD-Conv module is introduced into the backbone feature extraction network, the DWRSeg module is incorporated into the neck network, and the loss function is replaced as the EIoU function, combining data cleaning and enhancement technology to establish a model training Label the data set to detect fruit maturity and surface defects.
It realizes the detection of fruit maturity and surface defects on the fruit tree simultaneously, improves the accuracy and robustness of the detection, can effectively detect multi-scale information in complex environments, and reduces the problem of insufficient energy extraction of dense target features by the model. Improves the accuracy and real-time detection.
Smart Images

Figure CN119205658A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent agriculture, and in particular, relates to a method and system for detecting fruit maturity and surface defects. Background Art
[0002] In the field of smart agricultural technology, it is necessary to detect the maturity and defects of fruits to determine the quality of the fruits. By detecting the maturity and defects of fruits, ripe fruits can be picked and defective fruits can be separated, which can help fruit farmers improve the quality of fruits and improve their economic benefits. Therefore, in the field of smart agricultural technology, fruit maturity detection and defect detection are of great significance in assisting fruit farmers to improve fruit quality.
[0003] In the process of automatic picking, the detection of the maturity and surface defects of fruits is of great significance. Since field data collection and manual data annotation require a lot of energy, there are relatively few data sets for fruit maturity and surface defects, so there are relatively few detection methods based on deep learning. Therefore, so far most fruit detection systems are mainly used in the processing and classification stages after picking, and there is no research on the simultaneous maturity and surface defect detection of fruits on fruit trees. This means that the maturity and surface defects of fruits on trees are difficult to detect and feedback in time. With the continuous advancement of computer vision and image processing technology, scholars have begun to study the feasibility of directly detecting the maturity and surface defects of fruits on fruit trees in orchards. Therefore, the present invention takes plums as the research object, directly detects the maturity and surface defects of plum fruits on plum trees, and proposes a fruit maturity and surface defect detection method and detection system. Summary of the invention
[0004] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0005] To solve the above problems, the present invention adopts the following technical solutions.
[0006] A method for detecting fruit maturity and surface defects comprises the following steps:
[0007] Receiving an improvement instruction, and improving YOLOv8n as a baseline model in response to the improvement instruction to obtain an improved target detection model;
[0008] Acquire multiple fruit images, and optimize the multiple fruit images;
[0009] Establish a data set for model training based on the optimized fruit images;
[0010] Annotating the fruit images in the data set according to the preset maturity and surface defect categories to obtain an annotated data set; training and verifying the improved target detection model based on the annotated data set to obtain an improved target detection model after training;
[0011] The target to be detected is obtained, and the target to be detected is detected by using an improved target detection model to obtain detection results of fruit maturity and surface defects.
[0012] Preferably, the improvement instruction includes a first improvement instruction, a second improvement instruction and a third improvement instruction; receiving the improvement instruction, and improving the YOLOv8n as a baseline model in response to the improvement instruction to obtain an improved target detection model;
[0013] The steps include:
[0014] Receiving the first improvement instruction, and adding an SPD-Conv module to the backbone feature extraction network of the baseline model according to the first improvement instruction to obtain a first improved model;
[0015] receiving the second improvement instruction, and integrating the DWRSeg module into the C2f module of the neck network of the first improved model according to the second improvement instruction to obtain a second improved model;
[0016] Receive the third improvement instruction, and replace the loss function CIoU of the second improved model with the EIoU function according to the third improvement instruction to obtain an improved target detection model.
[0017] Preferably, the specific steps of optimizing the fruit image are:
[0018] The mobile acquisition equipment is used to collect fruit images at different distances and directions in the orchard, and the RGB images of fruits at different growth stages, different backgrounds, different surface defects, and different occlusions are obtained;
[0019] Data cleaning of fruit RGB images is performed based on background complexity and image clarity.
[0020] Preferably, after the step of performing data cleaning on the fruit RGB image based on background complexity and image clarity, the method further comprises:
[0021] Determine whether the RGB image of the washed fruit meets the requirements of model training;
[0022] If so, the cleaned fruit RGB image is used as the optimized fruit image;
[0023] If not, data enhancement processing is performed on the cleaned fruit RGB image, and the enhanced RGB image is used as the optimized fruit image.
[0024] Preferably, the data enhancement processing includes any one or more of scaling, mirroring, enhancing image contrast and Gamma transformation.
[0025] Preferably, the fruit images in the data set are annotated according to the preset maturity and surface defect categories to obtain an annotated data set, including:
[0026] The fruit images in the dataset are annotated using data annotation tools to obtain annotated datasets with different maturity and surface defects.
[0027] Preferably, the improved target detection model is trained and verified based on the labeled data set to obtain the improved target detection model, including:
[0028] Divide the labeled data set into a training set and a validation set according to a preset ratio;
[0029] Input the training set into the improved target detection model to start training;
[0030] Detect the performance of the model and obtain the detection evaluation indicators of the model. The detection evaluation indicators of the model include average accuracy, recall rate, and accuracy;
[0031] The trained target detection model is verified using the validation set. After determining that the model performance meets the preset requirements, the training is terminated to obtain an improved target detection model.
[0032] Another aspect of the present invention provides a detection system for executing the above-mentioned fruit maturity and surface defect detection method, which adopts the following technical scheme.
[0033] A fruit maturity and surface defect detection system, comprising:
[0034] An image acquisition module is used to acquire fruit images and optimize the acquired fruit images;
[0035] A model building module, used to build a data set for model training based on the optimized fruit images;
[0036] An image annotation module is used to annotate the fruit images in the data set according to the preset maturity and surface defect categories to obtain an annotated data set;
[0037] A training module is used to train and verify the improved target detection model based on the labeled data set to obtain the trained improved target detection model;
[0038] The detection module is used to obtain the fruit image to be detected, input the fruit image to be detected into the improved target detection model, and obtain the detection results of fruit maturity and surface defects.
[0039] Preferably, the above detection system further comprises:
[0040] The model improvement module is used to receive an improvement instruction, and in response to the improvement instruction, improve YOLOv8n as a baseline model to obtain an improved target detection model.
[0041] Preferably, the above detection system further comprises:
[0042] Login module, used for users to log in to the system;
[0043] The detection result output module is used to output the detection result output by the detection system.
[0044] Compared with the prior art, the present invention has the following beneficial effects:
[0045] The method for detecting fruit maturity and surface defects in the present invention can detect fruit maturity and surface defects at the same time; in terms of data set collection, the present invention comprehensively considers the various complex situations of different growth stages, different surface defects and fruit occlusion, and uses scaling, mirroring, enhancing image contrast and Gamma transformation to perform data enhancement to balance various data categories; in terms of model improvement, YOLOv8n is used as the baseline model, and the SPD-Conv module is introduced into the backbone network to solve the problem of fruit images containing small targets and low definition. In order to solve the problem of insufficient energy for the model to extract dense target features and improve the capture efficiency and accuracy of multi-scale information, the present invention integrates the efficient multi-scale feature extraction method DWRSeg module into the C2f module of the YOLOv8n neck network, and enhances the multi-scale receptive field features and attention mechanism without increasing the number of parameters; finally, in order to improve the model convergence speed and regression accuracy, thereby improving the accuracy of target detection, the YOLOv8n loss function is improved, and EIoU is used instead of the original YOL Ov8n loss function CIoU, so that the model can better learn and optimize the position and shape of the bounding box. Furthermore, a fruit maturity and surface defect detection system was developed, which provides fruit growers with a convenient and efficient management tool to help monitor and manage fruit growth. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a structural diagram of the target monitoring model in the present invention;
[0047] Figure 2 It is a schematic diagram of the process of the detection method of the present invention;
[0048] Figure 3It is a structural schematic diagram of the detection system in the present invention;
[0049] Figure 4 A comparison chart of the effects of the improved target detection model in the present invention and the YOLOv8n model on plum fruit detection under occlusion conditions;
[0050] Figure 5 A comparison chart of the detection effects of the improved target detection model in the present invention and the YOLOv8n model when detecting small targets;
[0051] Figure 6 This is a comparison chart of the effects of the improved target detection model in the present invention and the YOLOv8n model on fruit detection and counting in a complex environment. DETAILED DESCRIPTION
[0052] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0053] The present invention aims to provide a method for detecting fruit maturity and surface defects, and its main purpose is to simultaneously detect the fruit maturity and surface defects, comprising the following steps.
[0054] Collect fruit images in the orchard using image acquisition equipment;
[0055] Perform data cleaning and data enhancement on the collected fruit images to obtain target detection images that meet the requirements;
[0056] The images were annotated using the data annotation tool labelme to obtain annotated images of different maturity and surface defects;
[0057] Divide the labeled images into training and test sets;
[0058] Improving the target detection model to obtain an improved target detection model;
[0059] The data set is trained and verified through the improved target detection model to obtain the detection results.
[0060] In the present invention, a 48-megapixel smartphone or Canon camera is used as a mobile acquisition device when acquiring fruit images, and the shooting resolution is set to 4608×3072, the exposure parameter is automatic, and the focus mode is auto focus. In order to collect as much fruit information as possible in the natural environment, fruit trees at different growth stages are selected, and the shooting distance and shooting angle are constantly changed, in order to collect RGB images of different sizes, different colors, different backgrounds, different lighting, different occlusion conditions, and different surface defects.
[0061] Of course, in the present invention, the social security collection includes but is not limited to the above-mentioned smart phones or Canon cameras. As long as the smart shooting device can obtain the fruit image with the above-mentioned resolution, it can be used as a collection device in the present invention.
[0062] The pixel size of the collected fruit images is 4608×3072. In order to improve the robustness of the model, a scaling algorithm is used to scale the image pixels.
[0063] In addition, the detection method of the present invention also requires data cleaning of the collected fruit images, manually deleting blurred images, duplicate images, and images that do not contain fruits, etc.; and process data enhancement by scaling, mirroring, enhancing image contrast, and gamma transformation.
[0064] In the present invention, the data annotation tool Labelme is used to annotate the images. In order to detect fruits with different maturity and surface defects, the maturity and surface defects are manually judged during the annotation process and marked as four categories: mature (m), defective (d), half-ripe (sm) and unripe (im).
[0065] The steps of image annotation are as follows.
[0066] After completing data collection and image preprocessing, we began to label the images. Based on the experience of fruit farmers, we divided the fruits into different degrees of maturity. Mature fruits were labeled as mature (m), semi-mature fruits as semi-mature (sm), immature fruits as immature (im), and fruits with surface defects as defects (d).
[0067] Then the labeled image data is divided into a training set and a test set according to a ratio of 8:2.
[0068] Finally, the improved target detection model YOLOv8n is used to train the training set as the database. The trained target detection model YOLOv8n detects the test set and outputs the detection results.
[0069] The target detection model in the present invention is based on YOLOv8n as the baseline model, and the baseline model is improved to obtain an improved target detection model. The structure diagram of the improved target detection model is as follows: Figure 1 As shown, the specific improvement methods are as follows.
[0070] The SPD-Conv module is applied to the original YOLOv8n model to improve the model's accuracy and recall for small objects. SPD-Conv downsampling does not lose learnable information, can effectively retain fine-grained feature information, and avoids information loss caused by strided convolution and pooling layers, thereby improving the model's detection accuracy and detection speed, especially on small objects and low-resolution images. An SPD-Conv module is inserted after each strided convolution layer of YOLOv8n, thereby replacing the strided convolution layer with the SPD-Conv layer while keeping the rest of the model unchanged.
[0071] In order to enable the detection method of the present invention to efficiently extract features at multiple scales, the DWRSeg module can extract multi-scale features, thereby enhancing the effect of fruit detection and improving the robustness of fruit detection under complex backgrounds. The two-step residual feature extraction method is used to retain more detail information and the SIR module of the reverse bottleneck structure is used to enhance the feature extraction capability of the low layer, thereby improving the efficiency and stability of feature extraction. The amount of calculation and model parameters can be reduced by using a simple fully convolutional network (FCN)-like decoder to aggregate multi-scale feature maps. Therefore, the lightweight design and high-speed reasoning ability of the DWRSeg module can improve the real-time detection of the model. It can specifically solve the problems of multi-scale, small targets, complex environments and real-time performance in the tasks of fruit maturity and surface defects detection in natural environments.
[0072] In addition, since the target sizes of fruits are often inconsistent during the shooting process, they may present various sizes and shapes. When shooting at different angles, some fruits may be very small and exquisite, while others may be relatively large. Sometimes fruits of different sizes can be found on the same tree at the same time. In addition, there is often mutual occlusion between fruits. These problems make it difficult to calculate the target classification and positioning losses. In order to solve the above problems, the EIoU loss function is used instead of the CIoU loss function in YOLOv8n. The EIoU (Embedding IoU) loss function is an optimization strategy proposed for the bounding box regression problem in the target detection task. It mainly aims to improve the calculation of the overlap between bounding boxes to help the model better test targets of different shapes and sizes, thereby improving the accuracy and stability of target detection, while making the model converge faster and more accurate.
[0073] Use the improved model to train the prepared training set and make predictions on the test set. In order to objectively measure the detection effect of the improved model, the overall performance of the improved model is evaluated on the test set using evaluation indicators. Among them, the main evaluation indicators include precision (Precision, P), recall (Recall, R), F1 value (F1-score), average precision (AP), mean average precision (mAP), model parameter quantity, detection speed and weight size, etc.
[0074] The model image size selected in the present invention is 640×640, and the hardware environment configuration for model training is as follows: the CPU model is Intel(R) Xeon(R) Platinum 8255C, the GPU model is RTX 3080, the system disk is 30GB, the data disk is 80GB, the memory is 40GB, and the video memory is 10GB. The software environment configuration for model training is as follows: the operating system is Ubuntu 20.04, the Python version is 3.8, the Pytorch version is 2.0.0, and the Cuda version is 11.8. The total number of iterations (epochs) is 500, the initial learning rate is set to 0.001, the batch size is 12, the Adam optimizer is used, and Mosaic data enhancement is used during training.
[0075] Another aspect of the present invention provides a fruit maturity and surface defect detection system for executing the above detection method to detect fruits, the detection system comprising:
[0076] A model improvement module, used for receiving an improvement instruction, and in response to the improvement instruction, improving YOLOv8n as a baseline model to obtain an improved target detection model;
[0077] An image acquisition module is used to acquire fruit images in the orchard and optimize the acquired fruit images;
[0078] A model building module, used to build a data set for model training based on the optimized fruit images;
[0079] An image annotation module is used to annotate the fruit images in the data set according to the categories of preset maturity and surface defects to obtain an annotation data set; wherein the categories of preset maturity and surface defects include ripe (m), defect (d), half-ripe (sm), and unripe (im);
[0080] The training module trains and verifies the improved target detection model based on the labeled data set to obtain the trained improved target detection model;
[0081] The detection module is used to obtain the fruit image to be detected, input the fruit image to be detected into the improved target detection model, and obtain the detection results of fruit maturity and surface defects.
[0082] In addition, the detection system of the present invention also includes:
[0083] Login module, used for users to log in to the system;
[0084] The detection result output module is used to output the detection results of the fruit detection system.
[0085] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0086] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not refer to the same embodiment, nor is it a separate or selective embodiment that is mutually exclusive with other embodiments. The present invention provides the following embodiments.
[0087] Example
[0088] In order to explain the fruit maturity and surface defect detection method and system of the present invention in more detail, this embodiment takes plum as an example for experimental detection, and the specific steps are as follows.
[0089] First, YOLOv8n is used as a baseline model to receive an improvement instruction, and in response to the improvement instruction, YOLOv8n is improved to obtain an improved target detection model (Improved-YOLOv8n);
[0090] Among them, the improvement instructions include a first improvement instruction, a second improvement instruction and a third improvement instruction; the first improvement instruction is received, and an SPD-Conv module is added to the backbone feature extraction network of the YOLOv8n baseline model according to the first improvement instruction to obtain a first improved model; the second improvement instruction is received, and a DWRSeg module is integrated into the C2f module of the neck network of the first improved model according to the second improvement instruction to obtain a second improved model; the third improvement instruction is received, and the loss function CIoU of the second improved model is replaced with the EIoU function according to the third improvement instruction to obtain an improved target detection model.
[0091] Secondly, a plurality of plum fruit images in the orchard are obtained. Specifically, plum fruit images at different distances and directions in the orchard are collected by a mobile acquisition device to obtain RGB images of plum fruits at different growth stages, different backgrounds, different surface defects, and different occlusions; data cleaning is performed on the plurality of plum fruit images; a data set for model training is established based on the plum fruit images after data cleaning; in addition, it is determined whether the cleaned plum fruit RGB image meets the requirements of model training, and if so, the cleaned plum fruit RGB image is used as the optimized plum fruit image; if not, data enhancement processing is performed on the cleaned plum fruit RGB image, and the enhanced RGB image is used as the optimized plum fruit image;
[0092] The plum fruit images in the data set are annotated using the data annotation tool labelme according to the preset maturity and surface defect categories to obtain an annotated data set; wherein the preset maturity and surface defect categories include ripe (m), defect (d), half-ripe (sm), and unripe (im);
[0093] Training and verifying the improved detection model based on the labeled data set to obtain a target detection model;
[0094] A target to be detected is obtained, and the target to be detected is detected by using a target detection model to obtain detection results of plum fruit maturity and surface defects; wherein the target to be detected includes plum fruit images collected from an orchard.
[0095] In this embodiment, the improved target detection model Improved-YOLOv8n is used to detect plum fruits while the YOLOv8n model is used to detect plum fruits at the same time as a comparison. The effect is as follows: Figure 4 shown.
[0096] in:
[0097] Figure 4 (a1) is the effect of the YOLOv8n model on plum fruit detection with leaves occluded. Figure 4 (b1) is the improved target detection model Improved-YOLOv8n Figure 4 (a1) The effect of image detection. From the comparison results, we can see that Figure 4 (a1) The results show that the plum fruit is blocked by the presence of plum leaves, resulting in the YOLOv8n model not detecting the plum fruit. Figure 4 (b1) It can be seen that the improved target detection model Improved-YOLOv8n can detect plum fruits even when the plum leaves are blocked;
[0098] Figure 4(a2) is the effect of YOLOv8n model on plum fruit detection under the influence of light. Figure 4 (b2) is the effect of the improved target detection model YOLOv8n model on plum fruit detection under the influence of light. Figure 4 (a2) The results show that due to the influence of light, the YOLOv8n model detects the unripe plums as ripe plums, while Figure 4 (b2) The results show that the improved target detection model Improved-YOLOv8n did not detect errors;
[0099] Figure 4 (c1) is the effect of the YOLOv8n model on plum fruit detection with fruit occlusion. Figure 4 (b1) is the improved target detection model Improved-YOLOv8n Figure 4 (c1) The effect of image detection, Figure 4 (c1) It can be seen that when the YOLOv8n model detects plum fruits, the unripe plum fruits are missed due to the occlusion of the plum fruits, while Figure 4 (c2) It can be seen that the improved target detection model Improved-YOLOv8n can successfully detect unripe plum fruits when the fruit is occluded.
[0100] For the detection of surface defects of plum fruits in natural environments, since the target defects in the dataset vary in size and shape, the detection model may be difficult to adapt to targets of different scales. Figure 5 This is a comparison chart of the results of using the improved target detection model Improved-YOLOv8n to perform small target detection on plum fruits while using the YOLOv8n model to perform small target detection on plum fruits at the same time.
[0101] in:
[0102] The first row shows the detection results of the YOLOv8n model, and the second row shows the detection results of the improved target detection model Improved-YOLOv8n. Figure 5 In (al), the plum fruit is severely blocked by leaves, and the edge information of the fruit is missing. In the lower part, it can be seen that the plum fruit defects are repeatedly marked. Figure 5 In (a2), the surface defects of the plum fruit were too small to be detected. Figure 5 In (b2), it can be seen that it is successfully detected; Figure 5 The center of (a3) is missed due to the small surface defect of the plum fruit. Figure 5It can be seen from (b3) that it is successfully detected, which shows that the improved target detection model Improved-YOLOv8n in this embodiment has a good detection effect on small targets.
[0103] In this embodiment, in order to more intuitively test the detection effectiveness and performance of the model, 100 images are randomly selected from the test set, and the detection of plum objects is compared based on the improved target detection model Improved-YOLOv8n and the YOLOv8n model. Figure 6 As shown, the counting performance of the YOLOv8n model and the improved target detection model Improved-YOLOv8n is demonstrated.
[0104] in:
[0105] The first row shows the detection results of the YOLOv8n model, and the second row shows the detection results of the improved target detection model Improved-YOLOv8n. Figure 6 It is known that in Figure 6 In the lower left corner of (al), due to the dim light, the leaves are predicted to be unripe plum fruits, while Figure 6 It can be seen from (b1) that there is no false detection; Figure 6 In the lower right corner of (a2), a plum-shaped leaf target is mistaken for an unripe plum due to its small size. Figure 6 In the middle right position of (a3), due to the lighting, the leaves are also misdetected as unripe plums. Through the analysis of counting loss, it is found that the counting errors mainly come from false positives. Most false positive errors are caused by leaves predicted as unripe plums. The improved target detection model Improved-YOLOv8n improves the feature extraction ability of the model, thereby reducing the false detection rate of the model, and the counting errors from false negatives are effectively reduced. Thus, a higher counting accuracy for specific plum fruit targets is achieved.
[0106] In this embodiment, the improved target detection model Improved-YOLOv8n is used to detect and compare 100 randomly selected pictures with YOLOv8n, and the true detection rate (TDR), missed detection rate (MDR), and false detection rate (FDR) are used to compare the models. The results are shown in Table 1.
[0107] Table 1 Comparison of detection results of improved target detection model Improved-YOLOv8n and YOLOv8n
[0108]
[0109] From the results in Table 1, we can see that the true detection rate of the YOLOv8n model is 89.64%, while the true detection rate of the Improved-YOLOv8n model is 94.31%. Compared with the YOLOv8n model, the TDR value of the Improved-YOLOv8n is increased by 4.67%. In terms of missed detection rate, the YOLOv8n model is at a higher level due to the occlusion in the natural environment, and the Improved-YOLOv8n model is slightly lower at 2.02%. In terms of false positive rate, YOLOv8n shows false detection, identifying leaves with similar colors as unripe plum fruits, while the Improved-YOLOv8n model is slightly lower at 3.60%, which reduces false detection to a certain extent.
[0110] The above content is a further detailed description of the present invention in combination with specific implementation methods. It cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as belonging to the scope of protection determined by the claims submitted for the present invention.
Claims
1. A method for detecting fruit maturity and surface defects, characterized in that: The following steps are involved: Receiving an improvement instruction, and improving YOLOv8n as a baseline model in response to the improvement instruction to obtain an improved target detection model; Acquire multiple fruit images, and optimize the multiple fruit images; Establish a data set for model training based on the optimized fruit images; Annotating the fruit images in the data set according to preset maturity and surface defect categories to obtain an annotated data set; Training and verifying the improved target detection model based on the labeled data set to obtain a trained improved target detection model; The target to be detected is obtained, and the target to be detected is detected by using an improved target detection model to obtain detection results of fruit maturity and surface defects.
2. The method for detecting fruit maturity and surface defects according to claim 1, characterized in that: The improvement instruction includes a first improvement instruction, a second improvement instruction and a third improvement instruction; receiving the improvement instruction, and responding to the improvement instruction to improve the YOLOv8n as a baseline model to obtain an improved target detection model; The steps include: Receiving the first improvement instruction, and adding an SPD-Conv module to the backbone feature extraction network of the baseline model according to the first improvement instruction to obtain a first improved model; receiving the second improvement instruction, and integrating the DWRSeg module into the C2f module of the neck network of the first improved model according to the second improvement instruction to obtain a second improved model; Receive the third improvement instruction, and replace the loss function CIoU of the second improved model with the EIoU function according to the third improvement instruction to obtain an improved target detection model.
3. The method for detecting fruit maturity and surface defects according to claim 1, characterized in that: The specific steps for optimizing fruit images are: The mobile acquisition equipment is used to collect fruit images at different distances and directions in the orchard, and the RGB images of fruits at different growth stages, different backgrounds, different surface defects, and different occlusions are obtained; Data cleaning of fruit RGB images is performed based on background complexity and image clarity.
4. The method for detecting fruit maturity and surface defects according to claim 3, characterized in that: After the step of data cleaning the fruit RGB image based on background complexity and image clarity, it also includes: Determine whether the RGB image of the washed fruit meets the requirements of model training; If so, the cleaned fruit RGB image is used as the optimized fruit image; If not, data enhancement processing is performed on the cleaned fruit RGB image, and the enhanced RGB image is used as the optimized fruit image.
5. The method for detecting fruit maturity and surface defects according to claim 4, characterized in that: The data enhancement processing includes any one or multiple of scaling, mirroring, enhancing image contrast and Gamma transformation.
6. The method for detecting fruit maturity and surface defects according to claim 1, characterized in that: The fruit images in the dataset are annotated according to the preset maturity and surface defect categories to obtain an annotated dataset, including: The fruit images in the dataset are annotated using data annotation tools to obtain annotated datasets with different maturity and surface defects.
7. The method for detecting fruit maturity and surface defects according to claim 6, characterized in that: The improved target detection model is trained and verified based on the labeled data set to obtain the improved target detection model, including: Divide the labeled data set into a training set and a validation set according to a preset ratio; Input the training set into the improved target detection model to start training; Detect the performance of the model and obtain the detection evaluation indicators of the model. The detection evaluation indicators of the model include average accuracy, recall rate, and accuracy; The trained target detection model is verified using the validation set. After determining that the model performance meets the preset requirements, the training is terminated to obtain an improved target detection model.
8. A detection system for executing the fruit maturity and surface defect detection method according to any one of claims 1 to 7, characterized in that: include: An image acquisition module is used to acquire fruit images and optimize the acquired fruit images; A model building module, used for building a data set for model training based on the optimized fruit images; An image annotation module is used to annotate the fruit images in the data set according to the preset maturity and surface defect categories to obtain an annotated data set; A training module is used to train and verify the improved target detection model based on the labeled data set to obtain the trained improved target detection model; The detection module is used to obtain the fruit image to be detected, input the fruit image to be detected into the improved target detection model, and obtain the detection results of fruit maturity and surface defects.
9. The fruit maturity and surface defect detection system according to claim 8, characterized in that: Also includes: The model improvement module is used to receive an improvement instruction, and in response to the improvement instruction, improve YOLOv8n as a baseline model to obtain an improved target detection model.
10. The fruit maturity and surface defect detection system according to claim 9, characterized in that: Also includes: Login module, used for users to log in to the system; The detection result output module is used to output the detection result output by the detection system.
Citation Information
Patent Citations
Fruit and vegetable surface quality inspection method and storage medium and sorting device thereof
CN111161237A
Apple appearance defect recognition system and method
CN113158969A
Method for detecting grape maturity based on improved YOLOv4 orchard complex environment
CN115457542A
Fruit defect detection system and method based on neural network
CN116934720A
Unbalanced data-oriented candy surface defect detection method
CN117541576A
