Learn practical skills, build real-world projects, and advance your career

Classifying Intel Natural Scenes Images using PyTorch

nature scene

This project is the result of the knowledge acquired during the course Deep Learning with PyTorch: Zero to GANs offered by Jovian.ai.

For this project, was chosen the open Intel Image Classification Dataset which contains images of nature scenes sperated in 6 categories. The main goal of the project is to define, train and test a neural network model for classifying images.

System Setup

Let's begin by installing and importing the required libraries.

# Uncomment and run the appropriate command for your operating system, if required

# Linux / Binder / Windows (No GPU)
# !pip install numpy matplotlib torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

# Linux / Windows (GPU)
# pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
 
# MacOS (NO GPU)
# !pip install numpy matplotlib torch torchvision torchaudio

!pip install opendatasets --upgrade
Requirement already up-to-date: opendatasets in /usr/local/lib/python3.6/dist-packages (0.1.10) Requirement already satisfied, skipping upgrade: tqdm in /usr/local/lib/python3.6/dist-packages (from opendatasets) (4.41.1) Requirement already satisfied, skipping upgrade: kaggle in /usr/local/lib/python3.6/dist-packages (from opendatasets) (1.5.10) Requirement already satisfied, skipping upgrade: click in /usr/local/lib/python3.6/dist-packages (from opendatasets) (7.1.2) Requirement already satisfied, skipping upgrade: requests in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2.23.0) Requirement already satisfied, skipping upgrade: urllib3 in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (1.24.3) Requirement already satisfied, skipping upgrade: certifi in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2020.12.5) Requirement already satisfied, skipping upgrade: python-slugify in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (4.0.1) Requirement already satisfied, skipping upgrade: python-dateutil in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2.8.1) Requirement already satisfied, skipping upgrade: six>=1.10 in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (1.15.0) Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle->opendatasets) (3.0.4) Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle->opendatasets) (2.10) Requirement already satisfied, skipping upgrade: text-unidecode>=1.3 in /usr/local/lib/python3.6/dist-packages (from python-slugify->kaggle->opendatasets) (1.3)
import os
import opendatasets as od
import numpy as np

import torch
import torchvision
from torch.utils.data import random_split
from torch.utils.data.dataloader import DataLoader
import torch.nn as nn
import torch.nn.functional as F
from torchvision.datasets.utils import download_url
from torchvision.datasets import ImageFolder
from torchvision.transforms import ToTensor
from torchvision.utils import make_grid

import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

matplotlib.rcParams['figure.facecolor'] = '#ffffff'
project_name='zerotogans-project-intel-image-classification'