Giter Site home page Giter Site logo

konstantinosf / classification-of-hyperspectral-image Goto Github PK

View Code? Open in Web Editor NEW
184.0 12.0 74.0 7.96 MB

Classification of the Hyperspectral Image Indian Pines with Convolutional Neural Network

License: MIT License

Jupyter Notebook 100.00%
remote-sensing deeplearning hyperspectral-image-classification land-cover keras

classification-of-hyperspectral-image's Introduction

Classification-of-Hyperspectral-Image

Classification of the Hyperspectral Image Indian Pines with Convolutional Neural Network

Hyperspectral images are images captured in hundrends of bands of the electromagnetic spectrum. This project is focused at the development of Deep Neural Network for landcover classification in hyperspectral images. Land-cover classification is the task of assigning to every pixel, a class label that represents the type of land-cover.

Most of the existing studies and research efforts are following the conventional pattern recognition paradigm, which is based on the construction of complex handcrafted features. However, it is rarely known which features are important for the problem at hand. In contrast to these approaches, a deep learning based classification method that hierarchically constructs high-level features in an automated way, is proposed. In this project, exploitation of a Convolutional Neural Network, is taking part, to encode pixels’ spectral and spatial information and a Multi-Layer Perceptron to conduct the classification task.

This project is based on the paper "DEEP SUPERVISED LEARNING FOR HYPERSPECTRAL DATA CLASSIFICATION THROUGH CONVOLUTIONAL NEURAL NETWORKS" by Makantasis et al.

Just to clarify, my code has nothing to do with the previously mentioned paper. I refer to it, because I followed the same resoning to build my code.

Description of the repository

  1. Open the global_variables.txt file and write the wanted windowsize, the number of the PCA components and the test train split.

  2. Run the notebook "CreatetheDatasets", in order to create the Xtrain, Xtest, ytrain, ytest matrices. Matrices are saved in a numpy format.

  3. Run the notebook "TrainTheModel", in order to train the model. The model is being saved including the weights.

  4. Run the "Validation+ClassificationMaps", for validating the model and creating the clasification map.

Figures

Patch Size Overall Accuracy
5x5 83%
7x7 88%
9x9 94%
11x11 95%

CNN_Architecture

classification-of-hyperspectral-image's People

Contributors

konstantinosf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

classification-of-hyperspectral-image's Issues

Build the classification maps

Hi, thanks a lot for such a helpful repository. I see the code does not classify the marginal pixels when building the classification maps. Would you fix it later?

Classification-of-Hyperspectral-Image

In TrainTheModel file
Line number [5]

Reshape into (numberofsumples, channels, height, width)

X_train = np.reshape(X_train, (X_train.shape[0],X_train.shape[3], X_train.shape[1], X_train.shape[2]))


IndexError Traceback (most recent call last)
in ()
1 # Reshape into (numberofsumples, channels, height, width)
----> 2 X_train = np.reshape(X_train, (X_train.shape[0],X_train.shape[3], X_train.shape[1], X_train.shape[2]))

IndexError: tuple index out of range

FileNotFoundError

How can I solve it? Thank you very much.

FileNotFoundError: [Errno 2] No such file or directory: '/home/deeplearning/Desktop/GITHUB/XtrainWindowSize5PCA30testRatio0.25.npy'

Input size of image

In the training of the CNN, the input is of size (5,5,30) instead of (30,5,5) and as a result the model handles the input as an image of size 30x5 with 5 channels instead of a 5x5 image with 30 channels.

unnecessary code

function: CreatetheDataSets.AugmentData

patch2 = flipped_patch
X_train[i,:,:,:] = patch2

These two lines of code are unnecessary as flipped_patch and X_train all point to the same object.

A question

