File size: 1,208 Bytes
3334467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
import argparse
from pathlib import Path


def ensure_link(link: Path, target: str):
    if link.exists() or link.is_symlink():
        return
    try:
        link.symlink_to(target)
    except OSError:
        print(f"Could not create symlink {link} -> {target}. Please create it manually.")


def main():
    parser = argparse.ArgumentParser(description="Prepare DRSeg compatibility links.")
    parser.add_argument("--data-root", default="data/DRSeg")
    args = parser.parse_args()

    root = Path(args.data_root)
    if not root.exists():
        raise SystemExit(f"Missing data root: {root}")

    ensure_link(root / "CODrone", ".")
    if (root / "label").exists():
        ensure_link(root / "labels", "label")

    required = [
        root / "DRtrain",
        root / "DRval",
        root / "DRtest",
        root / "label" / "DRSeg_train.json",
        root / "label" / "DRSeg_val.json",
        root / "label" / "DRSeg_test.json",
    ]
    missing = [str(p) for p in required if not p.exists()]
    if missing:
        raise SystemExit("Missing required DRSeg files:\n" + "\n".join(missing))
    print(f"DRSeg is ready: {root}")


if __name__ == "__main__":
    main()