An open API service indexing awesome lists of open source software.

https://github.com/souvikmajumder26/land-cover-semantic-segmentation-pytorch

🛣 Building an end-to-end Promptable Semantic Segmentation (Computer Vision) project from training to inferencing a model on LandCover.ai data (Satellite Imagery).
https://github.com/souvikmajumder26/land-cover-semantic-segmentation-pytorch

ai-project ai-projects artificial-intelligence computer-vision deep-learning end-to-end image-segmentation landcover machine-learning-project machine-learning-projects ml-project ml-projects neural-network promptable promptable-segmentation pytorch satellite-imagery segmentation-models-pytorch semantic-segmentation unet

Last synced: 23 days ago
JSON representation

🛣 Building an end-to-end Promptable Semantic Segmentation (Computer Vision) project from training to inferencing a model on LandCover.ai data (Satellite Imagery).

Awesome Lists containing this project

README

        



![logo](https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch/blob/main/assets/logo2.jpg)

🛣 Land-Cover-Semantic-Segmentation-PyTorch:
An end-to-end Image Segmentation (CV) project

![PyTorch - Version](https://img.shields.io/badge/PYTORCH-2.0+-red?style=for-the-badge&logo=pytorch)
![Python - Version](https://img.shields.io/badge/PYTHON-3.9+-blue?style=for-the-badge&logo=python&logoColor=white)
[![Generic badge](https://img.shields.io/badge/License-MIT-.svg?style=for-the-badge)](https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch/blob/main/LICENSE)
[![GitHub Issues](https://img.shields.io/github/issues/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch.svg?style=for-the-badge)](https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch/issues)
![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg?style=for-the-badge)

----

## 📚 Table of Contents
- [Overview](#overview)
- [Demo](#demo)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Setting up and Running the project with Docker](#with-docker)
- [Setup without Docker](#setup)
- [Running the project without Docker](#running-the-project)
- [Citing](#citing)
- [License](#license)
- [Acknowledgements](#acknowledgements)

----

## 📌 Overview
An end-to-end Computer Vision project focused on the topic of Image Segmentation (specifically Semantic Segmentation). Although this project has primarily been built with the LandCover.ai dataset, the project template can be applied to train a model on any semantic segmentation dataset and extract inference outputs from the model in a promptable fashion. Though this is not even close to actual promptable AI, the term is being used here because of a specific functionality that has been integrated here.

The model can be trained on any or all the classes present in the semantic segmentation dataset with the ability to customize the model architecture, optimizer, learning rate, and a lot more parameters directly from the config file, giving it an exciting AutoML aspect. Thereafter while testing, the user can pass the prompt (in the form of the config variable 'test_classes') of the selected classes that the user wants to be present in the masks predicted by the trained model.

For example, suppose the model has been trained on all the 30 classes of the CityScapes dataset and while inferencing, the user only wants the class 'parking' to be present in the predicted mask due to a specific use-case application. Therefore, the user can provide the prompt as 'test_classes = ['parking']' in the config file and get the desired output.

----

## 💫 Demo


1. Training the model on LandCover.ai dataset with 'train_classes': ['background', 'building', 'woodland', 'water']...






2. Testing the trained model for all the classes used to train the model, i.e. 'test_classes': ['background', 'building', 'woodland', 'water']...






3. Testing the trained model for selective classes as per user input, i.e. 'test_classes': ['background', 'building', 'water']...




---

## 🚀 Getting Started

### ✅ Prerequisites

- Dataset prerequisite for training:

Before starting to train a model, make sure to download the dataset from LandCover.ai or from kaggle/LandCover.ai, and copy/move over the downloaded directories 'images' and 'masks' to the 'train' directory of the project.

### 🐳 Setting up and Running the project with Docker

First and foremost, make sure that Docker is installed and working properly in the system.

> 💡 Check the **Dockerfile** added in the repository. According the instructions provided in the file, comment and uncomment the mentioned lines to setup the docker image and container either to **train** or **test** the model at a time.

1. Clone the repository:
```shell
git clone https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch.git
```
2. Change to the project directory:
```shell
cd Land-Cover-Semantic-Segmentation-PyTorch
```
3. Build the image from the Dockerfile:
```shell
docker build -t segment_project_image .
```
4. Running the docker image in a docker container:
```shell
docker run --name segment_container -d segment_project_image
```
5. Copying the output files from the container directory to local project directory after execution is complete:
```shell
docker cp segment_container:/segment_project/models ./models
docker cp segment_container:/segment_project/logs ./logs
docker cp segment_container:/segment_project/output ./output
```
6. Tidying up:
```shell
docker stop segment_container
docker rm segment_container
docker rmi segment_project_image
```

If Docker is not installed in the system, follow the below methods to set up and run the project without Docker.

### 💻 Setup (Without 🐳 Docker)

1. Clone the repository:
```shell
git clone https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch.git
```
2. Change to the project directory:
```shell
cd Land-Cover-Semantic-Segmentation-PyTorch
```
3. Setting up programming environment to run the project:

- If using an installed conda package manager, i.e. either Anaconda or Miniconda, create the conda environment following the steps mentioned below:
```shell
conda create --name python=3.9
conda activate
```
- If using a directly installed python software, create the virtual environment following the steps mentioned below:
```shell
python -m venv
\Scripts\activate
```
4. Install the dependencies:
```shell
pip install -r requirements.txt
```

### 🤖 Running the project (Without 🐳 Docker)

Running the model training and testing/inferencing scripts from the project directory. It is not necessary to train the model first mandatorily, as a simple trained model has been provided to run the test and check outputs before trying to fine-tune the model.

1. Run the model training script:
```shell
cd src
python train.py
```
2. Run the model test (with images and masks) script:
```shell
cd src
python test.py
```
3. Run the model inference (with images only, masks not required) script:
```shell
cd src
python inference.py
```

----

## 📝 Citing
```
@misc{Souvik:2023,
Author = {Souvik Majumder},
Title = {Land Cover Semantic Segmentation PyTorch},
Year = {2023},
Publisher = {GitHub},
Journal = {GitHub repository},
Howpublished = {\url{https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch}}
}
```

----

## 🛡️ License
Project is distributed under [MIT License](https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch/blob/main/LICENSE)

---

## 👏 Acknowledgements
- [qubvel/segmentation_models.pytorch](https://github.com/qubvel/segmentation_models.pytorch)
```
@misc{Iakubovskii:2019,
Author = {Pavel Iakubovskii},
Title = {Segmentation Models Pytorch},
Year = {2019},
Publisher = {GitHub},
Journal = {GitHub repository},
Howpublished = {\url{https://github.com/qubvel/segmentation_models.pytorch}}
}
```
- [LandCover.ai](https://landcover.ai.linuxpolska.com/)
- [bnsreenu/python_for_microscopists](https://github.com/bnsreenu/python_for_microscopists)
- [leonardo.ai](https://leonardo.ai)


🔝 Return

---