An open API service indexing awesome lists of open source software.

https://github.com/gaiarighetti00/deep-learning-pasta-classification

Deep learning project for pasta image classification using CNNs, data augmentation, and regularization.
https://github.com/gaiarighetti00/deep-learning-pasta-classification

cnn computer-vision deep-learning food-ai image-classification keras tensorflow

Last synced: 3 months ago
JSON representation

Deep learning project for pasta image classification using CNNs, data augmentation, and regularization.

Awesome Lists containing this project

README

          

# 🍝 Guess the Pasta β€” Deep Learning with CNNs

![Python](https://img.shields.io/badge/Python-3.10+-blue?logo=python)
![TensorFlow](https://img.shields.io/badge/TensorFlow-2.x-orange?logo=tensorflow)
![Keras](https://img.shields.io/badge/Keras-DeepLearning-red?logo=keras)
![Jupyter](https://img.shields.io/badge/Notebook-Jupyter-orange?logo=jupyter)
![License: MIT](https://img.shields.io/badge/License-MIT-green)

> **Classifying pasta types with Convolutional Neural Networks (CNNs)**
> Master’s Degree in Data Science β€” University of Milano-Bicocca (A.Y. 2023/2024)

---

## πŸ“– Overview
This project applies **deep learning** to the (delicious) challenge of recognizing pasta varieties from images.
We start from a small, noisy dataset and iteratively improve the model with **data augmentation**, **regularization**, and **optimizer tuning** to boost generalization and stability.

---

## 🎯 Goals
- Build and train CNNs to classify pasta images.
- Group images into **short**, **long**, **filled**, **layered** pasta.
- Mitigate small-dataset issues using augmentation & L2 regularization.
- Compare optimizers (**RMSprop** vs **Adam**) and report findings.

---

## πŸ“‚ Repository Structure
- data/ # (see Data & Model section for download)
- models/pasta_model_M4.4.keras
- notebooks/pasta_classification_notebook.ipynb
- slides_pasta_classification.pdf
- README.md

---

## 🧭 Method & Models
1. **Dataset evolution**
- Start: 12 classes (~30 img/class) β†’ cleaned duplicates/errors.
- Reduced to 10 classes due to look-alike pairs (e.g., tagliatelle vs fettuccine).
- Final consolidation into **4 macro-classes**: short, long, filled, layered.

2. **Model iterations**
- **M1**: Baseline CNN + BatchNorm + Dropout, **RMSprop**.
- **M2**: + **Data Augmentation**.
- **M3**: + **L2 Regularization**.
- **M4**: Switch to **Adam** β†’ *final model saved as* `pasta_model_M4.4.keras`.

3. **Key observations**
- Validation accuracy rises with augmentation & regularization.
- **Long pasta** is hardest (shape changes; sauces/packaging can occlude pasta).
- Data quality & size are the main bottlenecks.

---

## Environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt

If requirements.txt is missing, install minimally:
pip install tensorflow keras numpy pandas matplotlib scikit-learn pillow jupyter

---

## Run
Open the notebook and follow the cells:
jupyter notebook notebooks/pasta_classification_notebook.ipynb

To load the pretrained model:
from tensorflow import keras
model = keras.models.load_model("models/pasta_model_M4.4.keras")

---

## πŸ“¦ Data & Model (large files)
GitHub’s web upload blocks files >100 MB. We provide large assets as Release attachments.
Download model: models/pasta_model_M4.4.keras
Download datasets (archives): data/raw/pasta_4.zip, pasta_10.zip, pasta_12.zip
How to set up:
Go to Releases β†’ Latest β†’ Assets and download the files.
Place them under the paths shown above (create folders if needed).

---

## πŸ“Š Results (high level)
Initial small dataset β†’ ~0.20 validation accuracy.
Augmentation + L2 reduced overfitting and improved stability.
Misclassifications often occurred on long pasta and occluded images (sauces, packaging).

---

## πŸš€ Future Work
Add more high-quality, standardized images per class.
Distinguish raw vs cooked pasta explicitly.
Try transfer learning (ResNet, EfficientNet, MobileNetV3).
Add Grad-CAM visualizations for interpretability.

---

## πŸ“‘ Documentation
Slides: docs/slides_pasta_classification.pdf

---

## βš–οΈ License
This repository is released under the MIT License.
Data are used for educational purposes; check original sources’ terms before redistribution

✨ From spaghetti to lasagne, let deep learning guess your pasta!