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.
- Host: GitHub
- URL: https://github.com/gaiarighetti00/deep-learning-pasta-classification
- Owner: GaiaRighetti00
- License: mit
- Created: 2025-09-23T10:19:21.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-23T12:02:03.000Z (9 months ago)
- Last Synced: 2025-09-23T13:35:58.969Z (9 months ago)
- Topics: cnn, computer-vision, deep-learning, food-ai, image-classification, keras, tensorflow
- Homepage:
- Size: 7.52 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π Guess the Pasta β Deep Learning with CNNs





> **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!