AgriVision is an automated computer vision system designed for the agricultural industry and food supply chains. By leveraging Deep Transfer Learning, this system classifies 10 different types of fruits with high precision, enabling automated quality control and reducing manual sorting errors in food processing lines.
In modern food supply chains, automated quality control is essential to reduce waste and ensure safety. This project focuses on building a scalable, high-accuracy Computer Vision pipeline using the MobileNetV2 architecture to identify fruit varieties under varying conditions.
- 10-Class Classification: Apple, Avocado, Banana, Cherry, Kiwi, Mango, Orange, Pineapple, Strawberries, and Watermelon.
- Transfer Learning: Utilizes pre-trained ImageNet weights for efficient feature extraction.
- Two-Stage Training: Includes both Feature Extraction (frozen base) and Fine-Tuning (unfrozen top layers).
- Robust Evaluation: Features Confusion Matrix analysis, Classification Reports, and Error Analysis.
The dataset was sourced from Roboflow.
-
Structure: Standardized
train/,test/, andvalid/directories. -
Preprocessing: Images resized to
$224 \times 224$ , normalized, and augmented with random rotations, shifts, and flips to prevent overfitting.
- Language: Python
- Framework: TensorFlow / Keras
- Libraries: NumPy, Pandas, Matplotlib, Seaborn, Scikit-learn
- Platform: Google Colab / Jupyter Notebooks
- EDA: Visualized class distributions and sample images for each category.
- Augmentation: Implemented
ImageDataGeneratorfor real-time training augmentation (rotation, zoom, horizontal flip).
- Architecture: MobileNetV2 (chosen for its efficiency on mobile/edge devices).
- Custom Head: Added Global Average Pooling, a Dense layer (128 units, ReLU), and Dropout (0.3).
- Training: Compiled with Adam optimizer and Categorical Crossentropy loss.
- Unfroze the top 20 layers of the base model.
- Re-trained with a very low learning rate (
$1e-5$ ) to refine weights for specific fruit textures without destroying pre-trained features.
| Metric | Score |
|---|---|
| Precision (Weighted Avg) | 0.87 |
| Recall (Weighted Avg) | 0.86 |
| F1-Score (Weighted Avg) | 0.86 |
The model performed exceptionally well on unique textures (Avocados, Strawberries) but occasionally confused fruits with similar color profiles (Mango vs. Orange) or shared spherical geometry (Apple vs. Cherry).
You can use the predict_fruit function to classify local images:
class_name, confidence = predict_fruit('path/to/fruit_image.jpg') print(f"Predicted: {class_name} with {confidence*100:.2f}% confidence")
AgriVision demonstrates that Transfer Learning is a powerful tool for niche agricultural tasks. The use of MobileNetV2 ensures that the model is not only accurate but also light enough for deployment in real-world sorting facilities.

