Lightweight sweet potato quality grading method based on improved YOLOv8
By improving the YOLOv8 model, replacing the backbone network with EdgeNeXt, designing the C2fC module and using the CARAFE operator, and proposing the FocalC-MPDIoU loss function, the problem of lightweight and high-precision detection in sweet potato grading is solved, and the efficiency of sweet potato quality grading is achieved Automatic sorting, suitable for low computing power equipment deployment.
Patent Information
- Application Number
- CN202410220681.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-28
- Publication Date
- 2024-11-19
AI Technical Summary
The existing sweet potato grading device cannot achieve both lightweight and high-precision detection of the model, resulting in low efficiency of automatic sweet potato grading and sorting, high misjudgment rate, and traditional target detection technology is sensitive to environmental factors and poor algorithm versatility.
Based on the improved YOLOv8's lightweight sweet potato quality grading method, by replacing the backbone network with EdgeNeXt, designing the C2fC module and using the CARAFE lightweight operator, and propose FocalC-MPDIoU loss function, combining data enhancement and specific sweet potato grade standards to build efficient sweet potato Quality grading model.
Lightweight and high-precision detection of sweet potato quality grading has been achieved, and the model parameter quantity, calculation quantity and weight size have decreased by 38.3%, 32.7% and 37.8%, while improving detection accuracy, which is suitable for the deployment of embedded equipment with low computing power.
Smart Images

