Image Analysis using pytorch
Prerequisites
This project is built using python in Ubuntu (WSL) and you’ll need to install the following:
- Any bash terminal (one of the following)
- Conda
- WSL
- Mac OS
- Any flavour of Linux
- Python 3 (I’m using 3.10.12)
- Pip
- Packages
Note: Since I’m using a computer with a CUDA compatable NVIDIA GPU, I’ll be using the GPU version of pytorch. If you don’t have a GPU, you can install the CPU version of pytorch given below.- CPU install
1
pip3 install torch torchvision numpy matplotlib
- GPU install
Installing numpy and matplotlibInstalling pytorch1
pip3 install numpy matplotlib
Check the pytorch website to see the which library is compatable with your system.
In my case I’m using CUDA 11.81
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
- CPU install
- Jupyter notebook (optional)Or just use Jupyter notebook from VS Code from here
1
pip3 install jupyterlab
Environement I’ve used
1 | CPU | Ryzen 7 5800H |
2 | GPU | RTX 3060 Laptop |
3 | RAM | 2x8GB DDR4 @ 3200MHz |
4 | OS | Windows 11/Ubuntu 22.4 WSL |
5 | CUDA | 11.8 |
6 | Python | 3.10.12 |
MNIST number dataset
The MNIST dataset is a dataset of handwritten digits. It has 60,000 training images and 10,000 test images. We’ll see a code to load the dataset and display the occurances of individual digits in the dataset. Or if you want to run the code from Jupyter notebook you can clone my repository via git.
RAW code
|
|
CPU version: ~ 3.1 mins
CUDA version: ~ 55 secs
MNIST fashion dataset
The MNIST fashion dataset is a dataset of fashion accessories. It has 60,000 training images and 10,000 test images. We’ll see a code to load the dataset and display the occurances of individual accessories in the dataset. Or if you want to run the code from Jupyter notebook you can clone my repository via git.
|
|
CPU version: ~ 35 secs
CUDA version: ~ 35 secs