Thanks for the work, I have tried the code, but it can not reach a high accuracy result as posted in the original paper.
image
The following are my results:
image
Train on 29685 samples, validate on 2563 samples
Epoch 1/15
29685/29685 [==============================] - 8s 258us/step - loss: 2.5315 - acc: 0.2048 - val_loss: 2.4267 - val_acc: 0.3531
Epoch 2/15
29685/29685 [==============================] - 7s 239us/step - loss: 1.9284 - acc: 0.4615 - val_loss: 1.8825 - val_acc: 0.5099
Epoch 3/15
29685/29685 [==============================] - 7s 240us/step - loss: 1.4118 - acc: 0.5917 - val_loss: 1.3746 - val_acc: 0.6278
Epoch 4/15
29685/29685 [==============================] - 7s 239us/step - loss: 1.0785 - acc: 0.6655 - val_loss: 1.1172 - val_acc: 0.6859
Epoch 5/15
29685/29685 [==============================] - 7s 240us/step - loss: 0.8887 - acc: 0.7122 - val_loss: 0.9545 - val_acc: 0.7323
Epoch 6/15
29685/29685 [==============================] - 7s 240us/step - loss: 0.7718 - acc: 0.7483 - val_loss: 0.8611 - val_acc: 0.7554
Epoch 7/15
29685/29685 [==============================] - 7s 240us/step - loss: 0.6798 - acc: 0.7747 - val_loss: 0.7822 - val_acc: 0.7706
Epoch 8/15
29685/29685 [==============================] - 7s 241us/step - loss: 0.6123 - acc: 0.7953 - val_loss: 0.7271 - val_acc: 0.7799
Epoch 9/15
29685/29685 [==============================] - 7s 240us/step - loss: 0.5648 - acc: 0.8120 - val_loss: 0.6752 - val_acc: 0.7936
Epoch 10/15
29685/29685 [==============================] - 7s 240us/step - loss: 0.5189 - acc: 0.8262 - val_loss: 0.6337 - val_acc: 0.8053
Epoch 11/15
29685/29685 [==============================] - 7s 241us/step - loss: 0.4804 - acc: 0.8420 - val_loss: 0.5988 - val_acc: 0.8092
Epoch 12/15
29685/29685 [==============================] - 7s 240us/step - loss: 0.4488 - acc: 0.8496 - val_loss: 0.5717 - val_acc: 0.8174
Epoch 13/15
29685/29685 [==============================] - 7s 242us/step - loss: 0.4181 - acc: 0.8618 - val_loss: 0.5408 - val_acc: 0.8205
Epoch 14/15
29685/29685 [==============================] - 7s 243us/step - loss: 0.3959 - acc: 0.8701 - val_loss: 0.5088 - val_acc: 0.8283
Epoch 15/15
29685/29685 [==============================] - 7s 241us/step - loss: 0.3730 - acc: 0.8765 - val_loss: 0.5010 - val_acc: 0.8221
Can you tell me what is the reason? Thanks in advance.

PCA

  1. in [16] X,pca = applyPCA(X,numPCAcomponents) numPCAcomponents is 30 but applyPCA function takes numComponents=75
    Please give difference between numPCAcomponents and numComponents
    Also how standartizeData function is used in the project

"NameError: name 'numComponents' is not defined",

hello,
I tried the code, the frist two-CreatetheDatasets and TrainTheModel all run successfully, but when I run the last code-validation, the sentence "file_name = 'report'+"WindowSize" + str(windowSize) + "PCA" + str(numComponents) + "testRatio" + str(testRatio) +".txt"" represent the question, said "NameError: name 'numComponents' is not defined",
This mean it can't find the corresponding file and data, which means I didn't save some training results?
I don't know how to slove, can you help me?
thanks a lot

Regarding the corrections

Firstly, thanks for this amazing code. It is very nice and I learned a lot from this. However, I saw your datasets are corrected. Can you please tell me how did you do the corrections and please give me the link of the code you are using? TIA

Issue with reshaping the patches for prediction

Hello, @KonstantinosF, thank you for sharing. I was trying the code and was getting an error when doing the final prediction. It seems image_patch=Patch(X,i,j) gives out a none type object.
X_test_image = image_patch.reshape(1,image_patch.shape[2],image_patch.shape[0],image_patch.shape[1]).astype('float32')

AttributeError: 'NoneType' object has no attribute 'reshape'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.