This project builds a CNN to classify 255 classes of fruits, vegetables, nuts, and seeds from the Fruits-360 dataset. It includes analysis such as a confusion matrix, t-SNE visualization, and Grad-CAM to understand how the model makes predictions.
- Open main_submission.ipynb in Google Colab
- Set
RUN_ON_COLAB = True - Enable GPU (Runtime > Change runtime type > GPU)
- Run all cells
Note: Google Drive access is required to save outputs.
pip install -r requirements.txt # install dependencies
jupyter notebook main_submission.ipynb - Source: Fruits-360 Dataset
- Classes: 255 (fruits, vegetables, nuts, seeds)
- Download method: Automatic via kagglehub
- Architecture: CNN with Conv, BatchNorm, ReLU, and Pooling layers
- Input size: 64 × 64
- Optimizer: Adam (learning_rate = 0.001)
- Loss function: SparseCategoricalCrossentropy
| Metric | Value |
|---|---|
| Test accuracy | 96.66% |
| Precision | 96.85% |
| Recall | 96.66% |
| F1-score | 96.59% |
The model shows lower performance on similar classes (e.g., different blackberry variants).
- Confusion Matrix: Errors occur between similar classes.
- t-SNE Visualization: Classes form distinct clusters in feature space.
- Grad-CAM: Model attention aligns with fruit regions in images.
fruit_detection/
├── main_submission.ipynb
├── requirements.txt
├── README.md
└── fruit_model/
- GPU is recommended for training
- Image size is 64×64 due to memory constraints
- steps_per_epoch = 2000 (partial data per epoch)
- Dataset caching is not used due to memory constraints
MIT License