Skip to content

πŸ›°οΈπŸŒ²Terra_Mask is an end-to-end computer vision project for semantic segmentation in land cover classification. It uses deep learning with PyTorch to classify features in high-resolution satellite imagery β€” such as buildings, woodland, water, and roads.

License

Notifications You must be signed in to change notification settings

XaXtric7/Terra_Mask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Terra_Mask πŸ›°οΈ

Land Cover Semantic Segmentation using PyTorch


πŸ“Œ What Is This Project?

Terra_Mask is an end-to-end computer vision project for semantic segmentation in land cover classification. It uses deep learning with PyTorch to classify features in high-resolution satellite imagery β€” such as buildings, woodland, water, and roads.

Built primarily for the LandCover.ai dataset, this project is modular and can be adapted to any semantic segmentation dataset.


🌍 What Does It Do?

This project enables you to:

  • βœ… Train segmentation models on land cover images
  • βœ… Test and infer with trained models
  • βœ… Prompt specific classes for prediction without retraining

Promptable Prediction: After training the model on all classes, you can selectively visualize only specific classes (e.g., just "buildings" and "water") by modifying the test_classes in the config.


πŸ“· Screenshots

Image

Image

Image

Image

Image

🧠 How It Works

1. Data Preparation

  • Patches are created from large aerial images.
  • Background-heavy patches are discarded.
  • Data is split into train/val/test sets.

2. Model Architecture

  • Uses UNet from segmentation_models_pytorch
  • EfficientNet as the encoder backbone
  • Decoder upsamples features to produce segmentation masks

3. Training

  • Uses Dice Loss for segmentation accuracy
  • Learning rate scheduling for better optimization

4. Inference

  • Patches are passed through the model
  • Reconstructed masks are filtered by class
  • Visualizations are generated and saved

πŸš€ Quick Start

πŸ“ Dataset Setup

Copy the dataset from LandCover.ai on Kaggle

Organize it as:

data/
β”œβ”€β”€ train/
β”‚ β”œβ”€β”€ images/ # Training satellite images
β”‚ └── masks/ # Corresponding segmentation masks
└── test/
β”œβ”€β”€ images/ # Testing satellite images
└── masks/ # Corresponding segmentation masks

πŸ”§ Environment Setup

# Clone this repository
git clone https://github.com/souvikmajumder26/Land-Cover-Semantic-Segmentation-PyTorch.git
cd Land-Cover-Semantic-Segmentation-PyTorch

# Install required packages
pip install -r requirements.txt

πŸƒβ€β™‚οΈ How to Run

πŸ”¬ Testing with Pre-trained Model

cd src
python test.py

🎯 Inference

cd src
python inference.py

πŸ‹οΈβ€β™‚οΈ Training the Model(⚠️ Requires significant GPU resources.)

cd src
python train.py

🐳 Docker Support

Build and Run in Docker

docker build -t segment_project_image .
docker run --name segment_container -d segment_project_image

Copy Outputs

docker cp segment_container:/segment_project/models ./models
docker cp segment_container:/segment_project/logs ./logs
docker cp segment_container:/segment_project/output ./output

Cleanup

docker stop segment_container
docker rm segment_container
docker rmi segment_project_image

πŸ“ Project Structure

β”œβ”€β”€ config/
β”‚   └── config.yaml        # Configuration file (classes, model params)
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ train/
β”‚   β”œβ”€β”€ test/
β”œβ”€β”€ models/                # Pretrained weights
β”œβ”€β”€ output/
β”‚   β”œβ”€β”€ predicted_masks/   # .tif mask outputs
β”‚   β”œβ”€β”€ prediction_plots/  # .png visualizations
β”œβ”€β”€ logs/                  # Training and testing logs
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ train.py
β”‚   β”œβ”€β”€ test.py
β”‚   └── inference.py
β”œβ”€β”€ requirements.txt
└── README.md

πŸ”§ Technologies Used

🧠 Deep Learning & Vision

  • PyTorch 2.0.1
  • torchvision 0.15.2
  • segmentation_models_pytorch 0.3.3
  • EfficientNet (efficientnet-pytorch)
  • timm (PyTorch Image Models)

🧰 Image & Data Handling

  • OpenCV (opencv-python-headless)
  • patchify
  • scikit-image, scikit-learn
  • albumentations
  • tifffile, Pillow, NumPy

πŸ“¦ Utilities

  • PyYAML
  • tqdm
  • split-folders
  • filelock, joblib
  • pretrainedmodels
  • huggingface-hub

πŸ“ˆ Loss and Optimization

  • Dice Loss
  • Adam Optimizer
  • LR Scheduler (PyTorch)

🐳 Deployment

  • Docker

πŸ“œ License

This project is released under the MIT License.

About

πŸ›°οΈπŸŒ²Terra_Mask is an end-to-end computer vision project for semantic segmentation in land cover classification. It uses deep learning with PyTorch to classify features in high-resolution satellite imagery β€” such as buildings, woodland, water, and roads.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published