Code Monkey home page Code Monkey logo

hyperspectral's Introduction

This repository has been ⛔️ DEPRECATED. Please take a look at our fairly recent work:

Band-Adaptive Spectral-Spatial Feature Learning Neural Network for Hyperspectral Image Classification [paper] [Code]

Deep Learning for Land-cover Classification in Hyperspectral Images

Hyperspectral images are images captured in multiple bands of the electromagnetic spectrum. This project is focussed at the development of Deep Learned Artificial Neural Networks for robust 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 present in the location of the pixel. It is an image segmentation/scene labeling task. The following diagram describes the task.



This website describes our explorations with the performance of Multi-Layer Perceptrons and Convolutional Neural Networks at the task of Land-cover Classification in Hyperspectral Images. Currently we perform pixel-wise classification.


Dataset =======

We have performed our experiments on the Indian Pines Dataset. The following are the particulars of the dataset:

  • Source: AVIRIS sensor
  • Region: Indian Pines test site over north-western Indiana
  • Time of the year: June
  • Wavelength range: 0.4 – 2.5 micron
  • Number of spectral bands: 220
  • Size of image: 145x145 pixel
  • Number of land-cover classes: 16

Input data format =================

Each pixel is described by an NxN patch centered at the pixel. N denotes the size of spatial context used for making the inference about a given pixel.

The input data was divided into training set (75%) and a test set (25%).

Hardware used

The neural networks were trained on a machine with dual Intel Xeon E5-2630 v2 CPUs, 32 GB RAM and NVIDIA Tesla K-20C GPU.


Multi-Layer Perceptron

Multi-Layer Perceptron (MLP) is an artificial neural network with one or more hidden layers of neurons. MLP is capable of modelling highly non-linear functions between the input and output and forms the basis of Deep-learning Neural Network (DNN) models.

Architecture of Multi-Layer Perceptron used

input- [affine - relu] x 3 - affine - softmax

(Schematic representation below)

Ndenotes the size of the input patch.


Specifics of the learning algorithm

The following are the details of the learning algorithm used:

  • Parameter update algorithm used: Adagrad

    • Batch size: 200
    • Learning rate: 0.01
  • Number of steps: until best validation performance


Performance

Decoding generated for different input patch sizes:


Convolutional Neural Network

(CNN or ConvNet) are a special category of artificial neural networks designed for processing data with a gridlike structure. The ConvNet architecture is based on sparse interactions and parameter sharing and is highly effective for efficient learning of spatial invariances in images. There are four kinds of layers in a typical ConvNet architecture: convolutional (conv), pooling (pool), fullyconnected (affine) and rectifying linear unit (ReLU). Each convolutional layer transforms one set of feature maps into another set of feature maps by convolution with a set of filters.

Architecture of Convolutional Neural Network used

input- [conv - relu - maxpool] x 2 - [affine - relu] x 2 - affine - softmax

(Schematic representation below)

Ndenotes the size of the input patch.


Specifics of the learning algorithm

The following are the details of the learning algorithm used:

  • Parameter update algorithm used: Adagrad

    • Batch size: 100
    • Learning rate: 0.01
  • Number of steps: until best validation performance


Performance

Decoding generated for different input patch sizes:



Description of the repository

  • IndianPines_DataSet_Preparation_Without_Augmentation.ipynb - does the following operations:

    • Loads the Indian Pines dataset
    • Scales the input between [0,1]
    • Mean normalizes the channels
    • Makes training and test splits
    • Extracts patches of given size
    • Oversamples the training set for balancing the classes
  • Spatial_dataset.py - provides a highly flexible Dataset class for handling the Indian Pines data.

  • patch_size.py - specify the required patch-size here.

  • IndianPinesCNN.ipynb- builds the TensorFlow Convolutional Neural Network and defines the training and evaluation ops:

    • inference() - builds the model as far as is required for running the network forward to make predictions.
    • loss() - adds to the inference model the layers required to generate loss.
    • training() - adds to the loss model the Ops required to generate and apply gradients.
    • evaluation() - calcuates the classification accuracy
  • CNN_feed.ipynb - trains and evaluates the Neural Network using a feed dictionary

  • Decoder_Spatial_CNN.ipynb - generates the landcover classification of an input hyperspectral image for a given trained network

  • IndianPinesMLP.py - builds the TensorFlow Multi-layer Perceptron and defines the training and evaluation ops:

    • inference() - builds the model as far as is required for running the network forward to make predictions.
    • loss() - adds to the inference model the layers required to generate loss.
    • training() - adds to the loss model the Ops required to generate and apply gradients.
    • evaluation() - calcuates the classification accuracy
  • MLP_feed.ipynb - trains and evaluates the MLP using a feed dictionary

  • Decoder_Spatial_MLP.ipynb - generates the landcover classification of an input hyperspectral image for a given trained network

  • credibility.ipynb - summarizes the predictions of an ensemble and produces the land-cover classification and class-wise confusion matrix.


