"""Oriented R-CNN teaching override for MMRotate 0.3.3.

The official MMRotate source tree is intentionally kept outside this repository.
Set ``MMROTATE_ROOT`` before launching ``tools/train.py``.  The base config is
loaded from that source tree, so the model definition remains aligned with the
installed MMRotate version instead of duplicating upstream code here.
"""

import os
from pathlib import Path

MMROTATE_ROOT = Path(os.getenv("MMROTATE_ROOT", "third_party/mmrotate-v0.3.3"))
_base_ = [str(MMROTATE_ROOT / "configs/oriented_rcnn/oriented_rcnn_r50_fpn_1x_dota_le90.py")]

data_root = os.getenv("DOTA_ROOT", "data/raw/DOTA")
# Keep validation separate from training. Prepare a source-image-level split
# before tiling; defaulting validation to trainval would leak neighbouring
# tiles and is intentionally avoided here.
train_root = os.getenv("DOTA_TRAIN_ROOT", f"{data_root}/trainval")
val_root = os.getenv("DOTA_VAL_ROOT", f"{data_root}/val")
test_root = os.getenv("DOTA_TEST_ROOT", f"{data_root}/test")
classes = (
    "plane", "baseball-diamond", "bridge", "ground-track-field", "small-vehicle",
    "large-vehicle", "ship", "tennis-court", "basketball-court", "storage-tank",
    "soccer-ball-field", "roundabout", "harbor", "swimming-pool", "helicopter",
)

model = dict(roi_head=dict(bbox_head=dict(num_classes=len(classes))))
dataset_type = "DOTADataset"
data = dict(
    train=dict(type=dataset_type, ann_file=f"{train_root}/labelTxt/", img_prefix=f"{train_root}/images/", classes=classes),
    val=dict(type=dataset_type, ann_file=f"{val_root}/labelTxt/", img_prefix=f"{val_root}/images/", classes=classes),
    test=dict(type=dataset_type, ann_file=f"{test_root}/labelTxt/", img_prefix=f"{test_root}/images/", classes=classes),
)
evaluation = dict(interval=1, metric="mAP")
work_dir = "runs/notebook_outputs/oriented_rcnn"
seed = 42
