Food Recognition
A comparative food classification system benchmarking traditional ML (SVM, Random Forest) against deep learning (Custom CNN, ResNet-50) on the Food2k dataset with 2,000 categories and ~1M images, featuring an interactive Streamlit web app for real-time inference and model comparison.
Explore the project
The stack.
Python
PyTorch
torchvision
scikit-learn
OpenCV
Streamlit
NumPy
Pandas
Matplotlib
Seaborn
CUDA
TensorBoard
Inside the project.
This project implements and compares four distinct approaches to large-scale food image classification on the Food2k dataset (2,000 food categories, ~1M images):
Traditional ML: SVM and Random Forest classifiers trained on both CNN-extracted features (2048-d from ResNet-50) and handcrafted features (HOG, Color Histograms, LBP, Gabor Filters).
Deep Learning: A custom 5-block CNN (~4M parameters) built from scratch, and a ResNet-50 model fine-tuned via two-stage transfer learning (frozen backbone → full fine-tuning).
Key highlights include class-weighted loss for handling data imbalance, mixed-precision GPU training, feature caching for efficiency, and comprehensive evaluation with Top-1/Top-5 accuracy, F1 scores, and inference time benchmarks. The SVM with CNN features achieved 90.47% Top-1 accuracy, while the Custom CNN reached 96.73% on a 20-class subset.
The project also features an interactive Streamlit web application where users can upload food images and get real-time predictions from all models simultaneously, with side-by-side confidence comparisons, model agreement detection, and live activation visualizations using PyTorch forward hooks.