Figure CN118982826A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of target detection, and in particular relates to a lightweight sweet potato quality grading method based on improved YOLOv8. Background Art
[0002] Currently, most sweet potato grading devices can only sort by size and weight. The sorting of defective sweet potatoes mainly relies on manual screening by workers, which is labor-intensive, low-efficiency and high-error rate.
[0003] The target detection technology in the traditional agricultural field has great requirements on the feature significance of the detection target, and the feature extraction results are affected by many factors such as the environment. At the same time, different types of agricultural products require the design of specific feature extraction schemes, and the algorithm has poor versatility. In recent years, with the improvement of computer computing resources and the in-depth research of neural network algorithms, target detection methods based on deep learning have gradually been applied to the agricultural field. For this reason, scholars have proposed many improved target detection methods applied to the agricultural field, laying the foundation for agricultural intelligence and automation. However, most target detection models currently cannot meet the requirements of both lightweight models and high detection accuracy when used for sweet potato detection: the model with high detection accuracy has a large number of parameters and calculations, and the model weights occupy a large amount of memory, which is not conducive to the deployment of the model; although the lightweight model is easy to deploy, the detection accuracy needs to be improved and cannot meet the detection task.
[0004] Therefore, in order to realize the automatic grading and sorting of sweet potatoes, it is urgent to study a low-cost sweet potato grading equipment, and the development of an efficient and lightweight sweet potato quality identification module is the key to related grading equipment. Summary of the invention
[0005] In view of the shortcomings of the prior art, the purpose of the present invention is to provide a lightweight sweet potato quality grading method based on improved YOLOv8, which can ensure detection performance while achieving lightweight and realize sweet potato quality grading.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] A lightweight sweet potato quality grading method based on improved YOLOv8 includes the following steps:
[0008] S1. The design of sweet potato grade standards divides sweet potatoes into several grades;
[0009] S2, obtaining a sweet potato image dataset, performing data augmentation on the images and dividing them into a training set, a validation set, and a test set;
[0010] S3. First, replace the backbone network in the original YOLOv8s model with the adjusted EdgeNeXt lightweight network, then use SCConv convolution to improve the C2f module to design the C2fC module, and then use the CARAFE lightweight operator to replace the upsampling module of the original model. Finally, based on Focal loss and MPDIoU, the FocalC-MPDIoU loss function is proposed to replace the loss function of the original model to obtain the improved network model.
[0011] S4. Use the training set and validation set to train the network model, and input the test set into the trained model to obtain the sweet potato quality grading results.
[0012] This classification method is based on the improvement of the YOLOv8 model, which was developed by Ultralytics for object detection, image classification, and instance segmentation tasks. For the overview, principle, and implementation of the YOLOv8 model, please refer to the Ultralytics YOLOv8 Documentation and other analysis and detailed explanation articles. I will not go into details here.
[0013] Furthermore, the sweet potato grades in step S1 include special grade, first grade and second grade, wherein the special grade sweet potato requires no rot spots, no insect damage, intact skin, no mechanical damage, and no sprouting; the first grade sweet potato requires no rot spots, no insect damage, relatively intact skin, and slight mechanical damage or sprouting is allowed; the second grade sweet potato requires rot spots, insect damage, incomplete skin, severe mechanical damage or sprouting.
[0014] Furthermore, the step S2 uses random rotation, random translation, random flipping, random cropping, Gaussian noise, brightness change, and Cutout methods to expand the enhanced data set, and divides the data set into a training set, a validation set, and a test set in a ratio of 8:1:1.
[0015] Furthermore, the specific steps of step S3 include:
[0016] S31. When introducing the EdgeNeXt structure, the C2f module in the original YOLOv8 backbone network is retained, and the introduction of spatial position encoding in the original EdgeNeXt structure is cancelled;
[0017] S32. Use SCConv convolution to improve the C2f module and design the C2fC module, where the SCConv module contains a spatial reconstruction unit (SRU) and a channel reconstruction unit (CRU). SRU first performs feature separation, separating blank feature maps or feature maps with little information from feature maps containing a lot of important information, and then reconstructs features in the spatial dimension to compress redundant features and save space. CRU is divided into three steps: splitting, transformation, and fusion. This module can reduce the redundant extraction of features in the channel dimension, complement SRU, and reduce the problem of feature redundancy in the convolution process;
[0018] S33. Use the CARAFE lightweight operator to replace the upsampling module of the original model. CARAFE consists of a kernel prediction module and a content-aware reorganization module. The kernel prediction module consists of a channel compressor, a content encoder, and a kernel normalizer. The channel compressor can simultaneously reduce the number of channels within a certain range without affecting performance. Therefore, CARAFE has advantages in terms of parameter quantity and computational complexity. The content encoder enables CARAFE to obtain a larger receptive field. The kernel normalizer uses SoftMax for normalization. The content-aware reorganization module expands the features obtained by the kernel prediction module and multiplies them with the input features at the same position to finally obtain the output feature map. The feature map output by the content-aware module pays more attention to global features than the original feature map, so it has more semantic information;
[0019] S34. Based on Focal loss and MPDIoU, a FocalC-MPDIoU loss function is proposed to replace the loss function of the original model. The MPDIoU calculation formula is as follows:
[0020] L MDPIoU =1-MDPIoU
[0021]
[0022]
[0023]
[0024] Where a and b are the width and height of the input image, G and P are the real frame and predicted frame respectively. Let (x_1^G, y_1^G), (x_2^G, y_2^G), (x_1^P, y_1^P), (x_2^P, y_2^P) be the coordinates of the upper left and lower right points of G and P respectively;
[0025] The calculation formula of FocalC-MPDIoU is as follows:
[0026] L FocalC-MPDIov =IoU α*γ L MPDIoU
[0027]
[0028]
[0029] Where γ is the parameter used to control the curvature of the curve, N is the number of samples, M is the number of categories, σ(x) is the Sigmoid transformation of the inputs one by one, and pred scoresij Represents the prediction score, and confidence represents the average confidence of all categories.
[0030] Further, the specific steps of step S4 include: during the training process, the batch size is 2-64, the optimizer uses the stochastic gradient descent method (SGD), the weight decay coefficient is 0.0001-0.005, the momentum factor is 0.9-0.95, and the initial learning rate is 0.01-0.02. Preferably, during the training process, the batch size is 4, the optimizer uses the stochastic gradient descent method (SGD), the weight decay coefficient is 0.0005, the momentum factor is 0.937, and the initial learning rate is 0.015, the network model is trained using the training set and the validation set, and the test set is input into the trained model to obtain the sweet potato quality grading result.
[0031] Based on the above, compared with the prior art, the present invention has the following beneficial effects:
[0032] 1. The present invention refers to the sweet potato grade classification standard and sweet potato processing application, and divides sweet potatoes into special grade, first grade and second grade sweet potatoes according to the characteristics of sweet potato rot spots, insect damage, skin integrity, mechanical damage, germination, etc., and shoots and uses data enhancement technology to establish a sweet potato dataset to provide data support for the research of sweet potato quality grading algorithm and automated sorting equipment.
[0033] 2. The present invention adopts YOLOv8 as the network basic model, and replaces the backbone network of YOLOv8 with EdgeNeXt. The network structure combines the advantages of CNN and visual Transformer models, and can maintain good accuracy while reducing network computing overhead. When introducing the EdgeNeXt structure, the C2f module in the original YOLOv8 backbone network is retained, and the introduction of spatial position coding in EdgeNeXt is cancelled. Retaining the C2f module can reduce the accuracy drop, while canceling the spatial position coding can reduce network delay. By performing SCConv convolution on the C2fC module, the feature redundancy problem in the ordinary convolution process can be reduced, and the model can be further lightweight. In order to ensure the detection accuracy of the model, the upsampling method in the neck network of the original model is changed to the CARAFE operator, which can obtain a larger receptive field without significantly increasing the model parameter amount, calculation amount, and weight file size, thereby improving the detection accuracy. Finally, the improved FocalC-MPDIoU loss function has better processing capabilities for difficult samples, so the detection accuracy of the model can be improved.
[0034] 3. The parameter quantity, calculation amount and model weight of the lightweight sweet potato quality grading network model constructed by the patent of this invention are reduced by 38.3, 32.7 and 37.8 percentage points respectively compared with the original model, and the model accuracy and average precision mean are increased by 0.3 and 0.9 percentage points respectively. This result shows that the deployment of the model on low-computing-power embedded devices has great advantages, laying the foundation for realizing the automated sorting of sweet potato quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 An implementation flow chart of the lightweight sweet potato quality grading method based on improved YOLOv8 provided by the present invention;
[0036] Figure 2 A network framework diagram of a lightweight sweet potato quality grading method based on improved YOLOv8 provided by the present invention;
[0037] Figure 3 6 is a block diagram of the adaptive N×N convolutional encoder module in the EdgeNeXt network provided by the present invention;
[0038] Figure 4 The structural diagram of the SDTA encoder module in the EdgeNeXt network provided by the present invention;
[0039] Figure 5 This is the structure diagram of the improved C2fC module;
[0040] Figure 6 To show the results of the verification; DETAILED DESCRIPTION
[0041] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, but the present invention is not limited to these embodiments. The present invention covers any substitution, modification, equivalent method and scheme made on the spirit and scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0042] The following is combined with Figure 1-6 The present invention is described in further detail.
[0043] A lightweight sweet potato quality grading method based on improved YOLOv8 includes the following steps:
[0044] S1. With reference to the grade standards and processing applications of sweet potatoes, the quality of sweet potatoes is divided into special grade, first grade and second grade according to the characteristics of skin integrity, hard spots, insect erosion, germination and mechanical damage. The grade standards of sweet potatoes are shown in Table 1.
[0045] Table 1 Description of sweet potato grading grades
[0046]
[0047] S2, obtaining a sweet potato image dataset, performing data augmentation on the images and dividing them into a training set, a validation set, and a test set;
[0048] S21, using a self-made data acquisition device to collect sweet potatoes at different angles, the types of collected images include single target images, multi-target single category images, multi-target multi-category images, and a total of 434 sweet potato images of 3072×2048 pixels were obtained. The self-made data acquisition device consists of an MV-CE060-10UC industrial camera, a laptop computer, a rotating mechanism, and a green conveyor belt;
[0049] S22, use the LabelImg tool to annotate the 434 sweet potato images collected, and use data enhancement methods such as random rotation, random translation, random flipping, random cropping, Gaussian noise, changing brightness, Cutout, etc. to expand the data set, and a total of 3472 labeled sweet potato images are obtained. The data set is divided into a training set (2778 images), a validation set (347 images), and a test set (347 images) in a ratio of 8:1:1. The specific number of sweet potatoes of different grades in the data set is shown in Table 2;
[0050] Table 2 Specific number of sweet potatoes of different grades in the dataset
[0051]
[0052]
[0053] S3. First, replace the backbone network in the original YOLOv8s model with the adjusted EdgeNeXt lightweight network, then use SCConv convolution to improve the C2f module to design the C2fC module, and then use the CARAFE lightweight operator to replace the upsampling module of the original model. Finally, based on Focal loss and MPDIoU, the FocalC-MPDIoU loss function is proposed to replace the loss function of the original model, and the improved network model structure is obtained as follows: Figure 2 shown.
[0054] S31. When the EdgeNeXt structure is introduced, the C2f module in the original YOLOv8 backbone network is retained, and the introduction of spatial position encoding in the original EdgeNeXt structure is cancelled. The EdgeNeXt structure is shown in Table 3. Table 3 EdgeNeXt structure
[0055]
[0056] The key structures are the adaptive N×N convolutional encoder (Conv.Encoder) and the SDTA encoder (SDTAEncoder). The structure of the adaptive N×N convolutional encoder is as follows Figure 4 As shown in the figure, its key structure is the depthwise separable convolution with adaptive kernel size. In this stage, spatial mixing is first achieved through depthwise separable convolution, then the data is normalized by standard layer, and linear layer and Gaussian error linear unit (GELU) are used to simulate pointwise convolution, and the weight of each position is calculated in the depth direction. This method can increase the network expression ability while ensuring the lightweight of the model. Finally, a residual connection is added to alleviate the problem of gradient disappearance or explosion. The SDTA encoder is shown in the figure. Figure 4 As shown in the figure, it includes two key parts. The first part divides the input tensor into B groups of channels, uses jump connections between branches and applies 3×3 deep convolutions to control the number of parameters and MAdds of the model and enhance the overall receptive field of the network. At the same time, in order to reduce the overhead of the transformer self-attention layer, a cross-covariance based self-attention function is introduced in the second part. Assuming that the input data is a tensor X with a shape of H×C×W, linear projection using weight matrices WQ, WK, and WV is used to obtain Q (query), K (key), and V (value), so that Q = XWQ, K = XWK, and V = XWV. Using the above definition, the proposed cross-covariance attention function calculated along the channel dimension features can be defined as:
[0057] C-Attention(Q, K, V) = Vδ τ (K, Q)
[0058]
[0059] Among them, the attention weight δ is based on the cross-covariance matrix; τ is a learnable temperature parameter that can be scaled before Softmax Make the distribution of attention weights more uniform. Using the above function, the operation of the second part can be expressed as:
[0060]
[0061] Where X is the input, After these two parts, the same structure as the convolution encoder above is used, namely: standard layer normalization, simulated point-by-point convolution, and residual connection.
[0062] S32, use SCConv convolution to improve the C2f module and design the C2fC module as follows Figure 5 As shown in the figure, the SCConv module includes a spatial reconstruction unit (SRU) and a channel reconstruction unit (CRU). SRU first performs feature separation, separating blank feature maps or feature maps with little information from feature maps containing a lot of important information, and then reconstructs features in the spatial dimension to compress redundant features and save space. CRU is divided into three steps: splitting, transformation, and fusion. This module can reduce the redundant extraction of features in the channel dimension, complementing SRU and reducing the feature redundancy problem in the convolution process;
[0063] S33. Use the CARAFE lightweight operator to replace the upsampling module of the original model. CARAFE consists of a kernel prediction module and a content-aware reconstruction module. The kernel prediction module consists of a channel compressor, a content encoder and a kernel normalizer. The channel compressor can simultaneously reduce the number of channels within a certain range without affecting performance, so CARAFE has advantages in terms of parameter quantity and computational complexity. The content encoder enables CARAFE to obtain a larger receptive field. The kernel normalizer uses SoftMax for normalization. The content-aware reconstruction module expands the features obtained by the kernel prediction module and multiplies them with the input features at the same position to finally obtain the output feature map. The feature map output by the content-aware module pays more attention to global features than the original feature map, and therefore has more semantic information;
[0064] S34. Based on Focal loss and MPDIoU, a FocalC-MPDIoU loss function is proposed to replace the loss function of the original model. The MPDIoU calculation formula is as follows:
[0065] L MDPIoU =1-MDPIoU
[0066]
[0067]
[0068]
[0069] Where a and b are the width and height of the input image, G and P are the real box and predicted box respectively. Let (x_1^G, y_1^G), (x_2^G, y_2^G), (x_1^P, y_1^P), and (x_2^P, y_2^P) be the coordinates of the upper left and lower right points of G and P respectively.
[0070] The calculation formula of FocalC-MPDIoU is as follows:
[0071] L FocalC-MPDIoU =IoU α*γ L MPDIoU
[0072]
[0073] Where γ is the parameter used to control the curvature of the curve, N is the number of samples, M is the number of categories, σ(x) is the Sigmoid transformation of the inputs one by one, and pred scoresij Represents the prediction score, and confidence represents the average confidence of all categories.
[0074] S4. Use the training set and validation set to train the network model, and input the test set into the trained model to obtain the sweet potato quality grading results.
[0075] S41. Test environment and methods
[0076] The model in this article runs under the Windows 10 operating system. The model framework adopts the Pytorch deep learning framework. The central processor model is the 12th Gen Intel Core i5-12400F, the graphics card is Nvidia GeForce RTX 3070, the video memory is 8GB, the computer running memory is 16GB, the Pycharm compiler version is 2022, the Python version is 3.9, the CUDA version is 11.7, and the Pytorch version is 2.0.1.
[0077] The training parameters include: input image size 640 × 640 pixels, batch size 4, optimizer using stochastic gradient descent (SGD), weight decay coefficient 0.0005, momentum factor 0.937, and initial learning rate 0.015;
[0078] S42. Evaluation indicators
[0079] To verify the performance of the improved algorithm in this study, precision (P), recall (R), mean average precision (mAP), parameters, floating point operations (FLOPs), and model weight size (memory size) are used as evaluation indicators. Precision represents the proportion of correctly predicted positive samples to all samples, recall represents the proportion of correctly predicted positive samples to all positive samples, and mean average precision represents the average value of the results obtained by integrating the PR curve for all categories;
[0080] S43. Network ablation test
[0081] This paper gradually adds the lightweight network EdgeNeXt, C2fC module, CARAFE lightweight operator and FocalC-MPDIoU loss function, and designs ablation tests based on YOLOv8s network and compares them one by one. The experimental results are shown in Table 4.
[0082] Table 4 Network ablation test results
[0083]
[0084] From the experimental results in Table 4, it can be seen that after replacing the backbone network with the EdgeNeXt lightweight network, the number of parameters and the amount of calculation of the model are greatly reduced, and the model weight is also significantly reduced. After replacing the C2f module of the neck network of the original model with C2fC, the number of parameters, the amount of calculation and the size of the model weight decreased by 12.6%, 10.6% and 13.3% respectively, while the mean value of the average accuracy remained almost unchanged. After introducing the CARAFE upsampling operator, the precision, recall rate and average accuracy of the model increased by 0.1%, 2.8% and 2.0% respectively, and the number of parameters and the amount of calculation of the model only increased slightly. Finally, the introduction of the FocalC-MPDIoU loss function also increased the average accuracy by 0.3 percentage points. According to the comparison between the first and eighth groups of experiments, the number of model parameters, the amount of calculation, and the size of the model weight after the improvement were reduced by 38.3%, 32.7%, and 37.8%, respectively, and the model accuracy and average precision were increased by 0.3 and 0.9 percentage points, respectively. The comparison results of the ablation test prove that the lightweight improvement effect of this paper is significant, which is of great help to the deployment of the model on low-computing embedded devices.
[0085] S44. Network ablation test
[0086] In order to objectively evaluate the advantages of the improved model, the improved model is compared with different target detection network models, including Faster RCNN, SSD, YOLOv3, YOLOv5s, YOLOv7-tiny and the original YOLOv8s model. The dataset used in this experiment is consistent with the ablation test. The quantitative results are shown in Table 5.
[0087] Table 5 Performance comparison results of different models
[0088]
[0089] From the test results in Table 5, we can see that the average accuracy of the improved model in this paper is 94.4, and the number of parameters, calculation amount and model weight are 6.85×10 6 , 19.1GFLOPs and 14MB. Compared with other models in the experiment, it not only has significant advantages in parameter quantity, computational complexity and weight size, but also has the highest average precision and the best detection effect on sweet potato. At the same time, the model was compared on two test set images, and the comparison results are as follows Figure 6 As shown. Figure 6 As shown in the figure, other models in this paper are prone to problems such as repeated detection, false detection, missed detection, low confidence and low positioning accuracy.
[0090] The improved model in this paper adds the CARAFE module and the Focal-MDPIoU loss function while optimizing the lightweight model. The introduction of the CARAFE module enhances the model's focus on global features, and the Focal-MDPIoU loss function adds a focus factor on low-confidence targets on the basis of Focal loss and MDPIoU, which can focus on high-quality anchor boxes and low-confidence targets at the same time. With the joint action of the two, it can better solve the problems of occlusion and repeated detection. Therefore, in terms of detection effect, the improved model in this paper has obvious advantages. In summary, the improved model can better meet the task of sweet potato quality grading, and the model complexity is relatively low, which is more conducive to deployment on embedded devices with limited computing resources.
[0091] The above embodiments are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope defined by the claims of the present invention.
Claims
1. A lightweight sweet potato quality grading method based on improved YOLOv8, characterized in that: The specific steps include: S1. The design of sweet potato grade standards divides sweet potatoes into several grades; S2, obtaining a sweet potato image dataset, performing data augmentation on the images and dividing them into a training set, a validation set, and a test set; S3. First, replace the backbone network in the original YOLOv8s model with the adjusted EdgeNeXt lightweight network, then use SCConv convolution to improve the C2f module to design the C2fC module, and then use the CARAFE lightweight operator to replace the upsampling module of the original model. Finally, based on Focal loss and MPDIoU, the FocalC-MPDIoU loss function is proposed to replace the loss function of the original model to obtain the improved network model. S4. Use the training set and validation set to train the network model, and input the test set into the trained model to obtain the sweet potato quality grading results.
2. A lightweight sweet potato quality grading method based on improved YOLOv8 according to claim 1, characterized in that: The sweet potato grades in step S1 include special grade, first grade and second grade, wherein the special grade sweet potato requires no rot spots, no insect damage, intact skin, no mechanical damage, and no sprouting; the first grade sweet potato requires no rot spots, no insect damage, relatively intact skin, and slight mechanical damage or sprouting is allowed; the second grade sweet potato requires rot spots, insect damage, incomplete skin, severe mechanical damage or sprouting.
3. A lightweight sweet potato quality grading method based on improved YOLOv8 according to claim 1, characterized in that: The step S2 uses random rotation, random translation, random flipping, random cropping, Gaussian noise, brightness change, and Cutout methods to expand and enhance the data set, and divides the data set into a training set, a validation set, and a test set in a ratio of 8:1:
1.
4. A lightweight sweet potato quality grading method based on improved YOLOv8 according to claim 1, characterized in that: The step S3 comprises: S31. When introducing the EdgeNeXt structure, the C2f module in the original YOLOv8 backbone network is retained, and the introduction of spatial position encoding in the original EdgeNeXt structure is cancelled; S32. Use SCConv convolution to improve the C2f module and design the C2fC module, where the SCConv module includes a spatial reconstruction unit (SRU) and a channel reconstruction unit (CRU). The SRU first performs feature separation, separating blank feature maps or feature maps with little information from feature maps containing a lot of important information, and then reconstructs features in the spatial dimension to compress redundant features and save space; CRU is divided into three steps: splitting, transformation, and fusion. CRU can reduce the redundant extraction of features in the channel dimension, complement SRU, and reduce the feature redundancy problem in the convolution process; S33, using the CARAFE lightweight operator to replace the upsampling module of the original model, CARAFE is composed of a kernel prediction module and a content-aware reorganization module, wherein the kernel prediction module is composed of a channel compressor, a content encoder and a kernel normalizer, and the content-aware reorganization module expands the features obtained by the kernel prediction module and multiplies them with the input features at the same position, and finally obtains an output feature map; S34. Based on Focal loss and MPDIoU, a FocalC-MPDIoU loss function is proposed to replace the loss function of the original model. The MPDIoU calculation formula is as follows: L MDPIoU =1-MDPIoU Where a and b are the width and height of the input image, G and P are the real frame and predicted frame respectively. Let (x_1^G, y_1^G), (x_2^G, y_2^G), (x_1^P, y_1^P), (x_2^P, y_2^P) be the coordinates of the upper left and lower right points of G and P respectively; The calculation formula of FocalC-MPDIoU is as follows: L FocalC-MPDIoU =IoU α*γ L MPDIoU Where γ is the parameter used to control the curvature of the curve, N is the number of samples, M is the number of categories, σ(x) is the Sigmoid transformation of the inputs one by one, and pred scoresij Represents the prediction score, and confidence represents the average confidence of all categories.
5. A lightweight sweet potato quality grading method based on improved YOLOv8 according to claim 1, characterized in that: In the step S4 training process, the batch size is 2-64, the optimizer uses the stochastic gradient descent method (SGD), the weight decay coefficient is 0.0001-0.005, the momentum factor is 0.9-0.95, the initial learning rate is 0.01-0.02, the training set and the validation set are used to train the network model, and the test set is input into the trained model to obtain the sweet potato quality grading result.
