Giter Site home page Giter Site logo

ajigeo / temporal-sar-transformer Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 58 KB

Crop classification in the Cauvery Delta Zone using a multichannel based transformer model

Python 100.00%
remote-sensing crop-classification sentinel-2 sentinel-1 tamilnadu deep-learning optical sar

temporal-sar-transformer's Introduction

Transformer based temporal SAR and multispectral data fusion for crop classification

Requirements

python=3.9.7
tensorflow=2.5.0
keras=2.4.3
sklearn=0.24.2
imblearn=0.8.0
numpy=1.21.2
pandas=1.3.3
matplotlib=3.4.3
seaborn=0.11.2
gdal=3.3.2

Installation

Run the code below to clone the repository to your local machine and change it to your working directory.

git clone https://github.com/ajigeo/convlstm-classification.git
cd convlstm-classification

All the libraries required for executing this code is shared as a yaml file. It can be installed by running the command,

conda env create -f environment.yml

Usage

Run the first 5 cells of training.py, to import the libraries, read the training data, preprocess it, building the DL model and fit the model.

Building the model

To call the model and train the data,

from models import fusion_transformer

model_history = my_fused_model.fit(
	x=[X_train_vv, X_train_vh, X_train_mss], y=y_train,
	validation_data=([X_val_vv, X_val_vh, X_val_mss], y_val),
	epochs=EPOCHS,batch_size=BATCH_SIZE,
    callbacks=[model_checkpoint])

Plotting the model performance

To plot the training accuracy and loss,

from utils import plot_performance

plot_performance(model_history, 'Title of the performance plot')

Model Evaluation Metrics

The Overall Accuracy, Kappa and class-wise F1 scores can be calculted by running the following code.

from utils import model_metrics

accuracy, kappa, f1_scores = model_metrics(predictions,y_test)

The confusion matrix for the classifier can be constructed by running,

from utils import confusion_matrix

confusion_matrix(class_labels, y_test, predictions, 'Title of the Confusion Matrix')

Reading the Image file

To read the image file, run the following code.

from raster import read_image

image_data = read_image('X:/location/of/the/image.tif')

Plotting the final thematic map

After reshaping and classifying the pixels in the image, the final thematic map can be plotted, assigned projections and extent by,

from raster import plot_output

plot_output(reshaped_classifed_matrix,transformations,'X:/location/of/classifed_map.tif')

temporal-sar-transformer's People

Contributors

ajigeo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

smyucas

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.