Skip to content

Repository files navigation

🍛 Nepali Food Classifier

An end-to-end computer vision project that classifies traditional Nepali dishes using transfer learning (ResNet18), compares augmentation strategies, and deploys predictions through Streamlit and FastAPI.


Challenges Faced

  • Small dataset size
  • Class imbalance
  • Overfitting in baseline model
  • Generalization issues

Solutions:

  • Strong augmentation
  • Transfer learning
  • Fine tuning

Streamlit App

Run the web app: View Project


FastAPI

POST /predict
pasted file

Project Overview

This project trains two separate models using the same architecture (ResNet18) but different data preprocessing strategies:

Model Description
Model 0 (Basic Augmentation) Minimal augmentation for baseline performance
Model 1 (Strong Augmentation) Advanced augmentation for better generalization

The goal is to analyze how augmentation impacts:

  • Accuracy
  • Overfitting
  • Generalization
  • Robustness

Project Structure

project/
│
├── dataset/
│   ├── train/
│   └── test/
│
├── src/
│   ├── dataset.py
│   ├── model.py
│   ├── engine.py
│   ├── predict.py
|   ├── train.py
│   └── streamlit_app
│    
├── models/
└── README.md

Dataset

Source: Kaggle Food Dataset (custom Nepali food subset) Data Source

Classes used:

  • momo
  • dal_bhat
  • sel_roti
  • chowmein
  • thukpa
  • chatamari
  • yomari

mage format: RGB
Input size: 224 x 224


Model

Base architecture:

ResNet18

Transfer learning used with frozen feature extractor and custom classifier head.


Data Augmentation Strategies

Model 0 — Basic Augmentation

Used for baseline training:

transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
])

Characteristics:

  • No heavy augmentation

  • Preserves original data distribution

  • Faster convergence

  • Higher risk of overfitting

    Model B — Strong Augmentation

Used for better generalization:

transforms.Compose([
    transforms.RandomResizedCrop(224),
    transforms.RandomHorizontalFlip(),
    transforms.RandomRotation(20),
    transforms.ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2),
    transforms.ToTensor(),
])

Characteristics: *More robust to real-world variation *Reduces overfitting *Slightly slower convergence *Better generalization


Training Details

Loss Function: CrossEntropyLoss Optimizer: Adam Learning Rate: 1e-3 (fine-tuning) Epochs: 15 Batch Size: 32


Training Results

Accuracy Plot

alt text

Loss Plot

alt text


Confusion Matrix

Model 0

alt text

Model 1

alt text


Inference Pipeline

Steps:

  1. Load image
  2. Resize to 224x224
  3. Normalize
  4. Forward pass through ResNet18
  5. Apply Softmax
  6. Get prediction (Argmax)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages