To propose and implement a multi-class classification approach to disaster assessment from the given data set of post-earthquake satellite imagery.

Overview

Vision_Beyond_Limits_211672

Table Of Content

Problem Statement

To propose and implement a multi-class classification approach to disaster assessment from the given data set of post-earthquake satellite imagery. We are provided with post earthquake satellite imagery along with the GeoJSON file containing the extent of damage of each building. Our task is to take the images, detect and localise the buildings and then classify them based on the damage inflicted upon them.

Relevance

We need a satellite image classifier to inform about the disaster in order for the rescue teams to decide where to head first based on the damage assessed by our model and arrive at the more damaged localities and save as many lives as possible.


Methodology

UNET

  • U-net is an encoder-decoder deep learning model which is known to be used in medical images. It is first used in biomedical image segmentation. U-net contained three main blocks, down-sampling, up-sampling, and concatenation.
  • The important difference between U-net and other segmentation net is that U-net uses a totally different feature fusion method: concatenation. It concatenates the feature channel together to get a feature group. It could decrease the loss of features during convolution layers.
  • The U-Net architecture contains two paths: contraction path (also called as the encoder, The encoder part is used to capture the context in the image using convolutional layer) and expanding path (also called as the decoder, The decoder part is used to enable precise localization using transposed convolutions).
  • The main idea behind the U-Net is that during the training phase the first half which is the contracting path is responsible for producing the relevant information by minimising a cost function related to the operation desired and at the second half which is the expanding path the network it would be able to construct the output image.

RESNET50

  • ResNet stands for ‘Residual Network’. ResNet-50 is a convolutional neural network that is 50 layers deep.
  • Deep residual nets make use of residual blocks to improve the accuracy of the models. The concept of “skip connections,” which lies at the core of the residual blocks, is the strength of this type of neural network.

File Structure

 ┣ classification model
 ┃ ┣ damage_classification.py
 ┃ ┣ damage_inference.py
 ┃ ┣ model.py
 ┃ ┣ process_data.py
 ┃ ┗ process_data_inference.py
 ┣ spacenet
 ┃ ┣ inference
 ┃ ┃ ┗ inference.py
 ┃ ┗ src
 ┃ ┃ ┣ features
 ┃ ┃ ┃ ┣ build_labels.py
 ┃ ┃ ┃ ┣ compute_mean.py
 ┃ ┃ ┃ ┗ split_dataset.py
 ┃ ┃ ┗ models
 ┃ ┃ ┃ ┣ dataset.py
 ┃ ┃ ┃ ┣ evaluate_model.py
 ┃ ┃ ┃ ┣ segmentation.py
 ┃ ┃ ┃ ┣ segmentation_cpu.py
 ┃ ┃ ┃ ┣ tboard_logger.py
 ┃ ┃ ┃ ┣ tboard_logger_cpu.py
 ┃ ┃ ┃ ┣ train_model.py
 ┃ ┃ ┃ ┣ transforms.py
 ┃ ┃ ┃ ┗ unet.py
 ┣ utils
 ┃ ┣ combine_jsons.py
 ┃ ┣ data_finalize.sh
 ┃ ┣ inference.sh
 ┃ ┣ inference_image_output.py
 ┃ ┣ mask_polygons.py
 ┃ ┗ png_to_geotiff.py
 ┣ weights
 ┃ ┗ mean.npy
 ┣ Readme.md
 ┗ requirements.txt

Installation and Usage

  • Clone this git repo
git clone https://github.com/kwadhwa539/Vision_Beyond_Limits_211672.git

Environment Setup

  • During development we used Google colab.
  • Our minimum Python version is 3.6+, you can get it from here.
  • Once in your own virtual environment you can install the packages required to train and run the baseline model.
  • Before installing all dependencies run pip install numpy tensorflow for CPU-based machines or pip install numpy tensorflow-gpu && conda install cupy for GPU-based (CUDA) machines, as they are install-time dependencies for some other packages.
  • Finally, use the provided requirements.txt file for the remainder of the Python dependencies like so, pip install -r requirements.txt (make sure you are in the same environment as before)

Implementation

Localization Training

The flow of the model is as follows:-

  • Expansion Part:-

    1. Applying Convolution to the Input Image, starting with 32 features, kernel size 3x3 and stride 1 in first convolution.
    2. Applying BatchNormalization on convoluted layers and feeding the output to the next Convolution layer.
    3. Again applying another convolution to this normalised layer, but keeping kernel size 4x4 and stride 2.

    These 3 steps are repeated till we reach 1024 features, in the bottleneck layer.

  • Contraction Part:-

    1. Upsample(de-convolute) the preceding layer to halve the depth.
    2. Concatenating with the corresponding expansion layer.
    3. Applying Batch Normalization.

    In the last step, we convolute with a kernel size of 1x1, giving the output label of depth 1.

(loss function used in training:- softmax_crossentropy)

