Add 80/20 random split (replaces cross-area 46/54 split)

- scripts/make_split.py: merges cross-area train+test (33,708 pairs),
  shuffles with seed=42, splits 80/20
- meta/train_80.json (26,966) + meta/test_20.json (6,742)
- After seg filter: 24,891 train / 6,252 test
- Default paths in train_gtauav.py updated to use new split

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
pikaliov
2026-04-21 18:19:37 +03:00
parent 44bce3096c
commit 905b9867c8
6 changed files with 98 additions and 6 deletions

View File

@@ -158,8 +158,10 @@ Meta-файл `meta/seg_filter.json`: исключение изображени
- Drone: RandomResizedCrop(0.7-1.0), HFlip, Rotation(15°), ColorJitter, Grayscale(5%), GaussianBlur - Drone: RandomResizedCrop(0.7-1.0), HFlip, Rotation(15°), ColorJitter, Grayscale(5%), GaussianBlur
- Satellite: RandomResizedCrop(0.7-1.0), HFlip, ColorJitter, Grayscale(5%) - Satellite: RandomResizedCrop(0.7-1.0), HFlip, ColorJitter, Grayscale(5%)
- Eval: Resize+CenterCrop (clean, no augmentation) - Eval: Resize+CenterCrop (clean, no augmentation)
- Train: 15,693 pairs → 13,622 after seg filter (cross-area) - **Split:** 80/20 random из всех 33,708 пар (`meta/train_80.json` / `meta/test_20.json`)
- Test: 18,015 pairs - Train: 26,966 → 24,891 after seg filter
- Test: 6,742 → 6,252 after seg filter
- Скрипт: `python -m scripts.make_split --ratio 0.8 --seed 42`
### V2 (UAV-GeoLoc, gin) ### V2 (UAV-GeoLoc, gin)
| Конфиг | Gate init | Описание | | Конфиг | Gate init | Описание |

View File

@@ -29,7 +29,7 @@ Loss: InfoNCE(query, gallery)
- Captions: `/home/servml/Документы/datasets/GTA-UAV-LR-captions/` (40K JSON, 3-paragraph VLM) - Captions: `/home/servml/Документы/datasets/GTA-UAV-LR-captions/` (40K JSON, 3-paragraph VLM)
- Segmentation: `/home/servml/Документы/datasets/GTA-UAV-LR-aug/` (17 classes) - Segmentation: `/home/servml/Документы/datasets/GTA-UAV-LR-aug/` (17 classes)
- Seg filter: 37,498 passed / 10,905 excluded (>=90% background+water) - Seg filter: 37,498 passed / 10,905 excluded (>=90% background+water)
- Train: 15,693 pairs, Test: 18,015 pairs (cross-area split) - Split: 80/20 random (26,966 train / 6,742 test → 24,891/6,252 after seg filter)
### V2 — UAV-GeoLoc + GeoRSCLIP (legacy) ### V2 — UAV-GeoLoc + GeoRSCLIP (legacy)
@@ -89,9 +89,10 @@ numpy
## Workflow (V3 — GTA-UAV) ## Workflow (V3 — GTA-UAV)
### 1. Filter segmentation (exclude uninformative images) ### 1. Create 80/20 split and filter segmentation
```bash ```bash
python -m scripts.make_split --output-dir meta
python -m scripts.filter_segmentation --output meta/seg_filter.json python -m scripts.filter_segmentation --output meta/seg_filter.json
``` ```

1
meta/test_20.json Normal file

File diff suppressed because one or more lines are too long

1
meta/train_80.json Normal file

File diff suppressed because one or more lines are too long

87
scripts/make_split.py Normal file
View File

