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
Launch your terminal using Windows Subsystem for Linux (WSL).
- Connect to the LIACS Login Server
SSH into the LIACS login node using your student credentials:
ssh s[student_number]@ssh.liacs.nlOn your first attempt, you'll be prompted to confirm the server’s authenticity. Type "yes" when asked to save the host key.
Enter your Brightspace/ULCN password when prompted.
- SSH into the Internal Server (VIbranium)
Once connected to the login node, SSH into the internal server:
ssh vibraniumIf you receive a warning about a changed host key (potential MITM attack), clear the old key and reconnect:
ssh-keygen -R vibranium
ssh vibranium Accept the host key again if prompted and enter your password.
- (Optional) Start a screen Session
Using screen allows your training jobs to continue running even if your SSH session disconnects.
To start a session for the first time:
screen -S cnn_trainingTo reconnect to a session later:
screen -r cnn_trainingTo clear the terminal content inside a screen session:
clear- Navigate to Your Home Directory
cd /home/s[student_number]/- Navigate to or Create the /data Directory
First time only:
mkdir /data/s[student_number]/
cd /data/s[student_number]Subsequent use:
cd /data/s[student_number]/- Clone or Access the assignment_NC2425 Repository
During setup:
git clone https://github.com/gabz81y/assignment_NC2425.git
cd assignment_NC2425Later:
cd assignment_NC2425- Sync with the Latest Changes:
During setup:
git pull origin main --rebaseLater:
git pull - Access the Python Virtual Environment
During setup:
python -m venv nc_venv
source nc_venv/bin/activate Later:
source nc_venv/bin/activate - Install Dependencies (only during setup)
pip install -r requirements.txt- Download and Prepare the Dataset (setup only)
python get_data.pyOnce complete, verify the dataset was extracted properly:
lsYou should see both "train" and "test" directories in the current folder.
- Convert the Notebook to a Python Script (setup only)
Convert the Jupyter notebook to a .py script using:
jupyter nbconvert --to script assignment_NC2425.ipynbThis will generate assignment_NC2425.py in the same directory.
- Run the CNN Training Script
To start model training, run:
python assignment_NC2425.py- Detach from the Screen Session (if using screen)
If you're running inside a screen session and want to safely detach:
Ctrl + A, then DThis will keep the training running in the background, allowing you to reconnect later.
This 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.