Learn practical skills, build real-world projects, and advance your career
# import all necessary libaries
import os
import torch
import torchvision
import tarfile
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
from torchvision.datasets.utils import download_url
from torchvision.datasets import ImageFolder
from torch.utils.data import DataLoader
import torchvision.transforms as tt
from torch.utils.data import random_split
from torchvision.utils import make_grid
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

matplotlib.rcParams['figure.facecolor'] = '#ffffff'
# name of the project
project_name='project-food-classification-resnet'

This machine learning project is a classification problem which can classify between 6 differnt types of common Nigerian dishes namely: pounded_yam, moimoi, akara_balls, amala_and_ewedu, fried_rice and jollof_rice. I actually aim to help tourists and foreigners navigate the country's dishes easily. The images are google images with 35 samples of each food.

5 of each class will be used for validation and the remaining for training.

# the dataset is in a google drive, so I have to mount it to google colab
from google.colab import drive
drive.mount('/content/drive')
Mounted at /content/drive
# data directory
data_dir = './drive/MyDrive/food'

# printing the content of directory and class names which are the names of the folders
print(os.listdir(data_dir))
classes = os.listdir(data_dir + '/train')
print(classes)
['train', 'test'] ['pounded_yam', 'moimoi', 'akara_balls', 'amala_and_ewedu', 'fried_rice', 'jollof_rice']