| With the improvement of people’s living standards,the demand for fruits such as apples is rapidly escalating towards "high quality and high standard",which makes postharvest management and quality inspection particularly important.The quality inspection of apples,such as defects,color and size,has become an important indicator for grading and classification.The current methods for appearance quality inspection mainly include manual grading and mechanical grading,the traditional manual grading can not achieve standardized operation,low efficiency and high cost;Mechanical grading is only for size and weight,which has a single grading feature and can easily damage apples.This dissertation solves the two core problems of apple defect detection and fruit diameter grading based on machine vision and deep learning technology.The main research contents are as follows:(1)The basic principle of YOLOv5 network structure and model performance evaluation index are deeply analyzed and studied,and an apple defect detection method based on YOLOv5 is designed and implemented.The experimental results show that the algorithm can effectively improve the efficiency and accuracy of apple defect detection,but there are still problems of missed detection and false detection.(2)An improved apple defect detection algorithm(NAM-YOLO)based on normalized attention mechanism is designed to solve the problem of high false detection rate and missed detection rate due to the large variation of apple defect scales.The algorithm first introduces the Transformer encoder to connect the backbone network contextual feature information to improve the global perception of features by the backbone network;Secondly,the Bi FPN structure is applied to the neck network to improve the multiscale feature fusion performance of the neck network by assigning weights to the input features;Finally,the introduction of Normalization-based Attention Module(NAM)in the neck network enables the model to focus more on the important channels and improve the detection accuracy.The experimental results show that NAMYOLO has strong feature information extraction and multi-scale feature fusion ability,and can effectively identify bad fruits with defects.(3)The NAM-YOLO anchor frame method and the morphological threshold segmentation method are used to measure the apple fruit diameter to improve the measurement speed and accuracy.The NAM-YOLO anchor frame method firstly uses the detection anchor frame as the smallest external rectangle of the apple,then measures the pixel length of the apple fruit diameter by reading the anchor frame coordinates,and finally calculates the actual fruit diameter of the apple by measuring the pixel scale.The experimental results show that the NAM-YOLO anchor frame method has a fast measurement speed,but the measurement accuracy is easily disturbed by the accuracy of defective bad fruit detection.(4)To solve the problems that the existing YOLOv5 target detection algorithm has a single type of detection results,cannot reflect the overall appearance quality of apples and has low accuracy in detecting small-scale defects of apples,a multi-task apple feature detection algorithm(MTL-YOLO)based on improved YOLOv5 is proposed.The algorithm can accomplish the tasks of defect detection and fruit diameter measurement of apples at the same time.Firstly,on the basis of ensuring the performance of YOLOv5 apple defect detection,the apple measurable region detection head is added;secondly,the CBAM attention mechanism is introduced to enhance the model feature focus capability;finally,the ASFF module is used to improve the utilization of effective feature information and enhance the model’s ability to detect small-scale defects.The experimental results show that MTL-YOLO has accurate apple contour segmentation and defect detection,its segmentation and detection accuracy is much higher than other algorithms,and the comprehensive measurement performance is better than NAMYOLO anchor frame method and morphological threshold segmentation method. |