Abstract: With the intelligent development of modern agriculture, traditional manual tomato ripeness detection methods suffer from low efficiency, strong subjectivity, and high labor costs. To improve the accuracy and efficiency of tomato ripeness detection, this paper designs and implements an intelligent tomato ripeness detection system based on deep learning.
Project Introduction
The system adopts the YOLOv8 object detection algorithm as its core recognition engine. By training on a large number of tomato image datasets, it realizes automatic classification and recognition of four ripeness levels: unripe, semi-ripe, ripe, and overripe. In terms of system architecture, a front-end and back-end separation development model is adopted. The back end uses Django REST Framework to build RESTful API interfaces, while the front end uses the Vue3 framework combined with the Element Plus component library to develop a responsive Web interface, providing a user-friendly interactive experience. The system integrates functional modules such as user management, image upload and detection, history record query, and data visualization analysis, and supports multi-role permission management.
The experimental results show that the system achieves a precision of 81.05%, a recall of 70.64%, an mAP@0.5 of 76.84%, and an F1 Score of 75.49% on the test dataset. The detection time for a single image is approximately 1–3 seconds, meeting the requirements of practical application scenarios. The system not only improves the automation level of tomato ripeness detection, but also provides a technical reference and practical case for intelligent agriculture.
System Architecture
The system adopts a front-end and back-end separation architecture based on Django REST Framework + Vue3. Through RESTful APIs, it enables coordinated operation among front-end interaction, back-end business processing, YOLOv8 model inference, and detection result management.
Figure 1 System Architecture Diagram
Technical Innovations
Innovation 1: YOLOv8 Model Optimization and Adaptation to Agricultural Scenarios
- The YOLOv8 network structure is optimized according to the ripeness characteristics of tomatoes.
- Data augmentation and transfer learning are used to improve detection accuracy in small-sample scenarios.
- End-to-end automatic recognition of ripeness grading is achieved, covering four categories: unripe, semi-ripe, ripe, and overripe.
Innovation 2: Front-End and Back-End Separated Real-Time Detection Architecture
- Django REST Framework is used to build asynchronous detection interfaces, supporting high-concurrency requests.
- A responsive Web interface based on Vue3 is developed to support drag-and-drop image upload, real-time preview, and result visualization.
- The detection results include confidence scores and bounding box coordinates, providing complete traceability.
Innovation 3: Multi-Dimensional Data Analysis and Visualization
- ECharts is integrated to implement multi-dimensional statistical visualization, such as ripeness distribution pie charts and detection trend line charts.
- A complete detection history record system is constructed, supporting multi-condition filtering by category, time, and confidence score.
- Model training curves, including Precision, Recall, mAP, and F1 Score, as well as performance indicators, are displayed to assist in model evaluation.
Dataset and Training
Dataset Construction
This study uses a tomato ripeness detection dataset from the Roboflow Universe platform under the CC BY 4.0 license. The dataset contains 1,420 high-quality images and 11,158 annotated bounding boxes. It is divided into a training set, validation set, and test set according to a 7:2:1 ratio, including 993 training images, 284 validation images, and 143 test images.
The dataset adopts the standard YOLO annotation format and establishes a four-level fine-grained classification system: unripe, turning, semi-ripe, and ripe. This classification system covers the complete ripening process of tomatoes from green to red. Each image contains an average of 7.9 objects, realistically reflecting dense multi-object scenarios in agricultural production.
In terms of class distribution, the semi-ripe category accounts for the highest proportion at 49.6%, followed by the ripe category at 25.5%. The unripe category accounts for 16.5%, while the turning category accounts for 8.5%. This class distribution is consistent with the natural growth pattern of tomatoes and provides a solid foundation for training a high-precision ripeness detection model.
Figure 2 dataset distribution scaled
Training Results
In this study, the YOLOv8 model was trained on the tomato ripeness detection dataset for 150 epochs and achieved excellent detection performance on the validation set. During the training process, the bounding box loss (box_loss) gradually decreased from the initial value of 1.09 to 0.57, while the classification loss (cls_loss) decreased from 2.73 to 0.34, indicating that the model converged well.
The final model achieved a precision of 81.05% and a recall of 70.65% on the validation set. The mAP50 reached 76.84%, and the mAP50-95 reached 61.15%, demonstrating the model’s ability to accurately recognize the four ripeness categories.
The training process generated complete visualization results, including the P-R curve, F1 curve, and confusion matrix. The total training time was approximately 2,794 seconds, or about 46 minutes. The best weight file was saved in the weights directory and can be directly used for practical detection applications.
The model performs stably in dense multi-object scenarios and can effectively distinguish four categories: unripe, turning, semi-ripe, and ripe. This provides reliable technical support for intelligent tomato harvesting and grading.
Figure 3 results
Figure 4 BoxPR_curve
Figure 5 confusion_matrix-scaled
Quick Start
Quick Start: After installing the dependencies, start the back end with python manage.py runserver and the front end with npm run dev. Then log in to http://localhost:5173 using the default account admin/admin123.
Environment Requirements
The system requires a Python 3.8+ environment. The core dependencies include Python 3.8+, Node.js 16+, and a MySQL database, with GPU acceleration optional.
Running Demo
Project Resources
Supporting Documents
Click to view:Intelligent Tomato Ripeness Detection System Based on YOLOv8 Deep Learning
Note: Additional purchase is required.
Supporting Files
The supporting files include the complete project source code, demonstration video, running screenshots, and other related resources. The project is ready to use out of the box.
Project Information
Author Information
Author: Bob (Zhang Jialiang)
Project ID: AI-2-EN
Originality Statement: This project is an original work.Contact Information
Email: wesharecode2023@gmail.com
GitHub:https://github.com/7zcode
YouTube:https://www.youtube.com/@7zcodeOpen Source License
This project is licensed under the AGPL-3.0 License. You may use, modify, and distribute the code, but derivative works must also remain open source under the same license. If the project is used to provide network services, the complete source code must be made available to users.
This project is for learning and research purposes only. Users are responsible for complying with local laws and regulations. If this project is helpful, citation and attribution are appreciated.
声明:本站所有项目资源都可以正常运行,亲测无错!而且我们录制了演示视频,在我们注明的环境版本下,项目运行效果完全和演示视频一致。客服QQ:下载须知







评论(0)