Skip to content

Mrudula1205/CoffeeBeanRoastClassification

Repository files navigation

☕ Coffee Roast Quality AI

Deep Learning-powered Coffee Bean Roast Classification — Validate roast consistency against production standards in real time.

Python 3.10+ TensorFlow Streamlit Docker License: MIT


🚀 Features

  • Multi-Architecture Benchmarking: Trained and evaluated InceptionV3, ResNet-152 V2, and VGG-16 on identical splits
  • 95% Accuracy: InceptionV3 achieves state-of-the-art performance on the 4-class roast dataset
  • Real-Time QC Validation: Upload a batch photo and instantly verify it against a target roast profile
  • Modular ML Pipeline: Clean src/ package separating ingestion, preprocessing, model engine, and inference
  • Dockerized: Single docker build + docker run for fully reproducible deployments
  • Streamlit UI: Intuitive interface for quality control operators — no ML knowledge required

📊 Model Results

Model Accuracy Precision Recall F1 Score
InceptionV3 0.95 0.97 0.97 0.97
ResNet-152 V2 0.96 0.96 0.96 0.96
VGG-16 0.91 0.92 0.91 0.91

🗂️ Dataset


🧠 How It Works

┌──────────────┐    ┌─────────────────┐    ┌──────────────────┐    ┌──────────────┐
│  Upload Image│ -> │  Preprocessing  │ -> │  InceptionV3     │ -> │  QC Result   │
│  (JPG/PNG)   │    │  Resize 224×224 │    │  + Custom Head   │    │  PASS / FAIL │
└──────────────┘    └─────────────────┘    └──────────────────┘    └──────────────┘

Architecture

Each model uses the same custom head on top of ImageNet-pretrained base:

BaseModel (frozen) → GlobalAveragePooling2D → Dense(1024, ReLU) → Dropout(0.5) → Dense(4, Sigmoid)

Trained with Adam optimizer, Categorical Cross-Entropy loss, for 25 epochs with data augmentation (rotation, flip, zoom, shear).


🖥️ Demo

Upload Batch Photo Quality Verdict
Select target roast from sidebar System predicts roast type and compares
PASS — batch matches the target profile FAIL — roast mismatch with corrective guidance

Live demo: coffeeroastclassification.streamlit.app


📦 Quick Start

Option 1: Docker (Recommended)

git clone https://github.com/<your-username>/CoffeeBeanRoastClassification.git
cd CoffeeBeanRoastClassification

docker build -t coffee-roast-ai .
docker run -p 7860:7860 coffee-roast-ai

Open http://localhost:7860

Option 2: Local Python

git clone https://github.com/<your-username>/CoffeeBeanRoastClassification.git
cd CoffeeBeanRoastClassification

pip install -r requirements.txt
pip install -e .

streamlit run app.py

🗃️ Project Structure

├── app.py                  # Streamlit UI entry point
├── main.py                 # Training pipeline entry point
├── params.yaml             # All hyperparameters & config
├── Dockerfile              # Container definition
├── requirements.txt        # Python dependencies
├── setup.py                # Installable src package
├── config/
│   └── config.yaml
├── models/
│   └── inception_v1.hdf5   # Best trained model
├── src/
│   └── coffee_roast_ai/
│       ├── data_ingest.py      # Kaggle dataset download
│       ├── data_loader.py      # Augmented data generators
│       ├── preprocessing.py    # Inference image processing
│       ├── model_engine.py     # Build / train / load models
│       ├── utils.py            # Config reader
│       └── logger.py           # Logging setup
└── research/
    ├── CoffeebeansClassification-Inception.ipynb
    └── CoffeebeansClassification-Resnet.ipynb

⚙️ Configuration

All tunable parameters live in params.yaml — no code changes needed:

data:
  image_size: [224, 224]
  batch_size: 64
  class_names: ['Dark', 'Green', 'Light', 'Medium']

model:
  base_model: "InceptionV3"
  learning_rate: 0.001
  dropout_rate: 0.5
  dense_units: 1024
  epochs: 25

🔧 Development

# Install in editable mode
pip install -e .

# Run training pipeline
python main.py

# Run app locally
streamlit run app.py

# Rebuild Docker image
docker build -t coffee-roast-ai .

🙏 Acknowledgments


Made with ❤️ and a lot of ☕

Releases

No releases published

Packages

 
 
 

Contributors

Languages