Personal short test project implementing partial cross-entropy (pCE) and partial focal cross-entropy (pfCE) on simulated point labels, trained on LoveDA (real remote sensing) or a synthetic benchmark for fast checks.
| Item | Description |
|---|---|
src/losses.py |
Masked pCE and pfCE (normalized by number of labeled pixels). |
src/data.py |
LoveDA loader (TorchGeo), random/balanced point simulation, synthetic dataset. |
src/model.py |
U-Net + ResNet-34 (ImageNet weights) via segmentation_models_pytorch. |
train.py |
Training and full-mask validation mIoU (LoveDA label 0 = no-data excluded from IoU mean). |
run_experiments.py |
Experiment grid → experiments/logs/results.csv. |
tests/test_losses.py |
Sanity checks for the loss implementations. |
TECHNICAL_REPORT.md |
Method, experiments (purpose / hypothesis / procedure), and results. |
- Python 3.10+ (3.11 recommended)
- Disk: a few MB for code; ~4 GB+ per split if you download LoveDA train/val
- GPU: optional; CPU runs work for small epochs and synthetic data
Do not install dependencies system-wide.
cd /path/to/TestProject
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txtFor GPU PyTorch, install the matching torch / torchvision wheels from pytorch.org (then install the rest of requirements.txt if needed).
source .venv/bin/activate # or: .venv/bin/python tests/test_losses.py
python tests/test_losses.pyExpected: ok
If your shell does not load the venv (some CI setups), call the interpreter explicitly: .venv/bin/python tests/test_losses.py.
Run from the project root (the repo root that contains src/ and train.py).
python train.py --dataset synthetic --epochs 8 --batch-size 8 --crop-size 256 \
--num-points 50 --loss focal --sampling random --seed 42First run downloads Zenodo archives into --data-root (large). Use caps while developing:
python train.py --dataset loveda --data-root ./data/loveda --download \
--epochs 10 --batch-size 4 --crop-size 512 \
--num-points 50 --loss focal --sampling random \
--max-train-samples 400 --max-val-samples 150 --seed 42Note on mask PNGs: segmentation masks use small integer class IDs (0–7). Many viewers show them as almost black; that is normal. See TECHNICAL_REPORT.md (FAQ).
Runs Experiment A (point density × sampling, pfCE) and Experiment B (pCE vs pfCE at fixed settings):
python run_experiments.py --dataset synthetic --epochs 3 --batch-size 8 --crop-size 256 \
--max-train-samples 200 --max-val-samples 80 --seed 42LoveDA (after data is present):
python run_experiments.py --dataset loveda --data-root ./data/loveda --epochs 5 \
--max-train-samples 500 --max-val-samples 200
# Add --download only if ./data/loveda is not populated yet.Output: experiments/logs/results.csv
| Option | Meaning |
|---|---|
--dataset |
synthetic or loveda |
--download |
Download LoveDA into --data-root (huge) |
--num-points |
Simulated clicks per crop (N) |
--sampling |
random (PDF baseline) or balanced (experiment) |
--loss |
focal (pfCE) or ce (pCE) |
--epochs, --batch-size, --lr, --crop-size |
Training knobs |
--max-train-samples, --max-val-samples |
Subset caps for speed |
Exclude the venv and any downloaded data. From the project root:
./scripts/package_submission.sh ./submission.zipOr manually zip the repository without .venv/, data/, and __pycache__/.
The produced archive should include: src/, train.py, run_experiments.py, requirements.txt, tests/, experiments/logs/results.csv (after you run experiments), TECHNICAL_REPORT.md, and this README.md.
If you use LoveDA, cite:
Wang et al., LoveDA: A Remote Sensing Land-Cover Dataset for Domain Adaptive Semantic Segmentation, arXiv:2110.08733.
This repository is a personal short test project. LoveDA has its own license; follow the LoveDA repository terms when using the data.