Abstract:[[Objective ]] To realize rapid and accurate measurement of both internal and external quality of tomatoes,and improve the efficiency and quality of tomato grading.[[Methods ]] Based on machine vision and spectroscopy technology,proposed a tomato comprehensive quality grading method which combined external and internal quality.By optimizing the YOLOv 8 model in four aspects (lightweight convolution,small object detection layer,CBAM attention mechanism,and loss function ),external defect detection was completed,and external quality grading was achieved by combining fruit shape index and tomato size.Complete tomato internal quality grading through preprocessing methods,feature extraction methods,and improved particle swarm optimization using least squares support vector machine.Analyzed the performance of the proposed grading detection method through experiments.[[Results ]] The proposed method could achieve comprehensive quality testing of tomatoes with high accuracy and efficiency.The accuracy of external quality grading >93.00%,the accuracy of internal quality grading >86.00%,the accuracy of fusion quality grading >96.00%,and the average grading time <0.25 s.[[Conclusion ]] Combining machine vision and spectral detection technology can achieve rapid,non -destructive,and accurate evaluation of tomato comprehensive quality.