How 2536070004phd2026/prototype works
Purpose and Entry Points
This is a GPU-oriented prototype for pixel-level land-use/land-cover (LULC) segmentation of Indian satellite imagery using the Sen-2 LULC dataset. Its lifecycle is: validate a manually downloaded dataset, build PyTorch loaders, train three segmentation architectures, and serve predictions/results in Streamlit.
Primary entry points:
• Dataset verification: 01_download_dataset.py
• Data loading smoke test and reusable pipeline: 02_data_pipeline.py
• Model training and artifact generation: 03_train_models.py
• Interactive UI: streamlit_app.py
Dataset Boundary
The dataset is externally obtained from Mendeley and expected to be extracted locally as sen2lulc; it is not versioned in the repository. 01_download_dataset.py verifies that expected local data is available. 02_data_pipeline.py owns the image/mask directory assumptions and is the boundary between raw raster/image files and training tensors.
Data Pipeline
02_data_pipeline.py defines the segmentation dataset abstraction and creates train, validation, and test DataLoaders. It pairs satellite tiles with corresponding class masks, applies image/mask preprocessing, and emits batched tensors suitable for semantic segmentation. Batch size is deliberately constrained for a 6 GB RTX 3060-class GPU.
The pipeline is shared control infrastructure: training consumes its loaders, while the UI must reproduce compatible image preprocessing for inference.
Training Orchestration
03_train_models.py is the central training workflow. It trains three encoder families—ConvNeXt, Swin Transformer, and ResNet—through segmentation-models-pytorch/timm-based segmentation models. It runs GPU training with PyTorch mixed precision to reduce VRAM pressure.
The workflow evaluates segmentation quality using IoU and Dice, records training duration, and persists trained weights plus a results summary under an outputs location at runtime. Those artifacts form the contract consumed by the demonstration layer.
Inference and Demonstration UI
streamlit_app.py is the deployed-facing interface, despite the README referring to a stale 04_app.py filename. It provides an image-upload prediction workflow that renders a color-coded LULC mask and a model-comparison view driven by saved evaluation metrics. It depends on compatible model checkpoints and result artifacts produced by 03_train_models.py.
Runtime and Dependencies
The primary runtime is Python with CUDA-enabled PyTorch, intended for NVIDIA GPU execution. Core libraries include torch, torchvision, segmentation-models-pytorch, timm, NumPy/Pandas, Pillow, scikit-learn, and Streamlit. External dependencies are the locally downloaded Sen-2 LULC dataset and the Mendeley dataset host; there is no indicated database, API backend, or cloud infrastructure.
End-to-End Control Flow
1. Obtain and extract Sen-2 LULC data externally.
2. Validate local placement via 01_download_dataset.py.
3. Configure and validate image/mask loading through 02_data_pipeline.py.
4. Train and evaluate three models in 03_train_models.py.
5. Load generated checkpoints/results into streamlit_app.py for uploaded-image inference and comparison.
Key operational boundary: model weights, metrics JSON, class ordering, image size, normalization, and mask color/class mappings must remain consistent between 02_data_pipeline.py, 03_train_models.py, and streamlit_app.py.
Main entry points: 02_data_pipeline.py Segmentation dataset · 03_train_models.py Three segmentation models · streamlit_app.py Inference preprocessing · 01_download_dataset.py Dataset verification
Components 13
Dataset & Pipeline
- Mendeley dataset host
- Local sen2lulc dataset · Manually downloaded and extracted locally.
- Dataset verification · Checks expected local dataset placement.
01_download_dataset.py - Segmentation dataset · Pairs satellite tiles with class masks and preprocesses both.
02_data_pipeline.py - Train/val/test loaders · GPU-constrained batched training tensors.
02_data_pipeline.py
GPU Training
- Training workflow · Trains, evaluates, and writes demonstration artifacts.
03_train_models.py - Three segmentation models · ConvNeXt, Swin Transformer, and ResNet encoder families.
03_train_models.py - CUDA PyTorch runtime · Uses mixed precision to reduce VRAM pressure.
- Segmentation evaluation · Computes IoU, Dice, and training duration.
03_train_models.py - Checkpoints & results · Weights and evaluation summary consumed by the UI.
Inference UI
- Streamlit application · Deployed-facing upload prediction and comparison interface.
streamlit_app.py - Inference preprocessing · Must match training image size, normalization, classes, and colors.
streamlit_app.py - LULC prediction & comparison · Renders a color-coded mask and model metrics comparison.
streamlit_app.py
Connections 15
- Mendeley dataset host → Local sen2lulc dataset: manual download & extract
- Local sen2lulc dataset → Dataset verification: validate placement
- Local sen2lulc dataset → Segmentation dataset: tiles and masks
- Segmentation dataset → Train/val/test loaders: split and batch
- Train/val/test loaders → Training workflow: training inputs
- Training workflow → Three segmentation models: instantiate and train
- CUDA PyTorch runtime → Training workflow: CUDA mixed precision
- Three segmentation models → Segmentation evaluation: predictions
- Segmentation evaluation → Checkpoints & results: metrics summary
- Three segmentation models → Checkpoints & results: trained weights
- Checkpoints & results → Streamlit application: load checkpoints and results
- Streamlit application → Inference preprocessing: uploaded image
- Inference preprocessing → LULC prediction & comparison: model prediction
- Checkpoints & results → LULC prediction & comparison: comparison metrics
- Segmentation dataset → Inference preprocessing: shared preprocessing contract