Below we will walk through the steps we have used for the localization training. First, we must create masks for the localization, and have the data in specific folders for the model to find and train itself. The steps we have built are described below:

  1. Run mask_polygons.py to generate a mask file for the chipped images.
  • Sample call: python mask_polygons.py --input /path/to/xBD --single-file --border 2
  • Here border refers to shrinking polygons by X number of pixels. This is to help the model separate buildings when there are a lot of "overlapping" or closely placed polygons.
  • Run python mask_polygons.py --help for the full description of the options.
  1. Run data_finalize.sh to setup the image and labels directory hierarchy that the spacenet model expects (it will also run compute_mean.py script to create a mean image that our model uses during training.
  • Sample call: data_finalize.sh -i /path/to/xBD/ -x /path/to/xView2/repo/root/dir/ -s .75
  • -s is a crude train/val split, the decimal you give will be the amount of the total data to assign to training, the rest to validation.
  • You can find this later in /path/to/xBD/spacenet_gt/dataSplit in text files, and easily change them after we have run the script.
  • Run data_finalize.sh for the full description of the options.
  1. After these steps have been run you will be ready for the instance segmentation training.
  • The original images and labels are preserved in the ./xBD/org/$DISASTER/ directories, and just copies the images to the spacenet_gt directory.

The main file is train_model.py and the options are below

A sample call we used is below(You must be in the ./spacenet/src/models/ directory to run the model):

$ python train_model.py /path/to/xBD/spacenet_gt/dataSet/ /path/to/xBD/spacenet_gt/images/ /path/to/xBD/spacenet_gt/labels/ -e 100

WARNING: If you have just ran the (or your own) localization model, be sure to clean up any localization specific directories (e.g. ./spacenet) before running the classification pipeline. This will interfere with the damage classification training calls as they only expect the original data to exist in directories separated by disaster name. You can use the split_into_disasters.py program if you have a directory of ./images and ./labels that need to be separated into disasters.

  1. You will need to run the process_data.py python script to extract the polygon images used for training, testing, and holdout from the original satellite images and the polygon labels produced by SpaceNet. This will generate a csv file with polygon UUID and damage type as well as extracting the actual polygons from the original satellite images. If the val_split_pct is defined, then you will get two csv files, one for test and one for train.

Damage Classification Training

  • In the final step we will be doing damage classification training on the provided training dataset. For this we have used ResNet-50 in integration with a typical U-Net.
  1. In order to optimise the model and increase the pixel accuracy, we first pre-process the given data by extracting the labelled polygon images, i.e. each unique building, using the polygon coordinates provided in the true label. This will give us 1000s of cropped images of the buildings.
  2. Then, by referring to the damage type, the model will train using UNet/ResNet architecture, which is as follows:-
    1. Applying 2D convolutions to the input image of (128,128,3) and max pooling the generated array. We do this for 3 layers.
    2. Then using the ResNet approach we concatenate the corresponding expansion array, and apply a Relu-Dense layer over it, starting with 2024 features to eventually give an array of original dimensions but with 4 features/classes(based on the damage type).
  • sample call:-
$ python damage_classification.py --train_data /path/to/XBD/$process_data_output_dir/train --train_csv train.csv --test_data /path/to/XBD/$process_data_output_dir/test --test_csv test.csv --model_out path/to/xBD/output-model --model_in /path/to/saved-model

Results

Sr. Metric Score
1. ACCURACY 0.81
1a. PIXEL ACCURACY 0.76
1b. MEAN CLASS ACCURACY 0.80
2. IOU 0.71
2a. MEAN IOU 0.56
3. PRECISION 0.51
4. RECALL 0.75

(On left, Ground truth image. On right, Predicted image.)

(epoch v/s accuracy)

(epoch v/s loss)


CONCLUSION

  • The above model achieves quite good accuracy in terms of localization of buildings from satellite imagery as well as classifying the damage suffered post disaster. It is very efficient in terms of time required to train the model and size of input dataset provided.
  • The optimum loss and best accuracy for localization training was achieved on 30 epochs. The various methods used such as data augmentation and different loss functions helped us to avoid overfitting the data.
  • Hence, this model will help to assess the post disaster damage, using the satellite imagery.
  • This challenge gave us a lot of insight on the satellite image, multi-classification problem. It made us realise the crucial need to utilise the advantages of deep learning to solve practical global issues such as post disaster damage assessment and much more.

Future Work

  • look for a better and efficient model
  • solve version-related issues in the code

Contributors

Acknowledgement

Resources

Back To The Top

Owner
Kunal Wadhwa
2nd Year Student at VJTI, Matunga Philomath : )
Kunal Wadhwa
MDETR: Modulated Detection for End-to-End Multi-Modal Understanding

MDETR: Modulated Detection for End-to-End Multi-Modal Understanding Website • Colab • Paper This repository contains code and links to pre-trained mod

Aishwarya Kamath 770 Dec 28, 2022
Using pretrained language models for biomedical knowledge graph completion.

LMs for biomedical KG completion This repository contains code to run the experiments described in: Scientific Language Models for Biomedical Knowledg

Rahul Nadkarni 41 Nov 30, 2022
Semantic similarity computation with different state-of-the-art metrics

