This repository contains a project for fruit recognition using the Fruits-360 dataset. The project applies computer vision techniques, image segmentation, color histogram extraction, and machine learning classifiers to classify fruits into different categories.
- Data Preprocessing: Extracts color histograms from fruit images, segmenting fruits from the background using color thresholds and enhancing segmented images.
- Segmentation: Isolates fruits based on predefined color ranges using the HSV color space. A mask is applied to separate the fruit from the background.
- Image Enhancement: Improves segmented images via brightness/contrast adjustments, histogram equalization, denoising, and sharpening.
- Feature Extraction: Color histograms in the HSV color space represent the distribution of color components (Hue, Saturation, Value) for each image.
- Machine Learning Models: Includes SVM, KNN, and Random Forest classifiers for fruit recognition based on extracted features.
- Model Evaluation: Assesses models using accuracy, precision, recall, F1-score, and confusion matrices.
The Random Forest model outperformed SVM and KNN, achieving an accuracy of approximately 95% on the test set.
The trained machine learning model is deployed in a Flask-based web application for real-time fruit recognition. Users can upload fruit images and receive predictions instantly.
- Real-Time Prediction: Upload an image, and the model predicts the fruit type in real time.
- User-Friendly Interface: Built with HTML, Bootstrap, and Tailwind CSS for a responsive and intuitive design.
- Image Preview: Displays an image preview after upload, prior to prediction.
- Cross-Origin Requests (CORS): Secure communication between frontend and backend.
- Error Handling: Smooth user experience with error management for missing files or failed predictions.
- Image Upload: Users upload a fruit image via the form on the webpage.
- Image Preprocessing: The uploaded image is resized and preprocessed to extract color histograms.
- Prediction: The preprocessed image is passed to the Random Forest model to classify the fruit.
- Results Display: The predicted fruit category is displayed to the user in real time.
- Backend: Flask for serving the machine learning model and managing HTTP requests.
- Frontend: HTML, Bootstrap, and Tailwind CSS for the user interface.
- Machine Learning: Random Forest model trained on color histogram features of fruit images.
- Python: Used for model development, image preprocessing, and backend functionality.
- Google Colab: For training and evaluating machine learning models in an experimental and optimized environment.
Developed by @nouran246 (Nouran Hassan).
Contributions are welcome! Feel free to open an issue or submit a pull request to improve the project.
This project is licensed under the MIT License.