Skip to content

Commit bec56f0

Browse files
Fix ruff E702 violations and formatting in make_hero.py
CI has been red since this file landed: two semicolon-joined statements failed ruff check, and the file predated ruff format's style. Both gates now pass with the pinned ruff 0.15.15. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 00fc563 commit bec56f0

1 file changed

Lines changed: 48 additions & 21 deletions

File tree

‎make_hero.py‎

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ class counts, and the scene's geodetic center - the core of what GEOINT-COP
99
1010
Run: python make_hero.py (uses yolo26m-obb.pt, conf 0.20)
1111
"""
12+
1213
import os
1314
from collections import Counter
1415

1516
import matplotlib
17+
1618
matplotlib.use("Agg")
1719
import matplotlib.pyplot as plt
1820
from matplotlib.patches import Polygon
@@ -22,7 +24,7 @@ class counts, and the scene's geodetic center - the core of what GEOINT-COP
2224
from ultralytics import YOLO
2325

2426
TIF, MODEL, CONF = "naip_clip.tif", "yolo26m-obb.pt", 0.20
25-
IMGSZ = 2048 # infer at native resolution; the 640px default misses small aircraft
27+
IMGSZ = 2048 # infer at native resolution; the 640px default misses small aircraft
2628
BG, INK, DIM, ACC = "#070b12", "#d7e2f0", "#6b7d95", "#ffb020"
2729

2830
# --- imagery + georeference ---
@@ -38,45 +40,70 @@ class counts, and the scene's geodetic center - the core of what GEOINT-COP
3840
obb = r.obb
3941
labels = [r.names[int(c)] for c in obb.cls]
4042
counts = Counter(labels)
41-
polys = obb.xyxyxyxy.cpu().numpy() # (n, 4, 2) oriented corners
43+
polys = obb.xyxyxyxy.cpu().numpy() # (n, 4, 2) oriented corners
4244
confs = obb.conf.cpu().numpy()
4345

4446
# --- figure ---
4547
plt.rcParams.update({"font.family": "DejaVu Sans", "text.color": INK})
4648
fig = plt.figure(figsize=(11, 8.6), facecolor=BG)
4749

48-
fig.text(0.05, 0.960, "GEOINT-COP · COMMON OPERATING PICTURE",
49-
fontsize=16, fontweight="bold")
50+
fig.text(
51+
0.05,
52+
0.960,
53+
"GEOINT-COP · COMMON OPERATING PICTURE",
54+
fontsize=16,
55+
fontweight="bold",
56+
)
5057
n_planes = counts.get("plane", 0)
5158
n_other = len(polys) - n_planes
52-
headline = f"{n_planes} aircraft detected" + (f" +{n_other} vehicles" if n_other else "")
53-
fig.text(0.95, 0.960, headline, ha="right",
54-
fontsize=14, fontweight="bold", color=ACC)
55-
fig.text(0.05, 0.922, "Overhead imagery → GPU detector (RT-DETR / YOLO-OBB) → "
56-
"georeferenced detections → AI SITREP + live ADS-B tracks",
57-
fontsize=10, color=DIM)
58-
fig.text(0.05, 0.012, f"scene center {lat:.4f}°N {abs(lon):.4f}°W · "
59-
f"NAIP imagery (USDA, public domain) · inference on CUDA",
60-
fontsize=8.5, color=DIM)
59+
headline = f"{n_planes} aircraft detected" + (
60+
f" +{n_other} vehicles" if n_other else ""
61+
)
62+
fig.text(0.95, 0.960, headline, ha="right", fontsize=14, fontweight="bold", color=ACC)
63+
fig.text(
64+
0.05,
65+
0.922,
66+
"Overhead imagery → GPU detector (RT-DETR / YOLO-OBB) → "
67+
"georeferenced detections → AI SITREP + live ADS-B tracks",
68+
fontsize=10,
69+
color=DIM,
70+
)
71+
fig.text(
72+
0.05,
73+
0.012,
74+
f"scene center {lat:.4f}°N {abs(lon):.4f}°W · "
75+
f"NAIP imagery (USDA, public domain) · inference on CUDA",
76+
fontsize=8.5,
77+
color=DIM,
78+
)
6179

6280
ax = fig.add_axes([0.07, 0.045, 0.86, 0.855])
6381
ax.imshow(rgb)
64-
ax.set_xticks([]); ax.set_yticks([])
82+
ax.set_xticks([])
83+
ax.set_yticks([])
6584
for s in ax.spines.values():
66-
s.set_edgecolor("#1b2740"); s.set_linewidth(1.5)
85+
s.set_edgecolor("#1b2740")
86+
s.set_linewidth(1.5)
6787

6888
for poly, conf in zip(polys, confs):
69-
ax.add_patch(Polygon(poly, closed=True, fill=False,
70-
edgecolor=ACC, linewidth=1.6))
89+
ax.add_patch(Polygon(poly, closed=True, fill=False, edgecolor=ACC, linewidth=1.6))
7190
x, y = poly[:, 0].min(), poly[:, 1].min()
7291
ax.text(x, y - 6, f"{conf:.0%}", fontsize=6.5, color=ACC, fontweight="bold")
7392

7493
# counts box
7594
lines = [f"{v} × {k}" for k, v in counts.most_common()]
76-
ax.text(0.985, 0.02, "DETECTIONS\n" + "\n".join(lines),
77-
transform=ax.transAxes, ha="right", va="bottom", fontsize=11,
78-
fontweight="bold", color=INK,
79-
bbox=dict(facecolor=BG, alpha=0.85, edgecolor=ACC, boxstyle="round,pad=0.5"))
95+
ax.text(
96+
0.985,
97+
0.02,
98+
"DETECTIONS\n" + "\n".join(lines),
99+
transform=ax.transAxes,
100+
ha="right",
101+
va="bottom",
102+
fontsize=11,
103+
fontweight="bold",
104+
color=INK,
105+
bbox=dict(facecolor=BG, alpha=0.85, edgecolor=ACC, boxstyle="round,pad=0.5"),
106+
)
80107

81108
os.makedirs("docs", exist_ok=True)
82109
fig.savefig("docs/hero.png", dpi=130, facecolor=BG)

0 commit comments

Comments
 (0)