Pytorch Satellite image classification using neural networks.
INTRODUCTION
Dataset description: contains four classes of satellite images which are: water , desert , cloudy and green area, with 1500 images of each class. The test folder contains 40 images of each class.
link to dataset: https://www.kaggle.com/mahmoudreda55/satellite-image-classification
Goal : To develop a deep learning or neural network model that can predict or classify satellite images into the following classes : water , desert , cloudy and green area using pytorch. This model was also trained on a cpu enabled computer. This project also helps to easily get started with pytorch.
What is pytorch?
PyTorch is an open source machine learning library primarily used for Deep Learning applications, computer vision and natural language processing using GPUs and CPUs. It can be implemented in Python, mainly developed by the Facebook AI Research team. other Machine learning libraries similar to pytorch are TensorFlow and Keras. It makes use of tensors and can be implemented with numpy.
OUTLINE
1. Import Libraries
2. Load and transform data then define the data loader
3. Load a pre-trained dense net model
4. Plot some images
5. Test computers cpu speed
6. Define neural networks
7 Define the training steps
8. Plot the training step graph
9. save trained model
10.Use the trained model for predicting the satellite image classes
- Import libraries
2. Load and transform data then define the data loader
Provide a link to the locally stored images on your PC,Transform and resize the images before using pytorch dataloader to load in dataset.
3. Load a pre-trained dense net model
A DenseNet is a type of convolutional neural network that utilises dense connections between layers, through dense blocks, where we connect all layers (with matching feature-map sizes) directly with each other. To preserve the feed-forward nature, each layer obtains additional inputs from all preceding layers and passes on its own feature-maps to all subsequent layers. The densenet-121 model is one of the DenseNet group of models designed to perform image classification. The authors originally trained the models on Torch*, but then converted them into Caffe* format. All DenseNet models have been pre-trained on the ImageNet image database.
4 Plot some images
5. Test computers cpu speed
PYTORCH uses cuda library as gpu for training but my computer doesnt have a cuda enabled gpu.
6 Define neural networks
Using the pytorch.nn module define the neural network using relu activation functions, and softmax. Note there is no need through the densenet weights.
7 Define the training steps
define the epochs, and inputs to device, then backward propagate and apply optimizer
8. Plot the training step graph
9. save trained model
10.Use the trained model for predicting the satellite image classes
First load the trained model
functions to classify images in the test folder
CONCLUSION
This project explained the process of predicting a satellite image class with the pytorch library, It is a simple and straight forward process, however this process will run faster on a GPU enable computer rather than a CPU. So the choice is yours. This notebook was submitted as a solution on the kaggle image classification page. https://www.kaggle.com/mahmoudreda55/satellite-image-classification/code
WRITER: OLUYEDE SEGUN . A(jr)
Resources used (References) and further reading:
Link to explanatory notebook:
twitter profile: https://twitter.com/oluyedejun1
linkedin profile: https://www.linkedin.com/in/oluyede-segun-adedeji-jr-a5550b167/
TAGS: #pytorch #neuralnetwork #imageclassification #densenet #machinelearning #deeplearning # python