This project implements a Convolutional Neural Network (CNN) for multi-class classification of food images across 91 distinct categories. The dataset is split into training (~44k samples) and testing (~22k samples) subsets and undergoes preprocessing. A custom model is then built using TensorFlow, trained on the dataset, and evaluated for accuracy. The main challenge involved tuning hyperparameters—such as learning rate and dropout—and shaping an effective CNN architecture, with fixed random seeds used to ensure reproducibility. Finally, a simulation is performed in which a hypothetical user submits 10 random food images to be classified by the trained model.
The purpose of this project is to demonstrate the application of deep learning for image classification in a real-world-like setting such as food recommendation systems.
It is designed for the NC2425 Neural Computing course at Leiden University and runs on LIACS remote servers.
- Classifies images across 91 food categories. Classifies food images into 91 distinct categories.
- Builds and trains a Convolutional Neural Network (CNN) from scratch, without relying on pretrained models.
- Simulates real-life usage by testing with random food images.
- Tracks training progress using accuracy and loss per epoch.
- Integrates visualization of the model development process for interpretation and debugging. -Designed for deployment on LIACS remote servers via SSH, integrated with each student’s /data directory.
This project must be run on LIACS remote servers and is intended only for Leiden University students who have:
-
Valid Leiden University account
-
SSH access to ssh.liacs.nl and internal servers (e.g., vibranium)
-
Working WSL terminal
-
Basic knowledge of SSH, Git, and Python venv
-
Required Python packages from requirements.txt
Setup Instructions (via LIACS SSH)
- Open WSL terminal.
- SSH into the LIACS login server:
ssh s[student_number]@ssh.liacs.nl(Enter your Brightspace/ULCN password when prompted)
(During the first time, write 'yes' when asked to connect with a fingerprint.)
- SSH into the Internal Server
ssh vibranium(Enter your Brightspace/ULCN password when prompted)
(During the first time, write 'yes' when asked to connect with a fingerprint.)
- Start a screen session:
During the setup
screen -S cnn_trainingDuring the next sessions to restore the screen During the setup
screen -r cnn_training[TIP - use whenever in screen you want to reset the content in the screen]
clear- Navigate to your home directory
cd /home/s[student_number]/- Check if the /data/s[student_number] directory exists
cd /data/s[student_number]If it does not exist, create it:
mkdir /data/s[student_number]
cd /data/s[student_number]- Clone the repository:
git clone https://github.com/gabz81y/assignment_NC2425.git
cd assignment_NC2425- Sync with Latest Changes:
git pull origin main --rebase- Set Up a Python Virtual Environment
python -m venv nc_venv
source nc_venv/bin/activate- Install Dependencies
pip install -r requirements.txt- Download and Prepare the Dataset
python get_data.pyVerify that train and test directories have been created:
ls- Convert Notebook to Script
jupyter nbconvert --to script assignment_NC2425.ipynb- Run the CNN Training Script
jupyter nbconvert --to script assignment_NC2425.ipynb- Detach from the screen session (only during the setup session)
Ctrl + A, then DThis CNN-based food classifier supports real-world applications such as:
-
Restaurant Recommendation Systems – Recommend dishes based on identified food types.
-
Diet Tracking Apps – Automatically log and categorize meals from photos.
-
Kitchen Assistants – Detect food in real time from images.
GROUP_10: NC_PA_2425 10 - NC_PA_2425_311543_39802_10
- Czapska Gabriela s4053672
- Doupovcová Livia s3952320
- Hanganu Ioana s3792773
- Snepvangers Alex s3700216
This project is licensed under the MIT License. See the LICENSE file for details.