**4. Conclusions**

In this paper, a grading method of defective apples was proposed and applied to the separate fruit tray sorting machine. The BiSeNet V2 network and pruned YOLO V4 network were combined to extract the defect regions in apple images. The BiSeNet V2 network was utilized to determine the latent location of defect regions. The pruned YOLO V4 network was used to remove the non-defective region. A projection algorithm was proposed to build the corresponding relationship between the defect area in the image and the actual defect area on the apple's surface. After the two deep learning models were deployed using C++ language, the average accuracy and the F1 score of defective apple grading in the online test were 92.42% and 94.31%, respectively.

The overall results denoted that the proposed method has potential to be implemented in commercial fruit-grading machines. Meanwhile, the proposed method has the potential for being extended to other fruit. Because separate fruit tray grading equipment in the market can only capture the upper surface of the fruit, we are developing a flexible air suction device to assist the camera with capturing the full surface image of the fruit. Future work will focus on improving the segmentation accuracy of defects and the projection accuracy of the defect area for improving the accuracy of grading defective apples.

**Author Contributions:** Conceptualization, X.L. and C.Z. (Chi Zhang); methodology, X.L.; software, C.Z. (Chi Zhang); validation, X.J., L.L. and X.L.; formal analysis, X.L.; investigation, C.Z. (Chi Zhang) and X.H.; resources, W.H.; data curation, X.J.; writing—original draft preparation, X.L.; writing review and editing, C.Z. (Chi Zhang), S.F. and C.Z. (Chunjiang Zhao); visualization, C.Z. (Chi Zhang); supervision, J.L.; project administration, C.Z. (Chi Zhang.); funding acquisition, S.F. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the National Natural Science Foundation of China (NSFC no. 31871523) and the Young Elite Scientists Sponsorship Program by CAST (2019QNRC001).

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** The data presented in this study are available on request from the corresponding author. The data are not publicly available since future studies are related to current data.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**