Semantic similarity computation with different state-of-the-art metrics Description • Installation • Usage • License Description TaxoSS is a semantic

6 Jun 22, 2022
Continuous Query Decomposition for Complex Query Answering in Incomplete Knowledge Graphs

Continuous Query Decomposition This repository contains the official implementation for our ICLR 2021 (Oral) paper, Complex Query Answering with Neura

UCL Natural Language Processing 71 Dec 29, 2022
Code for the TIP 2021 Paper "Salient Object Detection with Purificatory Mechanism and Structural Similarity Loss"

PurNet Project for the TIP 2021 Paper "Salient Object Detection with Purificatory Mechanism and Structural Similarity Loss" Abstract Image-based salie

Jinming Su 4 Aug 25, 2022
OCR Post Correction for Endangered Language Texts

📌 Coming soon: an update to the software including features from our paper on semi-supervised OCR post-correction, to be published in the Transaction

Shruti Rijhwani 96 Dec 31, 2022
Justmagic - Use a function as a method with this mystic script, like in Nim

justmagic Use a function as a method with this mystic script, like in Nim. Just

witer33 8 Oct 08, 2022
Pgn2tex - Scripts to convert pgn files to latex document. Useful to build books or pdf from pgn studies

Pgn2Latex (WIP) A simple script to make pdf from pgn files and studies. It's sti

12 Jul 23, 2022
공공장소에서 눈만 돌리면 CCTV가 보인다는 말이 과언이 아닐 정도로 CCTV가 우리 생활에 깊숙이 자리 잡았습니다.

ObsCare_Main 소개 공공장소에서 눈만 돌리면 CCTV가 보인다는 말이 과언이 아닐 정도로 CCTV가 우리 생활에 깊숙이 자리 잡았습니다. CCTV의 대수가 급격히 늘어나면서 관리와 효율성 문제와 더불어, 곳곳에 설치된 CCTV를 개별 관제하는 것으로는 응급 상

5 Jul 07, 2022
Visualizer using audio and semantic analysis to explore BigGAN (Brock et al., 2018) latent space.

BigGAN Audio Visualizer Description This visualizer explores BigGAN (Brock et al., 2018) latent space by using pitch/tempo of an audio file to generat

Rush Kapoor 2 Nov 21, 2022
a reimplementation of UnFlow in PyTorch that matches the official TensorFlow version

pytorch-unflow This is a personal reimplementation of UnFlow [1] using PyTorch. Should you be making use of this work, please cite the paper according

Simon Niklaus 134 Nov 20, 2022
なりすまし検出(anti-spoof-mn3)のWebカメラ向けデモ

FaceDetection-Anti-Spoof-Demo なりすまし検出(anti-spoof-mn3)のWebカメラ向けデモです。 モデルはPINTO_model_zoo/191_anti-spoof-mn3からONNX形式のモデルを使用しています。 Requirement mediapipe

KazuhitoTakahashi 8 Nov 18, 2022
Technical Analysis library in pandas for backtesting algotrading and quantitative analysis

bta-lib - A pandas based Technical Analysis Library bta-lib is pandas based technical analysis library and part of the backtrader family. Links Main P

DRo 393 Dec 20, 2022
Official PyTorch Implementation for "Recurrent Video Deblurring with Blur-Invariant Motion Estimation and Pixel Volumes"

PVDNet: Recurrent Video Deblurring with Blur-Invariant Motion Estimation and Pixel Volumes This repository contains the official PyTorch implementatio

Junyong Lee 98 Nov 06, 2022
TorchIO is a Medical image preprocessing and augmentation toolkit for deep learning. Part of the PyTorch Ecosystem.

Medical image preprocessing and augmentation toolkit for deep learning. Part of the PyTorch Ecosystem.

Fernando Pérez-García 1.6k Jan 06, 2023
Source code for CVPR 2021 paper "Riggable 3D Face Reconstruction via In-Network Optimization"

Riggable 3D Face Reconstruction via In-Network Optimization Source code for CVPR 2021 paper "Riggable 3D Face Reconstruction via In-Network Optimizati

130 Jan 02, 2023
[CVPR 2021] Anycost GANs for Interactive Image Synthesis and Editing

Anycost GAN video | paper | website Anycost GANs for Interactive Image Synthesis and Editing Ji Lin, Richard Zhang, Frieder Ganz, Song Han, Jun-Yan Zh

MIT HAN Lab 726 Dec 28, 2022
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.

Fairseq(-py) is a sequence modeling toolkit that allows researchers and developers to train custom models for translation, summarization, language mod

20.5k Jan 08, 2023
Collections for the lasted paper about multi-view clustering methods (papers, codes)

Multi-View Clustering Papers Collections for the lasted paper about multi-view clustering methods (papers, codes). There also exists some repositories

Andrew Guan 10 Sep 20, 2022
NeRF Meta-Learning with PyTorch

NeRF Meta Learning With PyTorch nerf-meta is a PyTorch re-implementation of NeRF experiments from the paper "Learned Initializations for Optimizing Co

Sanowar Raihan 78 Dec 18, 2022