Setting up the experiment

  • Download the Indian Pines data-set from here.
  • Make a directory named Data within the current working directory and copy the downloaded .mat files Indian_pines.mat and Indian_pines_gt.mat in this directory.

In order to make sure all codes run smoothly, you should have the following directory subtree structure under your current working directory:

|-- IndianPines_DataSet_Preparation_Without_Augmentation.ipynb
|-- Decoder_Spatial_CNN.ipynb
|-- Decoder_Spatial_MLP.ipynb
|-- IndianPinesCNN.ipynb
|-- CNN_feed.ipynb
|-- MLP_feed.ipynb
|-- credibility.ipynb
|-- IndianPinesCNN.py
|-- IndianPinesMLP.py
|-- Spatial_dataset.py
|-- patch_size.py
|-- Data
|   |-- Indian_pines_gt.mat
|   |-- Indian_pines.mat


  • Set the required patch-size value (eg. 11, 21, etc) in patch_size.py and run the following notebooks in order:
    1. IndianPines_DataSet_Preparation_Without_Augmentation.ipynb
    2. CNN_feed.ipynb OR MLP_feed.ipynb (specify the number of fragments in the training and test data in the variables TRAIN_FILES and TEST_FILES)
    3. Decoder_Spatial_CNN.ipynb OR Decoder_Spatial_MLP.ipynb (set the required checkpoint to be used for decoding in the model_name variable)

Outputs will be displayed in the notebooks.


Acknowledgement

This repository was developed by Anirban Santara, Ankit Singh, Pranoot Hatwar and Kaustubh Mani under the supervision of Prof. Pabitra Mitra during June-July, 2016 at the Department of Computer Science and Engineering, Indian Institute of Technology Kharagpur, India. The project is funded by Satellite Applications Centre, Indian Space Research Organization (SAC-ISRO).

hyperspectral's People

Contributors

manila95 avatar santara avatar thisisashukla 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperspectral's Issues

Fail to run Decoder_Spatial_MLP.ipynb

when I run Decoder_Spatial_MLP.ipynb, errors arise like "NotFoundError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to find any matching files for model/model-MLP-1X1.ckpt-49999" . I am wondering how to solve it?

Published paper/ comments on results

Hi,
Thank you for sharing this code, *
I want to know if you published your results or not and whether it is possible to share the paper ,?
I run your code and I get the result of the Decoder_Spatial_CNN notebook but i couldn't understand, can you explain for me please ??
image

Thank you for your help
Best regards

Error in the 'Conv2D' op in IndianPinesCNN class

Hello, I just noticed a strange error while running the Decoder Spatial CNN notebook before getting into the code. I am running it with python3.5 and tensorflow 1.4. Just thought of bringing it to your notice. Specifically, the IndianPinesCNN.inference(), execution of line 70:

z = tf.nn.conv2d(x_image, weights, strides=[1, 1, 1, 1], padding='VALID')

raised the error:

InvalidArgumentError: Negative dimension size caused by subtracting 3 from 1 for 'conv_1/Conv2D' (op: 'Conv2D') with input shapes: [1,1,1,220], [3,3,220,500]

Here is the output when I run the decoder():


InvalidArgumentError Traceback (most recent call last)
/usr/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py in _call_cpp_shape_fn_impl(op, input_tensors_needed, input_tensors_as_shapes_needed, require_shape_fn)
653 graph_def_version, node_def_str, input_shapes, input_tensors,
--> 654 input_tensors_as_shapes, status)
655 except errors.InvalidArgumentError as err:

/usr/lib64/python3.5/contextlib.py in exit(self, type, value, traceback)
65 try:
---> 66 next(self.gen)
67 except StopIteration:

/usr/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py in raise_exception_on_not_ok_status()
465 compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466 pywrap_tensorflow.TF_GetCode(status))
467 finally:

InvalidArgumentError: Negative dimension size caused by subtracting 3 from 1 for 'conv_1/Conv2D' (op: 'Conv2D') with input shapes: [1,1,1,220], [3,3,220,500].

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in ()
----> 1 predicted_image,predicted_results = decoder()

