Quick Start¶
1. Prepare Your Data¶
Place your PAN and MS images in the data/ directory:
data/
pan.tif # Panchromatic image (1 band, high resolution)
ms.tif # Multispectral image (N bands, low resolution)
2. Run Pansharpening¶
Using Deep Learning Models¶
# Run with default PanNet model
python scripts/run_deep_learning.py --model pannet
# Run with transformer model
python scripts/run_deep_learning.py --model panformer_lite --epochs 100
# With spectral-focused loss
python scripts/run_deep_learning.py --model panformer_lite --loss spectral_focus --epochs 200
Using Classic Methods¶
3. Python API¶
from models import create_model, create_loss
import torch
# Create model
model = create_model('panformer_lite', ms_bands=4)
# Create loss function
criterion = create_loss('spectral_focus')
# Prepare inputs
ms = torch.randn(1, 4, 256, 256) # Multispectral
pan = torch.randn(1, 1, 256, 256) # Panchromatic
# Run inference
with torch.no_grad():
fused = model(ms, pan)
print(f"Output shape: {fused.shape}") # [1, 4, 256, 256]
4. Load Pre-trained Weights¶
import torch
from models import create_model
# Create model
model = create_model('panformer_lite', ms_bands=4)
# Load pre-trained weights
model.load_state_dict(torch.load('checkpoints/panformer_lite_best.pth'))
model.eval()