Giter Site home page Giter Site logo

aerial_imagery_semantic_segmentation's Introduction

Semantic segmentation of aerial imagery using U-Net

PyTorch implementation of UNet for semantic segmentation of aerial imagery

  1. This repository enables training UNet with various encoders like ResNet18, ResNet34, etc.
  2. Uses a compound (Cross-Entropy + Jaccard loss) loss to train the network.
  3. You can quickly use a custom dataset to train the model.
  4. Contains a self-supervised method to train network encoder on unlabeled data (Upcoming task).


Example of the network outputs visualization

Upcoming Tasks

  1. Complete the self-supervised part of the repository and train the encoder on our unlabeled dataset.
  2. Implement dataloaders and evaluation metrics for FloodNet, and EarthVision challenges.
  3. Add Distributed Data-Parallel strategy to the repository to enable multi-GPUs training.

Get started

  1. Clone the repository

    git clone https://github.com/sabadijou/aerial_imagery_semantic_segmentation.git
    

    We call this directory as $RESA_ROOT

  2. Create an environment and activate it (We've used conda. but it is optional)

    conda create -n aiss python=3.9 -y
    conda activate aiss
  3. Install dependencies

    # Install pytorch firstly, the cudatoolkit version should be same in your system. (you can also use pip to install pytorch and torchvision)
    conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
    
    # Install following libraries
    pip install opencv-python
    pip install numpy
    pip install matplotlib
    pip install segmentation_models_pytorch
  4. Download and extract dataset Download and extract this Kaggle Dataset

    Note: this repository is still developing, and this dataset is used for testing the model. Our model could achieve 81.0% segmentation accuracy on this dataset.

    semantic-segmentation-of-aerial-imagery/
                   ├── Tile 1
                         ├── images
                            ├── image_part_001.jpg
                            ├── image_part_002.jpg
                            ├── ...
                         └── masks
                            ├── image_part_001.png
                            ├── image_part_002.png
                            ├── ...
                   ├── Tile 2
                   ├── .
                   ├── .
                   └── Tile 9
                   └── classes
    
    

Training

The following command is prepared as an example for training the network. You can customize the parameters to train the default version.

Note that this repository still not supports multi-GPUs training.

python train.py --dataset_path Semantic_segmentation_dataset --encoder resnet34 --encoder_weights imagenet --gpu_id 0 --gpus 1

Demo

  1. Inference Demo with a Pre-trained model. You can download our pretrain weights from here and customize the following command to run the demo
python demo.py --checkpoint checkpoints/best.pth --image_path demo/sample_1.jpg --fname demo/result_1.jpg --gpu_id 0

aerial_imagery_semantic_segmentation's People

Contributors

sabadijou avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.