in decoder()
11 conv2,
12 fc1,
---> 13 fc2)
14
15 eval_correct = IndianPinesCNN.evaluation(logits, labels_placeholder)

/home/Hyperspectral-master/IndianPinesCNN.py in inference(images, conv1_channels, conv2_channels, fc1_units, fc2_units)
68 # Flattening the 3D image into a 1D array
69 x_image = tf.reshape(images, [-1,IMAGE_SIZE,IMAGE_SIZE,CHANNELS])
---> 70 z = tf.nn.conv2d(x_image, weights, strides=[1, 1, 1, 1], padding='VALID')
71 print (z)
72 h_conv1 = tf.nn.relu(z+biases, name=scope.name)

/usr/lib/python3.5/site-packages/tensorflow/python/ops/gen_nn_ops.py in conv2d(input, filter, strides, padding, use_cudnn_on_gpu, data_format, name)
395 strides=strides, padding=padding,
396 use_cudnn_on_gpu=use_cudnn_on_gpu,
--> 397 data_format=data_format, name=name)
398 return result
399

/usr/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py in apply_op(self, op_type_name, name, **keywords)
765 op = g.create_op(op_type_name, inputs, output_types, name=scope,
766 input_types=input_types, attrs=attr_protos,
--> 767 op_def=op_def)
768 if output_structure:
769 outputs = op.outputs

/usr/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in create_op(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_shapes, compute_device)
2630 original_op=self._default_original_op, op_def=op_def)
2631 if compute_shapes:
-> 2632 set_shapes_for_outputs(ret)
2633 self._add_op(ret)
2634 self._record_op_seen_by_control_dependencies(ret)

/usr/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in set_shapes_for_outputs(op)
1909 shape_func = _call_cpp_shape_fn_and_require_op
1910
-> 1911 shapes = shape_func(op)
1912 if shapes is None:
1913 raise RuntimeError(

/usr/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in call_with_requiring(op)
1859
1860 def call_with_requiring(op):
-> 1861 return call_cpp_shape_fn(op, require_shape_fn=True)
1862
1863 _call_cpp_shape_fn_and_require_op = call_with_requiring

/usr/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py in call_cpp_shape_fn(op, require_shape_fn)
593 res = _call_cpp_shape_fn_impl(op, input_tensors_needed,
594 input_tensors_as_shapes_needed,
--> 595 require_shape_fn)
596 if not isinstance(res, dict):
597 # Handles the case where _call_cpp_shape_fn_impl calls unknown_shape(op).

/usr/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py in _call_cpp_shape_fn_impl(op, input_tensors_needed, input_tensors_as_shapes_needed, require_shape_fn)
657 missing_shape_fn = True
658 else:
--> 659 raise ValueError(err.message)
660
661 if missing_shape_fn:

ValueError: Negative dimension size caused by subtracting 3 from 1 for 'conv_1/Conv2D' (op: 'Conv2D') with input shapes: [1,1,1,220], [3,3,220,500].

UnrecognizedFlagError: Unknown command line flag 'f'

I am trying to implement Deep Learning for Land-cover Classification in Hyper spectral Images

In CNN_feed.ipynb file line number-9 run_training() function the following error encountered

UnrecognizedFlagError: Unknown command line flag 'f'

The replay will be helpful for my research

datasets

can you tell me where is the dataset? thank you very much!
def read_data_sets(directory,value, dtype=tf.float32): images = io.loadmat(directory)[value+'_patch'] labels = io.loadmat(directory)[value+'_labels'] data_sets = DataSet(images, labels, dtype=dtype) return data_sets

Need Help

Hello Dear,
So i am a phd student in MASCIR Foundation (Moroccan Foundation for Advanced Science, Innovation & Reserarch) , i work in project of hyperspectrale image classification with Deep Learnig , and search for a large Dataset of hyperspectral image and grounf thruth image , because one image of ground-thruth not enought to make a training in a Deep network ,
i look for your help to find one

Unable to complete ipynb notebook due to error

Hello, we have problem from column "Collect all available patches of each class from the given image". There is an error. We use the script that have converted to version python 3 in windows.
error1
We hope that you could give some input and information regarding this error.

add samples

rotating the original samples by 90°, 180°and 270° and flipping the data where the original samples are
flipped along the horizontal and vertical directions can increase the number of training data. But a question is that the label should remain unchanged or changed ?

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.