Skip to content

Commit ac2bedc

Browse files
committed
measurement scripts must read the settings that are actually running
Both scripts read config.yaml only, while the service layers data/settings.json on top - so a scheduled comparison would have measured threshold 0.50 and k=3 while the service ran 0.45 and k=1.
1 parent d165b4e commit ac2bedc

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

scripts/coverage.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ def match(gal, e, drop_slug, drop_idx):
6868
return best_slug, best
6969

7070

71+
def load_config(base: Path) -> dict:
72+
"""config.yaml plus die in der UI gesetzten Werte aus data/settings.json.
73+
74+
Der Dienst legt settings.json ueber die config — ohne das misst ein Skript
75+
andere Schwellen als die, die tatsaechlich laufen.
76+
"""
77+
cfg = yaml.safe_load((base / "config.yaml").read_text())
78+
sf = base / "data" / "settings.json"
79+
if sf.exists():
80+
try:
81+
cfg.setdefault("faceid", {}).update(json.loads(sf.read_text()))
82+
except (OSError, json.JSONDecodeError):
83+
pass
84+
return cfg
85+
86+
7187
def main():
7288
ap = argparse.ArgumentParser()
7389
ap.add_argument("--data", default=str(BASE / "data"))
@@ -76,8 +92,10 @@ def main():
7692
sys.path.insert(0, str(BASE))
7793
from app.engine import FaceEngine
7894

79-
cfg = yaml.safe_load((BASE / "config.yaml").read_text())
95+
cfg = load_config(BASE)
8096
thr = float(cfg["faceid"].get("match_threshold", 0.5))
97+
global TOP_K
98+
TOP_K = max(1, int(cfg["faceid"].get("match_top_k", 3)))
8199
eng = FaceEngine(det_size=int(cfg["faceid"].get("det_size", 640)))
82100

83101
persons = Path(args.data) / "persons"

scripts/measure-recognition.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,22 @@ def live_probe(gal_old, gal_new, days, thr, cfg):
154154
"selfhits": selfhits}
155155

156156

157+
def load_config(base: Path) -> dict:
158+
"""config.yaml plus die in der UI gesetzten Werte aus data/settings.json.
159+
160+
Der Dienst legt settings.json ueber die config — ohne das misst ein Skript
161+
andere Schwellen als die, die tatsaechlich laufen.
162+
"""
163+
cfg = yaml.safe_load((base / "config.yaml").read_text())
164+
sf = base / "data" / "settings.json"
165+
if sf.exists():
166+
try:
167+
cfg.setdefault("faceid", {}).update(json.loads(sf.read_text()))
168+
except (OSError, json.JSONDecodeError):
169+
pass
170+
return cfg
171+
172+
157173
def main():
158174
ap = argparse.ArgumentParser()
159175
ap.add_argument("--baseline", help="Pfad zu einer aelteren Galerie (entpacktes Backup)")
@@ -162,12 +178,14 @@ def main():
162178
ap.add_argument("--top-k", type=int, help="match_top_k zum Vergleich uebersteuern")
163179
args = ap.parse_args()
164180

181+
global TOP_K
165182
if args.top_k:
166-
global TOP_K
167183
TOP_K = max(1, args.top_k)
168184

169-
cfg = yaml.safe_load((BASE / "config.yaml").read_text())
185+
cfg = load_config(BASE)
170186
thr = float(cfg["faceid"].get("match_threshold", 0.5))
187+
if not args.top_k:
188+
TOP_K = max(1, int(cfg["faceid"].get("match_top_k", 3)))
171189
new = load_gallery(Path(args.data) / "persons")
172190
if not new:
173191
print("keine Galerie gefunden", file=sys.stderr)

0 commit comments

Comments
 (0)