analysis¶
The breakdown behind hbb2obb-analyze. The guide describes each table and has a worked example.
from pathlib import Path
from hbb2obb.analysis import collect_pairs, plot_analysis, render_markdown, summarise
pairs = collect_pairs(Path("data/labels_obb_gt"), Path("data/labels_obb"), hbb_dir=Path("data/labels_hbb"))
summary = summarise(pairs)
Path("analysis.md").write_text(render_markdown(summary))
plot_analysis(summary, Path("analysis.png"))
Collecting pairs¶
collect_pairs
¶
collect_pairs(gt_dir: Path, pred_dir: Path, hbb_dir: Optional[Path] = None, image_sizes: Optional[Dict[str, Tuple[int, int]]] = None, excluded_classes: Sequence[int] = (), iou_threshold: float = 0.1, class_agnostic: bool = False, no_bar: bool = False) -> List[Pair]
Match every converted box to its ground truth and record what each cut needs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gt_dir
|
Path
|
Directory of ground-truth OBB annotations |
required |
pred_dir
|
Path
|
Directory of converted OBB annotations |
required |
hbb_dir
|
Optional[Path]
|
Directory of the horizontal boxes the conversion was prompted with, for the identity baseline; without it that comparison is left out |
None
|
image_sizes
|
Optional[Dict[str, Tuple[int, int]]]
|
Frame stem to (width, height), for the frame-edge cut; without it that cut is left out |
None
|
excluded_classes
|
Sequence[int]
|
Class ids to drop before matching |
()
|
iou_threshold
|
float
|
Minimum IoU for a match, as in |
0.1
|
class_agnostic
|
bool
|
Match regardless of class label |
False
|
no_bar
|
bool
|
Disable the progress bar |
False
|
Returns:
| Type | Description |
|---|---|
List[Pair]
|
One Pair per matched box. |
Source code in hbb2obb/analysis.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
Pair
dataclass
¶
One matched ground-truth and converted box, with the properties every cut reads.
Source code in hbb2obb/analysis.py
Summarising and reporting¶
summarise
¶
summarise(pairs: Sequence[Pair], label_map: Optional[dict] = None, boundary_classes: Optional[Sequence[int]] = None) -> dict
Every cut and comparison, as plain data a report or a plot can render.
Source code in hbb2obb/analysis.py
render_markdown
¶
The whole analysis as one Markdown document.
Source code in hbb2obb/analysis.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
print_analysis
¶
The same report on the terminal, the Markdown tables laid out in columns.
Source code in hbb2obb/analysis.py
plot_analysis
¶
Three panels: where the average comes from, what the prompt already gave, and the side ratios.
Forces the Agg backend, as the sweep plots do, so this runs on a headless machine.