Skip to content

Kayleeli/fruit_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fruit Detection

Overview

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.

Setup

Option 1: Google Colab

  1. Open main_submission.ipynb in Google Colab
  2. Set RUN_ON_COLAB = True
  3. Enable GPU (Runtime > Change runtime type > GPU)
  4. Run all cells

Note: Google Drive access is required to save outputs.

Option 2: Local Environment

pip install -r requirements.txt # install dependencies
jupyter notebook main_submission.ipynb 

Dataset

  • Source: Fruits-360 Dataset
  • Classes: 255 (fruits, vegetables, nuts, seeds)
  • Download method: Automatic via kagglehub

Model

  • Architecture: CNN with Conv, BatchNorm, ReLU, and Pooling layers
  • Input size: 64 × 64
  • Optimizer: Adam (learning_rate = 0.001)
  • Loss function: SparseCategoricalCrossentropy

Results

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).

Analysis

  • 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.

Repo Structure

fruit_detection/
├── main_submission.ipynb
├── requirements.txt
├── README.md
└── fruit_model/

Notes

  • 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

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors