Lightweight peanut pod detection and grading method and system based on improved YOLO model
By improving the YOLOv8 model and designing a peanut pod conveying and grading system, the problems of low efficiency and poor accuracy in peanut pod grading were solved, achieving lightweight and efficient automated grading.
Patent Information
- Application Number
- CN202511162452.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-19
- Publication Date
- 2025-11-21
AI Technical Summary
Existing technologies struggle to achieve efficient and accurate grading of peanut pods. In particular, the irregularity and complex surface characteristics of peanut pods prevent existing detection methods from being directly applied, and traditional grading devices are costly and fail to meet the requirements for fine grading.
An improved YOLOv8 model was adopted, and the backbone network and neck network were optimized. The C2f_iRMA module and Focaler-CIoU loss function were introduced. Real-time detection and grading were performed in conjunction with mobile terminals or embedded devices, and a peanut pod conveying and grading system was designed.
It achieves lightweight, efficient detection and automated grading of peanut pods, reducing the number of model parameters and computational resource requirements, and improving the recognition accuracy and grading accuracy of peanut pods.
Smart Images

Figure CN120997190A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent grading technology for peanut pods, and in particular to a lightweight method and system for detecting and grading peanut pods based on an improved YOLO model. Background Technology
[0002] In modern agriculture, quality control and grading of peanut pods is crucial for product quality assessment. Traditional peanut pod grading methods rely on manual labor, resulting in low efficiency and poor accuracy. With the continuous development of machine vision technology and deep learning methods, vision-based automated grading methods are gradually becoming an effective solution to this problem. Through efficient target detection algorithms, features such as peanut pod size and surface defects can be quickly and accurately identified, and the pods can be graded in real time based on these features, thereby improving grading accuracy and production efficiency.
[0003] Among numerous single-stage object detection algorithms, the YOLO series stands out. As a typical single-stage detection algorithm, YOLO is renowned for its superior detection speed and real-time performance. In existing technology, patent CN119608618A provides a machine vision-based apple grading method. Although this method uses the YOLO model and image processing technology for fruit grading, it is designed for relatively regular fruits such as apples. The surface features of apples differ from those of peanut pods in terms of size, shape, and the complexity of surface texture. In particular, the irregular size and shape of peanut pods make it difficult to directly apply the feature extraction and grading strategies used in this method to peanut pod detection. Therefore, while these methods provide some insights into fruit grading, specific algorithm optimization and model improvement are still needed for applications involving peanut pods.
[0004] In the field of other target object detection, patent CN118279272A mentions a steel plate surface defect detection method based on an improved YOLOv8. Although this patent employs an improved YOLOv8 architecture and introduces the iRMB attention mechanism and improvements to the C2f module (named the C2f-iRMB module), its primary detection target is steel plate surface defects. However, the characteristics of steel plate surfaces and peanut pods are significantly different. Steel plate surfaces are generally flat with obvious textures, while peanut pods have natural and complex curves, color differences, and surface irregularities. These characteristics make effective feature extraction methods for steel plate surface detection unsuitable for peanut pods. Therefore, the patent's technical method, despite incorporating YOLOv8 optimizations, cannot meet the requirements for lightweight, high-precision detection of peanut pods, especially when processing the fine-grained features of peanut pods, where the original model structure and feature processing methods have limitations.
[0005] In summary, although existing technologies have made significant progress in other fields, the differences between the detection targets and the characteristics of peanut pods make them unsuitable for efficient and accurate grading of peanut pods.
[0006] In addition, regarding grading devices, patent CN 201534145 U describes grading fruits based on their weight using a lever mechanism. However, this method is difficult and costly for weighing peanuts and cannot meet the requirements for fine grading of complex objects like peanut pods. Summary of the Invention
[0007] Purpose of the invention: In order to overcome the shortcomings of the existing technology, the present invention provides a lightweight peanut pod detection and grading method and system based on an improved YOLO model, which ensures the accuracy of peanut pod recognition, optimizes the model structure, significantly reduces the number of model parameters, shrinks the model size, and makes the model easy to deploy.
[0008] Technical Solution: To achieve the above objectives, the present invention provides a lightweight peanut pod detection and grading method based on an improved YOLO model, the method comprising:
[0009] Obtain a peanut pod dataset; the peanut pod dataset contains pre-collected and labeled peanut pod images;
[0010] A pre-built improved YOLO model is trained using a portion of the peanut pod dataset, and the model's accuracy is validated using another portion of the dataset until the model's accuracy meets the preset requirements, resulting in a pod detection and grading model. The improved YOLO model is based on the YOLOv8 network structure and includes a backbone network, a neck network, and a head network. The neck network is used to interactively fuse feature maps of different scales from the backbone network. The head network is used to process the fused feature maps and output the detection results of peanut pods, including the bounding box position, class confidence, and pod grade classification for each peanut pod.
[0011] The pods are graded online using the pod detection and grading model.
[0012] Both the backbone network and the neck network include a C2f_iRMA module. The backbone network includes multiple standard convolutional layers (Conv) and C2f_iRMA. The C2f_iRMA module is obtained by introducing an iRMA module after the second convolutional module in the Bottleneck of the conventional C2f architecture. The iRMA module is obtained by inserting the EMA attention mechanism before the DW-Conv layer in the inverse residual structure, which can improve feature extraction efficiency and representation ability. In this invention, the modified Bottleneck is called Bottleneck_iRMA, which performs efficient feature extraction processing on the output features after two convolutions, and better captures the complex feature relationships between peanut pods of different levels.
[0013] In the neck network, a 1×1 convolutional layer is added to recalibrate the feature maps before the feature map stitching operation. The improved neck network is named the CCF_Neck network.
[0014] The pod detection and grading model trained above is named PG-YOLOv8 model. The trained PG-YOLOv8 model is deployed to mobile terminals or embedded devices to perform real-time detection and grading on new peanut pod images.
[0015] Furthermore, the Focaler-CIoU loss function is used in the head network, and its formula is as follows:
[0016]
[0017] in,
[0018] ; ;
[0019] ; ;
[0020] In the formula: The traditional CIoU loss function; The loss function is the reconstructed value; IoU is the ground truth bounding box. With prediction box The intersection and union ratio; This is the adjusted IoU introduced by Focaler, which dynamically adjusts the attention based on the degree of overlap between samples; The minimum threshold; The upper limit threshold; and Indicates the center point of the predicted bounding box and the ground truth bounding box. The Euclidean distance between the two center points; The length of the diagonal of the smallest bounding rectangle between the predicted bounding box and the ground truth bounding box; These are weighting coefficients. It is a parameter representing the similarity between aspect ratios; , , and These represent the width and height of the ground truth bounding box and the predicted bounding box, respectively.
[0021] Furthermore, the method for obtaining centralized data in the peanut pod dataset described herein includes:
[0022] Images of peanut pods of different varieties, sizes, and shapes were collected, covering multiple categories such as intact pods and damaged pods;
[0023] Label the peanut pods in each image and obtain the bounding box coordinates of each pod and its corresponding hierarchical category label;
[0024] The labeled image data is divided into training and testing sets according to a predetermined ratio for model training and performance evaluation.
[0025] Furthermore, the online grading of pods using the pod detection and grading model includes:
[0026] Deploy the trained pod detection and grading model to mobile terminals or embedded devices;
[0027] Get a new image of a peanut pod;
[0028] Real-time detection and grading are performed on the peanut pod images to obtain the grade information of the peanut pods.
[0029] Furthermore, the head network includes multiple detection heads, each used to output the location and grading information of peanut pods for feature maps of different scales.
[0030] A lightweight peanut pod detection and grading system based on an improved YOLO model includes:
[0031] A peanut pod conveying device is used to convey peanut pods. In this invention, the peanut pod conveying device is a conveyor belt.
[0032] Multiple grading actuators arranged on both sides of the peanut pod conveying device are used to separate peanuts of corresponding grades from the peanut pod conveying device; specifically, the grading actuator includes a lever and a rotary drive unit that drives the lever to rotate, the rotary drive unit being a servo motor or a motor.
[0033] A peanut feeding device includes a hopper, a W-shaped feeding track, and a vibration mechanism that vibrates the feeding track. The feeding track has two pointed bottom grooves.
[0034] A camera used to capture images of peanut pods;
[0035] A control system is used to implement the aforementioned lightweight peanut pod detection and grading method based on the improved YOLO model.
[0036] The vibration mechanism causes the feeding track to vibrate, enabling the peanut pods to move towards the peanut pod conveyor. During this movement, the peanut pods adjust their posture, ensuring their length aligns with the conveying direction of the feeding track. A baffle is located in the middle of the feeding track, with a gap between the track and the baffle. Peanut pods passing through this gap are arranged in a single row on the feeding track. Furthermore, the conveying speed of the peanut pod conveyor is greater than the vibration feeding speed of the feeding track, allowing the peanut pods to be fully separated, facilitating the grading actuators to remove their corresponding peanut pods from the conveyor.
[0037] In the above system, the W-shaped feeding track can divide the peanut pods falling from the hopper into two paths, and place the peanut pods along the length of the feeding track to both sides of the peanut feeding device, which is convenient for the grading execution device to process. In this way, the peanut pods have a consistent posture in the image captured by the camera, and the control system does not need to perform posture rotation or other processing on the peanut pod images. This can reduce the computational resources required for training the pod detection and grading model, as well as the computational resources required for online grading using the pod detection and grading model.
[0038] After determining the peanut grade based on the image of the peanut pods, the control system identifies the corresponding grading actuator for each peanut pod. Based on the position of the peanut pods on the peanut pod conveyor and the conveying speed of the peanut pod conveyor, the system determines the unfolding and retraction times of the lever in the corresponding grading actuator. Based on this, the system controls the operation of the rotary drive unit to achieve the grading operation.
[0039] Beneficial Effects: The lightweight peanut pod detection and grading method and system based on the improved YOLO model of the present invention has the following beneficial effects:
[0040] (1) In this invention, the backbone network and neck network are improved based on the YOLOv8 network structure, which fully meets the characteristics of peanut pods themselves and the characteristics of grading peanut pods. After structural optimization, the number of parameters and model size are greatly reduced, and the model has lightweight and efficient detection performance. It can run stably in resource-constrained environments. The trained PG-YOLOv8 model can automatically determine the grade of peanut pods based on the model output, realizing the automatic and rapid grading of peanut pods.
[0041] (2) In the training process, the improved loss function Focaler-CIoU is introduced to optimize the model and replace the original CIoU loss function. Focaler-CIoU gives higher weight to peanut pod samples that are difficult to detect and integrates the Focal Loss idea to dynamically adjust the weight distribution of different samples in the loss calculation, thereby improving the model's learning ability for minority classes and small-sized peanut pods and accelerating model convergence. Attached Figure Description
[0042] Figure 1 This is a flowchart illustrating a lightweight peanut pod detection and grading method based on an improved YOLO model.
[0043] Figure 2 This is a structural diagram of the PG-YOLOv8 model of the present invention;
[0044] Figure 3 A structural diagram of the iRMB network structure in the existing technology;
[0045] Figure 4 This is a structural diagram of the iRMA network structure in this invention;
[0046] Figure 5 This is a structural diagram of the C2f_iRMA network structure in this invention;
[0047] Figure 6 A side view of a peanut pod detection and grading system;
[0048] Figure 7 A top view of the peanut pod detection and grading system;
[0049] Figure 8 for Figure 7 Enlarged structure of section A;
[0050] Figure 9 This is a structural diagram of the feeding track.
[0051] In the diagram: 10-Peanut pod conveying device; 20-Grading execution device; 21-Lever; 22-Rotary drive unit; 30-Peanut feeding device; 31-Hopper; 32-Feeding track; 33-Vibration mechanism; 34-Baffle; 40-Camera; 50-Control system. Detailed Implementation
[0052] The invention will now be further described with reference to the accompanying drawings.
[0053] like Figure 1 The lightweight peanut pod detection and grading method based on the improved YOLO model shown includes the following steps S101-S103:
[0054] Step S101: Obtain a peanut pod dataset; the peanut pod dataset contains pre-collected and labeled peanut pod images;
[0055] Step S102: Use a portion of the data in the peanut pod dataset to train the pre-built improved YOLO model, and use another portion of the data to verify the model accuracy until the model accuracy meets the preset requirements (such as the grading accuracy reaching more than 90%), and obtain the pod detection and grading model.
[0056] Step S103: Use the pod detection and grading model to grade the pods online.
[0057] In step S102 above, the improved YOLO model is based on the YOLOv8 network structure and includes a backbone network, a neck network, and a head network.
[0058] Both the backbone network and the neck network include a C2f_iRMA module; such as Figure 5 As shown, the C2f_iRMA module is obtained by introducing the iRMA module after the second convolution module in the Bottleneck module in the regular C2f.
[0059] In real-world automated peanut pod grading scenarios, pod recognition and grading involve rapid, real-time image processing. To achieve higher recognition accuracy while reducing computational costs, this invention improves upon the inverse residual structure iRMB by designing an iRMA module, such as... Figure 3 The diagram shown is a structural diagram of the iRMB network in the prior art, which is also a structural diagram of the inverse residual structure, as follows. Figure 4 As shown, the iRMA module is obtained by inserting the EMA attention mechanism before the DW-Conv layer in the inverse residual structure, thus improving feature extraction efficiency and representation capability. The structure is as follows: Figure 5The model adaptively adjusts feature selection while smoothing input features, helping the DW-Conv layer extract important features of peanut pods more efficiently. iRMA fully leverages the efficient computational power of the inverse residual structure and the multi-scale spatial information capture capability of EMA attention. First, it standardizes the input peanut pod data using Batch Normalization (BatchNorm2d) to improve training stability. The processed peanut image data then undergoes the EMA multi-scale attention mechanism to extract important information about the input pod features. It utilizes parallel 1x1 and 3x3 convolutional paths to capture inter-channel and spatial dependencies, respectively. 1x1 convolutions handle inter-channel interactions, while 3x3 convolutions capture local pod features, effectively enhancing feature representations between different pod categories. After passing through the EMA module, the feature maps are processed by 3x3 depthwise convolutions. Convolution operations are performed independently on each channel, further reducing computation and parameter count. After depthwise convolution, 1x1 convolutions are used to reduce the number of channels back to the original number. This process helps integrate peanut pod features and reduce redundant information. Finally, by randomly discarding certain paths and adding the residuals to the original input to output the feature map, the risk of overfitting during training can be effectively reduced, thus enhancing the robustness of the model.
[0060] To address the issues of channel information redundancy and poor extraction performance for targets of different sizes in the C2f module of YOLOv8n when extracting features of peanut pods at adjacent levels, this paper improves the Bottleneck module in C2f using the iRMA module and names it Bottleneck_iRMA. Figure 6 As shown, iRMA is introduced after the second convolutional module to perform efficient feature extraction processing on the output features after two convolutions, better capturing the complex feature relationships between peanut pods of different levels, and improving Bottleneck's feature extraction capability and robustness.
[0061] Specifically, such as Figure 2 As shown, the backbone network includes multiple standard convolutional layers (Conv) and C2f_iRMA. The neck network is used to interactively fuse feature maps of different scales from the backbone network; the head network is used to process the fused feature maps and output the detection results of peanut pods, including the bounding box position, class confidence, and pod grade classification for each peanut pod.
[0062] In the described neck network, a 1×1 convolutional layer is added before the feature map stitching operation to recalibrate the feature maps, emphasizing important features and suppressing unimportant features. This also reduces the number of channels in the feature maps, thereby reducing the computational complexity of subsequent stitching operations. This makes the network more efficient in processing different input data, reduces unnecessary feature calculations, and avoids repetitive feature processing. The improved neck network is named the CCF_Neck network.
[0063] Figure 2 In the backbone network, there are two standard convolutional layers (Conv), one regular C2f module, a standard convolutional layer (Conv), a C2f_iRMA module, a standard convolutional layer (Conv), a C2f_iRMA module, a standard convolutional layer (Conv), a C2f_iRMA module, a standard convolutional layer (Conv), a C2f_iRMA module, and an SPPF module.
[0064] The CCF_Neck network performs interactive fusion of the feature maps in the three dimensions corresponding to the first two C2f_iRMA modules and the SPPF module. Each feature map is first recalibrated by a 1×1 convolutional layer before subsequent concatenation operations. Figure 1 The CCF_Neck includes three fusion paths. The first fusion path consists of a 1×1 convolutional layer (Conv), a Concat module, and a C2f_iRMA module. The second fusion path consists of a 1×1 convolutional layer (Conv), a Concat module, a C2f_iRMA module, a standard convolutional layer (Conv), a Concat module, and a C2f_iRMA module. The third fusion path consists of a 1×1 convolutional layer (Conv), an Upsample module, a contact module, and a C2f module. The features output by the 1×1 convolutional layer (Conv) in the third fusion path... Figure 1 The first concat module of the second fusion path is input to the first concat module of the second fusion path. The concat module of the first fusion path concatenates the feature map of the current path with the feature map output from the standard convolutional layer Conv of the second fusion path. The feature map concatenated by the concat module of the first fusion path is then input into the second concat module of the second feature map after passing through the C2f_iRMA module and a standard convolutional layer Conv. The output of the second concat module of the second fusion path is then output to the head network and, after passing through the second C2f_iRMA module, to the contact module of the third fusion path after passing through a standard convolutional layer Conv. The head network contains three detection heads corresponding to the three fusion paths.
[0065] In the aforementioned improvements, on the one hand, to address the channel redundancy issue of the conventional C2f module in YOLOv8, an iRMA module is obtained by inserting the EMA attention mechanism before the DW-Conv layer in the inverse residual structure. This iRMA module is then introduced into the Bottleneck of C2f. The improved C2f_iRMA enhances feature extraction capabilities and the ability to capture features at different levels of peanut pods. It can adaptively adjust feature selection while smoothing input features, enhancing model robustness. Furthermore, it reduces overfitting through random discarding, helping the DW-Conv layer extract important peanut pod features more efficiently. On the other hand, by adding a 1×1 convolutional layer to the neck network before feature map stitching, the feature maps are recalibrated. This allows for selective enhancement of important features, suppression of unimportant features, and reduction of channel dimensions, resulting in a fused feature map for detection.
[0066] The pod detection and grading model trained above is named PG-YOLOv8 model. The trained PG-YOLOv8 model is deployed to mobile terminals or embedded devices to perform real-time detection and grading on new peanut pod images.
[0067] In this invention, the backbone and neck networks are improved based on the YOLOv8 network structure, which fully meets the characteristics of peanut pods themselves and the characteristics of grading peanut pods. After structural optimization, the number of parameters and the model size are greatly reduced, and it has lightweight and efficient detection performance. It can run stably in resource-constrained environments. The trained PG-YOLOv8 model can automatically determine the grade of peanut pods based on the model output, realizing automated and rapid grading of peanut pods.
[0068] Preferably, the Focaler-CIoU loss function is used in the head network, and its formula is:
[0069]
[0070] in,
[0071] ; ;
[0072] ; ;
[0073] In the formula: The traditional CIoU loss function; The loss function is the reconstructed value; IoU is the ground truth bounding box. With prediction box The intersection and union ratio; This is the adjusted IoU introduced by Focaler, which dynamically adjusts the attention based on the degree of overlap between samples; The minimum threshold; The upper limit threshold; and Indicates the center point of the predicted bounding box and the ground truth bounding box. The Euclidean distance between the two center points; The length of the diagonal of the smallest bounding rectangle between the predicted bounding box and the ground truth bounding box; These are weighting coefficients. It is a parameter representing the similarity between aspect ratios; , , and These represent the width and height of the ground truth bounding box and the predicted bounding box, respectively.
[0074] During training, an improved loss function, Focaler-CIoU, is introduced to optimize the model, replacing the original CIoU loss function. Focaler-CIoU assigns higher weights to peanut pod samples that are difficult to detect and incorporates the FocalLoss idea to dynamically adjust the weight distribution of different samples in the loss calculation, thereby improving the model's ability to learn minority classes and small-sized peanut pods and accelerating model convergence.
[0075] In contrast, the CIoU loss function used in YOLOv8 may cause the model to pay the same amount of attention to all samples. When dealing with unevenly distributed samples, it may not be able to effectively focus on difficult samples such as small peanut pods that are hard to identify, thus affecting the accuracy of pod detection.
[0076] Preferably, the method for obtaining centralized data of the peanut pod dataset in step S101 includes the following steps S201-S203:
[0077] Step S201: Collect images of peanut pods of different varieties, sizes and shapes, covering multiple categories such as intact pods and damaged pods;
[0078] Step S202: Label the peanut pods in each image and obtain the bounding box coordinates of each pod and its corresponding hierarchical category label;
[0079] Step S203: The labeled image data is divided into training set and test set according to a predetermined ratio for model training and performance evaluation.
[0080] Preferably, the online grading of pods using the pod detection and grading model in step S103 includes steps S301-S303:
[0081] Step S301: Deploy the trained pod detection and grading model to a mobile terminal or embedded device.
[0082] Step S302: Obtain a new peanut pod image;
[0083] Step S303: Perform real-time detection and grading on the peanut pod image to obtain the grade information of the peanut pods.
[0084] Preferably, the head network includes multiple detection heads, each used to output the location and grading information of peanut pods for feature maps of different scales.
[0085] This invention also provides a lightweight peanut pod detection and grading system based on an improved YOLO model, such as... Figure 6 and Figure 7 As shown, it includes:
[0086] Peanut pod conveying device 10 is used to convey peanut pods. In this invention, the peanut pod conveying device 10 is a conveyor belt.
[0087] Multiple grading actuators 20 arranged on both sides of the peanut pod conveying device 10 are used to separate peanuts of corresponding grades from the peanut pod conveying device 10; specifically, such as... Figure 8 As shown, the graded execution device 20 includes a lever 21 and a rotary drive unit 22 for driving the lever 21 to rotate. The rotary drive unit 22 is a servo motor or a motor.
[0088] The peanut feeding device 30 includes a hopper 31, a feeding track 32 with a W-shaped cross section, and a vibration mechanism 33 for vibrating the feeding track 32. The feeding track 32 has two pointed bottom grooves.
[0089] Camera 40 is used to acquire images of peanut pods;
[0090] The control system 50 is used to implement the above-described lightweight peanut pod detection and grading method based on the improved YOLO model.
[0091] The vibration mechanism 33 vibrates the feeding track 32, enabling the peanut pods to move towards the peanut pod conveying device 10. During this movement, the peanut pods can adjust their posture, ensuring their length aligns with the conveying direction of the feeding track 32. The feeding track 32 has a baffle 34 in its middle, with a gap between the feeding track 32 and the baffle 34. Peanut pods passing through this gap are arranged in a single row on the feeding track 32. Furthermore, the conveying speed of the peanut pod conveying device 10 is greater than the vibration feeding speed of the feeding track 32, allowing the peanut pods to be fully separated, facilitating the grading actuators 20 to remove their corresponding peanut pods from the peanut pod conveying device 10.
[0092] Based on the above system, peanut pod images can be collected first. The user marks the collected images to form a peanut pod dataset. After the control system 50 implements steps S101-S102 based on the peanut pod dataset, a peanut pod detection and grading model can be obtained and applied to the online detection and grading in step S103.
[0093] In the above system, the W-shaped feeding track 32 can divide the peanut pods falling from the hopper 31 into two paths, and place the peanut pods along the length direction of the feeding track 32 to both sides of the peanut feeding device 30, which is convenient for the grading execution device 20 to process. In this way, the peanut pods in the image captured by the camera 40 have a consistent posture, and the control system 50 does not need to perform posture rotation or other processing on the peanut pod images. This can reduce the computational resources required for the training process of the pod detection and grading model, as well as the computational resources required for online grading using the pod detection and grading model.
[0094] After determining the grade of peanuts based on the image of peanut pods, the control system 50 determines the grading execution device 20 corresponding to the peanut pods. Based on the position of the peanut pods on the peanut pod conveying device 10 and the conveying speed of the peanut pod conveying device 10, the control system 50 determines the unfolding time and retraction time of the lever 21 in the corresponding grading execution device 20, and controls the rotary drive unit 22 to operate accordingly to realize the grading operation.
[0095] Furthermore, the field of view of the camera 40 includes not only part of the image of the feeding track 32, but also part of the image of the peanut pod conveying device 10; thus, the control system 50 can acquire images of peanut pods with regular postures on the feeding track 32 for detection and grading, and can also acquire images of pods on the peanut pod conveying device 10 to obtain the position information of the peanut pods, which facilitates determining the operating time of the corresponding grading execution device 20.
[0096] In order for the control system 50 to acquire more comprehensive images of peanut pods, such as Figure 9 As shown, each of the pointed bottom grooves of the feeding track 32 has densely arranged protrusions on one side of the groove wall, while the other side of the groove wall is smooth. In this way, each time the peanut pod is thrown up and falls back, it can be deflected at a certain angle by the action of the protrusions on one side, so that the camera 40 can acquire multi-angle images of the peanut pod. The control system 50 can acquire comprehensive information about the peanut pod based on the images. In addition to making a grade judgment, it can also acquire defect data of the peanut pod, making it convenient to pick out defective peanut pods.
[0097] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A lightened peanut pod detection and grading method based on an improved YOLO model, the method comprising: obtaining a peanut pod dataset; the peanut pod dataset comprising pre-collected and labeled peanut pod images; training a pre-constructed improved YOLO model using part of the data in the peanut pod dataset, and verifying the model accuracy using another part of the data until the model accuracy meets the preset requirements, to obtain a pod detection and grading model; the improved YOLO model is improved based on a YOLOv8 network structure, including a backbone network, a neck network, and a head network; the neck network is used to interactively fuse feature maps of different scales from the backbone network; using the pod detection and grading model to perform online grading of peanut pods; characterized in that: the backbone network and the neck network each comprise a C2f_iRMA module, which is obtained by introducing an iRMA module after the second convolution module in the Bottleneck of a conventional C2f; the iRMA module is obtained by inserting an EMA attention mechanism before a DW-Conv layer in a reverse residual structure; in the neck network, a 1x1 convolution layer is added before the feature map splicing operation to recalibrate the feature map.
2. The improved YOLO model-based lightened peanut pod detection and grading method according to claim 1, characterized in that, in the head network, a Focaler-CIoU loss function is used, and its formula is: wherein, ; ; ; ; wherein: is the traditional CIoU loss function; is the restructured loss function; IoU is the intersection over union of the real target box and the predicted box ; is the adjusted IoU introduced by Focaler; is the lowest threshold value; is the upper threshold value; and denote the center points of the predicted box and the real box, is the Euclidean distance between the two center points; is the diagonal length of the minimum circumscribed rectangle of the predicted box and the real box; is the weight coefficient, is the parameter of the similarity between the length and width ratios; , , and denote the width and height of the real box and the predicted box, respectively.
3. The improved YOLO model-based lightened peanut pod detection and grading method according to claim 1, characterized in that, the method for obtaining data in the peanut pod dataset comprises: collecting peanut pod images of different varieties, sizes, and shapes, covering various categories such as complete pods and damaged pods; annotating the peanut pods in each image to obtain the bounding box coordinates and corresponding grading class labels of each pod; dividing the annotated image data into a training set and a test set according to a predetermined proportion for model training and performance evaluation.
4. The improved YOLO model-based lightened peanut pod detection and grading method according to claim 1, characterized in that, the use of the pod detection and grading model for online grading of peanut pods comprises: deploying the trained pod detection and grading model to a mobile terminal or an embedded device; obtaining new peanut pod images; performing real-time detection and grading on the peanut pod images to obtain the grade information of the peanut pods.
5. The improved YOLO model-based lightened peanut pod detection and grading method according to claim 1, characterized in that, the head network comprises multiple detection heads for outputting the position and grading class information of peanut pods for feature maps of different scales.
6. The lightened peanut pod detection and grading system based on improved YOLO model, characterized in that, it comprises: a peanut pod conveying device (10) for conveying peanut pods; a plurality of grading execution devices (20) arranged on both sides of the peanut pod conveying device (10) for removing peanut pods of corresponding grades from the peanut pod conveying device (10); a peanut delivery device (30) comprising a hopper (31), a W-shaped feeding track (32), and a vibration mechanism (33) for vibrating the feeding track (32); a camera (40) for obtaining images of peanut pods; a control system (50) for implementing the lightened peanut pod detection and grading method based on the improved YOLO model according to any one of claims 1-5.
Citation Information
Patent Citations
Apple grading device and method based on machine vision technology
CN119608618A
lever-type weight grading fruit sorting machine
CN201534145U