Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

UNetFormer++: Early Context Modules for UAV Semantic Segmentation

PyTorch Python

An Early Context Module (ECM): windowed self-attention added to encoder stages 2–4 of UNetFormer, to give small objects in drone imagery more context.


Summary

  • Overall mIoU: no change. Against a baseline trained with the identical recipe, mIoU is 67.55% vs. 67.59% (last-10-epoch average).
  • Human class: +2.2 IoU, ahead of the baseline in all of the last 10 epochs. Humans are the smallest and hardest class in UAVid.
  • Trade-off: tree (−0.8) and low vegetation (−1.2) are lower in all of the last 10 epochs. Cars show no change.
  • Caveat: one training run per model. Treat these as signals to test with more seeds, not settled results.

Example output

Example UNetFormer++ predictions on UAVid.

Quick Start

# 1. Clone
git clone https://github.com/AjayAdit/Unet_Former_Plus_Plus.git
cd Unet_Former_Plus_Plus

# 2. Setup environment
conda env create -f environment.yml
conda activate airs

# 3. Train
python GeoSeg/train_supervision.py -c GeoSeg/config/uavid/unetformerpp.py

# 4. Inference
python inference_unetformerpp.py

Results

Setup. Both models use the same data split and the same training recipe: 60 epochs, AdamW + Lookahead, lr 1e-3, weight decay 0.05, backbone lr 1e-4, cosine schedule. The only difference is the ECM. Configs: unetformerpp.py (ECM) and unetformer_matched.py (baseline).

Metric. IoU on the UAVid val split, averaged over the last 10 epochs (50–59) to reduce epoch-to-epoch noise. One training run per model.

Class Baseline UNetFormer++ (ECM) Difference Epochs where ECM is ahead (of last 10)
Building 90.13 90.28 +0.15 7
Road 74.37 74.17 −0.21 5
Tree 76.77 75.99 −0.78 0
Low Vegetation 66.47 65.26 −1.22 0
Moving Car 66.17 66.05 −0.12 6
Static Car 64.71 64.52 −0.20 5
Human 41.56 43.72 +2.17 10
Clutter 60.51 60.41 −0.11 5
mIoU 67.59 67.55 −0.04
Baseline UNetFormer++ (ECM)
mIoU, final epoch (59) 67.19 67.30
mIoU, best epoch 68.19 (ep 48) 68.46 (ep 57)

Reading the results. ECM does not raise overall mIoU. It does give a consistent gain on humans, the smallest class, while trees and low vegetation drop. One possible explanation, not tested: the larger 16×16 attention windows add useful surrounding context for tiny objects but blur the fine texture that separates tree from low vegetation. Next steps: more seeds, and an ablation of window size.


Installation

Option A: Conda (Recommended)

conda env create -f environment.yml
conda activate airs

Dataset Setup

  1. Download UAVid Dataset

  2. Organize as:

data/uavid/
├── train/
│   ├── images/
│   └── masks/
├── train_val/
│   ├── images/
│   └── masks/
└── val/
    ├── images/
    └── masks/
  1. Or create symbolic link:
ln -s /path/to/UAVid_patches data/uavid

Training

Train UNetFormerPP (Ours)

python GeoSeg/train_supervision.py -c GeoSeg/config/uavid/unetformerpp.py

Train Baseline (same recipe, used for the results above)

python GeoSeg/train_supervision.py -c GeoSeg/config/uavid/unetformer_matched.py

unetformer.py is the original GeoSeg baseline recipe (40 epochs). It is not used for the comparison.

Training Outputs

  • Logs: lightning_logs/uavid/
  • Checkpoints: model_weights/uavid/

Inference

Step 1: Update checkpoint path in inference_unetformerpp.py

CHECKPOINT_PATH = "model_weights/uavid/unetformerpp-r18-1024-768crop-e60-optimized/unetformerpp-r18-1024-768crop-e60-optimized.ckpt"

Step 2: Run

python inference_unetformerpp.py

Step 3: Generate comparisons

python colorize_gt.py
python create_comparison.py

Output: fig_results/uavid/comparison/


Configuration

Key parameters in GeoSeg/config/uavid/unetformerpp.py:

# ECM Parameters
use_ecm = True
ecm_stages = (2, 3, 4)        # Encoder stages for ECM
ecm_compression_ratio = 2      # Channel compression
ecm_num_heads = 8              # Attention heads
ecm_window_size = 16           # Window size

# Training
max_epoch = 60
lr = 1e-3
batch_size = 1
weight_decay = 0.05

Repository Structure

├── GeoSeg/
│   ├── geoseg/models/
│   │   ├── ecm.py              # Early Context Module
│   │   └── UNetFormerPP.py     # UNetFormer++ model
│   └── config/uavid/
│       ├── unetformerpp.py     # UNetFormer++ (ECM) training config
│       └── unetformer_matched.py  # Baseline with the identical recipe
├── inference_unetformerpp.py   # Inference script
├── colorize_gt.py              # GT visualization
├── create_comparison.py        # Comparison generator
├── requirements.txt
└── environment.yml


Acknowledgments

  • GeoSeg - Base framework
  • UAVid Dataset - Benchmark dataset
  • Worcester Polytechnic Institute - CS/DS 541 Deep Learning

Team

  • Ajay Adit Jagan
  • Seenivasa Ramasamy
  • Karan Sujay Muluskar
  • Cristina Seoylemezian

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages