Skip to content

FreshCheck AI is a deep learning–based Streamlit application that classifies fruit images as fresh or spoiled using a pretrained ResNet-50 model. It demonstrates an end-to-end transfer learning pipeline, from data preparation and validation to real-time inference.

Notifications You must be signed in to change notification settings

inv-fourier-transform/FreshCheck_AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

FreshHarvest Fruit Classifier

FreshCheck AI – Fresh vs Spoiled Fruit Classifier

A deep learning–powered application to classify fruits as fresh or spoiled.

Streamlit PyTorch TorchVision Scikit-Learn Optuna

Model: ResNet-50 (Transfer Learning)   |   Framework: PyTorch   |   UI: Streamlit

This project demonstrates an end-to-end computer vision workflow — from data preparation and leakage-safe splitting to model training, evaluation, and deployment using Streamlit.


A practical deep learning project that classifies fruit images as fresh or spoiled using a pretrained ResNet-50 model.
The project emphasizes data integrity, correct evaluation, and production-ready deployment, rather than just high accuracy.


📸 Screenshots

🖥️ Streamlit Application Interface

Home Screen

✅ Fresh vs Spoiled Result

Result Screen Result Screen


✨ Features

  • Binary Classification: Predicts whether a fruit is fresh or spoiled
  • Multi-Fruit Support: Trained on 8 different fruits
  • Transfer Learning: Uses pretrained ResNet-50 for efficient learning
  • Leakage-Safe Dataset Splitting: Fruit-aware and class-aware splits
  • Minimal Hyperparameter Tuning: Lightweight Optuna demonstration
  • Fast Inference: Backbone frozen for quick predictions
  • Interactive UI: User-friendly Streamlit web app

📂 Project Structure

Fruits_Freshness_Classifier/
│
├── README.md          
├── .gitignore
└──streamlit_app/
    │
    ├── artifacts/
    ├── harvest_classifier_notebook.ipynb
    └── harvest_classifier_resnet50.ipynb
    │
    ├── models/
       └── fruits_classifier_resnet50_tl.pth
    ├── app.py
    ├── app_v2.py # ✅ Main Streamlit application (use this)
    ├── model_definition.py # Model architecture definition
    ├── model_helper.py # Model loading & inference utilities
    ├── requirements.txt


🧠 Model Details

  • Architecture: ResNet-50 (pretrained on ImageNet)
  • Training Strategy:
    • Transfer learning
    • Backbone frozen
    • Fully connected layer fine-tuned
  • Classes:
    • 0 → Fresh
    • 1 → Spoiled
  • Input Size: 224 × 224 RGB
  • Loss Function: CrossEntropyLoss
  • Optimizer: Adam / AdamW (with weight decay)

🖥️ Setup Instructions

Prerequisites

  • Python 3.9+
  • Git

1️⃣ Clone the Repository

git clone https://github.com/inv-fourier-transform/Fruits_Freshness_Classifier.git
cd Fruits_Freshness_Classifier

2️⃣ Create & Activate Virtual Environment

python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate

3️⃣ Install Dependencies

pip install -r requirements.txt

🚀 Running the Application

streamlit run app_v2.py

📸 How to Use the App

  1. Upload a fruit image
  2. The model processes the image
  3. View the output, which includes:
    • Prediction: Fresh / Spoiled
    • Confidence Score

🔬 Training & Experiments

All experimentation and training logic is documented in the notebooks inside the artifacts/ directory.

Includes:

  • From-scratch CNN experiments
  • BatchNorm & Dropout analysis
  • Data leakage diagnosis
  • Transfer learning with ResNet-50
  • Minimal Optuna-based tuning (demo only)

📦 Model Reuse

The trained model can be loaded independently:

import torch

model = torch.load("models/fruits_classifier_resnet50_tl.pth")

Refer to model_helper.py for reusable inference utilities.


🔐 Key Design Principles

  • Correct evaluation > inflated accuracy
  • Data leakage prevention
  • Minimal but meaningful regularization
  • Clear separation of training and inference
  • Production-ready deployment mindset

🤝 Contributing

Contributions are welcome!
Please open an issue or submit a pull request for improvements or bug fixes.


📄 License

This project is licensed under the MIT License.


Built with a focus on correctness, clarity, and real-world deployment.

About

FreshCheck AI is a deep learning–based Streamlit application that classifies fruit images as fresh or spoiled using a pretrained ResNet-50 model. It demonstrates an end-to-end transfer learning pipeline, from data preparation and validation to real-time inference.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published