@@ -0,0 +1,87 @@
from __future__ import annotations
"""Create 80/20 train/test split from GTA-UAV-LR pair JSONs.
Merges cross-area train+test (33,708 pairs), shuffles deterministically,
and saves new 80/20 split JSONs.
Usage:
python -m scripts.make_split [--ratio 0.8] [--seed 42]
"""
import argparse
import json
import logging
import random
from pathlib import Path
import coloredlogs
LOGGER = logging.getLogger("caption_test.make_split")
_RGB_ROOT = Path("/home/servml/Документы/datasets/GTA-UAV-LR")
def main() -> None:
parser = argparse.ArgumentParser(description="Create 80/20 split for GTA-UAV-LR.")
parser.add_argument("--ratio", type=float, default=0.8, help="Train ratio (default 0.8).")
parser.add_argument("--seed", type=int, default=42, help="Random seed.")
parser.add_argument(
"--output-dir", type=str, default="meta",
help="Output directory for split JSONs.",
)
args = parser.parse_args()
coloredlogs.install(
level="INFO", logger=LOGGER,
fmt="%(asctime)s %(name)s %(levelname)s %(message)s",
)
# Load both original splits.
train_path = _RGB_ROOT / "cross-area-drone2sate-train.json"
test_path = _RGB_ROOT / "cross-area-drone2sate-test.json"
LOGGER.info("📂 Loading %s", train_path.name)
with open(train_path) as f:
part1 = json.load(f)
LOGGER.info("📂 Loading %s", test_path.name)
with open(test_path) as f:
part2 = json.load(f)
all_pairs = part1 + part2
LOGGER.info("📊 Total pairs: %d", len(all_pairs))
# Shuffle deterministically.
rng = random.Random(args.seed)
rng.shuffle(all_pairs)
# Split.
n_train = int(len(all_pairs) * args.ratio)
train_pairs = all_pairs[:n_train]
test_pairs = all_pairs[n_train:]
LOGGER.info(
"✂️ Split %.0f/%.0f: train=%d (%.1f%%) test=%d (%.1f%%)",
args.ratio * 100, (1 - args.ratio) * 100,
len(train_pairs), 100 * len(train_pairs) / len(all_pairs),
len(test_pairs), 100 * len(test_pairs) / len(all_pairs),
)
# Save.
out_dir = Path(args.output_dir)
out_dir.mkdir(parents=True, exist_ok=True)
train_out = out_dir / "train_80.json"
test_out = out_dir / "test_20.json"
with train_out.open("w", encoding="utf-8") as f:
json.dump(train_pairs, f)
with test_out.open("w", encoding="utf-8") as f:
json.dump(test_pairs, f)
LOGGER.info("💾 Saved: %s (%d pairs)", train_out, len(train_pairs))
LOGGER.info("💾 Saved: %s (%d pairs)", test_out, len(test_pairs))
if __name__ == "__main__":
main()

View File

@@ -37,8 +37,8 @@ LOGGER = logging.getLogger("caption_test.train_gtauav")
# Default paths. # Default paths.
_RGB_ROOT = "/home/servml/Документы/datasets/GTA-UAV-LR" _RGB_ROOT = "/home/servml/Документы/datasets/GTA-UAV-LR"
_CAPTION_ROOT = "/home/servml/Документы/datasets/GTA-UAV-LR-captions" _CAPTION_ROOT = "/home/servml/Документы/datasets/GTA-UAV-LR-captions"
_TRAIN_JSON = f"{_RGB_ROOT}/cross-area-drone2sate-train.json" _TRAIN_JSON = "meta/train_80.json"
_TEST_JSON = f"{_RGB_ROOT}/cross-area-drone2sate-test.json" _TEST_JSON = "meta/test_20.json"
_DINO_WEB = "nn_models/DINO_WEB/dinov3-vitl16-pretrain-lvd1689m.pth" _DINO_WEB = "nn_models/DINO_WEB/dinov3-vitl16-pretrain-lvd1689m.pth"
_DINO_SAT = "nn_models/DINO_SAT/model.safetensors" _DINO_SAT = "nn_models/DINO_SAT/model.safetensors"