*3.1. Model Training Results*

According to the data set type, the loss function of the prediction model can be divided into training loss and validation loss, and the curve is shown in the Figure 10a. It can be observed from the figure that in the process of model training, when the number of iterations is between 0 and 150, the training loss and validation loss decrease rapidly, and when the number of iterations reaches more than 250, the loss value of the prediction model begins to stabilize gradually. In this paper, the training model with 300 iterations is selected as the final walnut kernel impurity detection model. In addition, it can be observed from the *mAP* curves of the training set and the validation set in the Figure 10b that the trained prediction model does not appear to be overfitting.

**Figure 10.** Training results of the improved YOLOv5 model. (**a**) Training and validation loss. (**b**) *mAP*\_0.5 of training and validation sets. *mAP*\_0.5: mean average precision when the threshold of IoU is 0.5.
