PyTorch is a Python package that provides Tensor computations. Tensors are multidimensional arrays just like NumPy ndarrays which run on GPU also.
PyTorch makes use of dynamic computation graphs instead of predefined graphs with specific functionalities. PyTorch provides us a framework to build and even change the computational graphs during runtime. This is useful when we do not know how much memory we will require for creating a neural network.
PyTorch expects the data to be organized by folders with one folder for each class. This can be done using the Sklearn library.
Image classification is an important application of Computer Vision. Its applications involve the area of driverless cars, the health sector, navigation, manufacturing industry, etc.
In this article, we will see a stepwise procedure to classify map tile images from Google based on the land features they contain. For the same, we will use the dataset consisting of map tiles from Google Maps.
Stepwise procedure to achieve image classification using Pytorch:
1. IMPORTING THE PACKAGES
2. DEFINING THE VALIDATION DATASET LOADER USING SubsetRandomSampler
3. LOADING A PRETRAINED MODEL
4. ADJUSTING PARAMETERS
1. Freeze the pre-trained layers to avoid backprop during training.
2. Redefining the final fully-connected layer that we will train with our images.
3. Creating a loss function, choosing and optimizer, and the learning rate.
5. TRAINING THE MODEL