Expand regional corpus and aerial finetuning controls
This commit is contained in:
@@ -52,6 +52,14 @@ def metrics(tp: int, fp: int, fn: int) -> dict[str, float | int]:
|
||||
}
|
||||
|
||||
|
||||
def scale_box(box: tuple[float, float, float, float], factor: float) -> tuple[float, float, float, float]:
|
||||
"""Scale a detector box around its center for calibration-only geometry correction."""
|
||||
x1, y1, x2, y2 = box
|
||||
cx, cy = (x1 + x2) / 2, (y1 + y2) / 2
|
||||
half_width, half_height = (x2 - x1) * factor / 2, (y2 - y1) * factor / 2
|
||||
return cx - half_width, cy - half_height, cx + half_width, cy + half_height
|
||||
|
||||
|
||||
def read_references(path: Path, width: int, height: int) -> list[tuple[float, float, float, float]]:
|
||||
boxes = []
|
||||
for line in path.read_text(encoding="utf-8").splitlines() if path.is_file() else []:
|
||||
@@ -88,6 +96,7 @@ def main() -> int:
|
||||
default=1000,
|
||||
help="Maximum detections retained per tile; dense Belgian urban tiles exceed YOLO's default 300.",
|
||||
)
|
||||
parser.add_argument("--box-scale", type=float, default=1.0)
|
||||
args = parser.parse_args()
|
||||
|
||||
from ultralytics import YOLO
|
||||
@@ -119,7 +128,7 @@ def main() -> int:
|
||||
for tile, result in zip(tiles, results, strict=True):
|
||||
height, width = result.orig_shape
|
||||
predictions = [
|
||||
(tuple(map(float, box)), float(score))
|
||||
(scale_box(tuple(map(float, box)), args.box_scale), float(score))
|
||||
for box, score in zip(result.boxes.xyxy.cpu().tolist(), result.boxes.conf.cpu().tolist(), strict=True)
|
||||
]
|
||||
observations.append(
|
||||
@@ -163,6 +172,7 @@ def main() -> int:
|
||||
"test_time_augmentation": args.augment,
|
||||
"inference_imgsz": args.imgsz,
|
||||
"max_detections_per_tile": args.max_det,
|
||||
"box_scale": args.box_scale,
|
||||
"tile_count": len(tiles),
|
||||
"sweeps": sweeps,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user