Learn practical skills, build real-world projects, and advance your career
!pip install jovian --upgrade --quiet
project_name = 'fruits360-gan' 

Narrative: Classifying Fruits' images using ResNets, Regularization and Data Augmentation in PyTorch


In This project we are going to classify image fruits to achieve over 90% accuracy with single GPU.

To achieve this we'll carry these steps:

  • Data normalization
  • Data augmentation
  • Residual connections
  • Batch normalization
  • Learning rate scheduling
  • Weight Decay
  • Gradient clipping
  • Adam optimizer

As the data is already cleaned for us, we will start by analysing and visualizing some data to know the type of fruits we are working with in our dataset then we start working on my model.

The dataset was acquired through Kaggle.

Link: Fruits 360

Dataset properties

Total number of images: 90483.

Training set size: 67692 images (one fruit or vegetable per image).

Test set size: 22688 images (one fruit or vegetable per image).

Multi-fruits set size: 103 images (more than one fruit (or fruit class) per image)

Number of classes: 131 (fruits and vegetables).

Image size: 100x100 pixels.

Import Libraries

import os
import torch
import torchvision
import torch.nn as nn
import numpy as np
from torchvision.transforms import ToTensor
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'