comparaison.py: the end-of-session page of /boucle is now the detecteurs.py page, with the analyst's bars above the detectors'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e665e761a
commit
eca278279d
4 files changed
+46
-74
No files matched your search
@@ -94,7 +94,7 @@ document.getElementById('gif-av').onclick = () => { joue(false); image(G.k - 1);
|
||||
document.getElementById('gif-ap').onclick = () => { joue(false); image(G.k + 1); };
|
||||
gd.on('plotly_click', ev => {
|
||||
const p = ev.points[0];
|
||||
if (p.data.name === 'Détecteurs') return gif(p.customdata);
|
||||
if (p.customdata) return gif(p.customdata); // la barre d'un événement (détecteurs ou analyste)
|
||||
const x = ms(String(p.x));
|
||||
let best = 0;
|
||||
IM.forEach((m, i) => { if (Math.abs(ms(m.t) - x) < Math.abs(ms(IM[best].t) - x)) best = i; });
|
||||
@@ -104,8 +104,10 @@ montre(0);
|
||||
"""
|
||||
|
||||
|
||||
def page(dossier, du=None, au=None, entete="", annexe="", chemin=None):
|
||||
"""entete, annexe : HTML ajouté avant et après la figure (page de /revue-cas) ; chemin : la page, sinon out/detecteurs_…."""
|
||||
def page(dossier, du=None, au=None, entete="", annexe="", chemin=None, analyste=()):
|
||||
"""entete, annexe : HTML ajouté avant et après la figure (page de /revue-cas) ; chemin : la page, sinon out/detecteurs_… ;
|
||||
analyste : ses moments [(début, fin, catégorie, survol)], en barres au-dessus de celles des détecteurs, chaque ligne de
|
||||
catégorie dédoublée (page de fin de séance de /boucle, comparaison.py)."""
|
||||
mesures = score.charger(dossier)
|
||||
if not mesures:
|
||||
raise SystemExit(f"Aucun export « advanced » dans {dossier}.")
|
||||
@@ -120,8 +122,11 @@ def page(dossier, du=None, au=None, entete="", annexe="", chemin=None):
|
||||
evts = score.evenements(mesures, score.iso(a), score.iso(b))
|
||||
spans = [(v["start"], v["end"], v["category"],
|
||||
comparaison.survol(v["label"], v["start"], v["end"], v["sensors"], v["text"])) for v in evts]
|
||||
presentes = {v["category"] for v in evts}
|
||||
ordre = [c for c in [*score.categories.CATEGORIES, *sorted(presentes - set(score.categories.CATEGORIES))] if c in presentes]
|
||||
hors = comparaison.HORS
|
||||
presentes = {v["category"] for v in evts} | {s[2] for s in analyste}
|
||||
ordre = [c for c in [*score.categories.CATEGORIES, *sorted(presentes - set(score.categories.CATEGORIES) - {hors}), hors]
|
||||
if c in presentes]
|
||||
haut = 40 if analyste else 30 # deux barres par ligne avec l'analyste
|
||||
station = os.path.basename(os.path.normpath(dossier))
|
||||
nom = f"{station}_{score.iso(a)[:10]}_{score.iso(b)[:10]}"
|
||||
chemin = chemin or os.path.join(ROOT, "out", f"detecteurs_{nom}.html")
|
||||
@@ -131,9 +136,10 @@ def page(dossier, du=None, au=None, entete="", annexe="", chemin=None):
|
||||
poses = [p for p in donnees.charger_camera(dossier) if a <= p["t"] < b]
|
||||
c = 1 if poses else 0 # la ligne de la caméra, seulement si le dossier a des poses sur la plage
|
||||
fig = make_subplots(rows=4 + c, cols=1, shared_xaxes=True, vertical_spacing=0.025,
|
||||
row_heights=[200] * c + [260, 260, 30 * len(ordre) + 20, 30],
|
||||
row_heights=[200] * c + [260, 260, haut * len(ordre) + 20, 30],
|
||||
subplot_titles=(*["Caméra : pan, tilt, rotation (deg)"] * c, "corr_x (px)", "corr_y (px)",
|
||||
"Événements des détecteurs, par catégorie", ""))
|
||||
"Classification : analyste (bleu, en haut ; gris : hors catégorie), détecteurs (orange, en bas)"
|
||||
if analyste else "Événements des détecteurs, par catégorie", ""))
|
||||
for col, couleur in POSE if poses else ():
|
||||
fig.add_trace(go.Scatter(x=[p["t"] for p in poses], y=[p[col] for p in poses], name=col, mode="lines",
|
||||
line={"width": 1.2, "color": couleur}, hovertemplate=f"{col} : %{{y:.4f}}°<extra></extra>"), row=1, col=1)
|
||||
@@ -150,9 +156,17 @@ def page(dossier, du=None, au=None, entete="", annexe="", chemin=None):
|
||||
d.customdata = [[v["start"], score.iso(score.instant(v["end"]) + pas), v["label"]] for v in evts] # le clic : son timelapse
|
||||
if images:
|
||||
d.hovertext = [h + "<br><i>clic : timelapse des images</i>" for h in d.hovertext]
|
||||
fig.add_trace(d, row=3 + c, col=1)
|
||||
fig.add_trace(d, row=3 + c, col=1) # en mode group, le 1er groupe en bas
|
||||
for nom_a, couleur, rang, sel in (("Analyste", comparaison.AGENT, 2, [s for s in analyste if s[2] != hors]),
|
||||
(f"Analyste, {hors}", comparaison.GRIS, 3, [s for s in analyste if s[2] == hors])):
|
||||
if sel:
|
||||
t = comparaison.barres(nom_a, couleur, sel, pas, rang, "a")
|
||||
t.customdata = [[s[0], score.iso(score.instant(s[1]) + pas), f"Analyste : {s[2]}"] for s in sel]
|
||||
if images:
|
||||
t.hovertext = [h + "<br><i>clic : timelapse des images</i>" for h in t.hovertext]
|
||||
fig.add_trace(t, row=3 + c, col=1)
|
||||
fig.add_trace(comparaison.taux_erreur(mesures, a, b), row=4 + c, col=1)
|
||||
fig.update_layout(bargap=0.3, height=680 + 230 * c + 30 * len(ordre), hovermode="closest",
|
||||
fig.update_layout(barmode="group", bargap=0.3, bargroupgap=0.1, height=680 + 230 * c + haut * len(ordre), hovermode="closest",
|
||||
plot_bgcolor="white", margin={"l": 170, "r": 90, "t": 40, "b": 40},
|
||||
legend={"orientation": "h", "x": 0, "y": 1.02, "yanchor": "bottom", # au-dessus : à droite, la barre de l'Error rate
|
||||
"title": {"text": "clic : cacher, double clic : seul", "side": "top left"}})
|
||||
|
||||
Reference in new issue
Block a user