Deepfake Authenticator commited on
Commit ·
112ba45
1
Parent(s): 31c9c07
fix: frame timeline empty — use frame_timeline field with fake_pct
Browse files- frontend/script.js +11 -8
frontend/script.js
CHANGED
|
@@ -269,7 +269,8 @@ function renderTimeline(data, isFake) {
|
|
| 269 |
if (!chart) return;
|
| 270 |
chart.innerHTML = '';
|
| 271 |
|
| 272 |
-
|
|
|
|
| 273 |
if (!frames.length) {
|
| 274 |
chart.innerHTML = '<span style="font-size:11px;color:var(--muted);font-family:\'JetBrains Mono\',monospace;margin:auto;">No per-frame data available</span>';
|
| 275 |
return;
|
|
@@ -279,9 +280,12 @@ function renderTimeline(data, isFake) {
|
|
| 279 |
const barColor = isFake ? '#ff3355' : '#00ff88';
|
| 280 |
const barGlow = isFake ? 'rgba(255,51,85,0.5)' : 'rgba(0,255,136,0.5)';
|
| 281 |
|
| 282 |
-
frames.forEach((
|
| 283 |
-
|
| 284 |
-
const
|
|
|
|
|
|
|
|
|
|
| 285 |
|
| 286 |
const wrap = document.createElement('div');
|
| 287 |
wrap.className = 'bar-wrap';
|
|
@@ -294,22 +298,21 @@ function renderTimeline(data, isFake) {
|
|
| 294 |
const inner = document.createElement('div');
|
| 295 |
inner.className = 'bar-inner';
|
| 296 |
inner.style.height = '0px';
|
| 297 |
-
inner.style.background =
|
| 298 |
? `linear-gradient(to top, ${barColor}, rgba(255,255,255,0.3))`
|
| 299 |
: 'rgba(255,255,255,0.12)';
|
| 300 |
-
if (
|
| 301 |
|
| 302 |
outer.appendChild(inner);
|
| 303 |
|
| 304 |
const tip = document.createElement('div');
|
| 305 |
tip.className = 'bar-tooltip';
|
| 306 |
-
tip.textContent = `
|
| 307 |
|
| 308 |
wrap.appendChild(outer);
|
| 309 |
wrap.appendChild(tip);
|
| 310 |
chart.appendChild(wrap);
|
| 311 |
|
| 312 |
-
// Animate in
|
| 313 |
setTimeout(() => { inner.style.height = h + 'px'; }, 50 + i * 20);
|
| 314 |
});
|
| 315 |
|
|
|
|
| 269 |
if (!chart) return;
|
| 270 |
chart.innerHTML = '';
|
| 271 |
|
| 272 |
+
// Backend sends frame_timeline: [{frame, fake_pct}, ...]
|
| 273 |
+
const frames = data.frame_timeline || data.frame_scores || [];
|
| 274 |
if (!frames.length) {
|
| 275 |
chart.innerHTML = '<span style="font-size:11px;color:var(--muted);font-family:\'JetBrains Mono\',monospace;margin:auto;">No per-frame data available</span>';
|
| 276 |
return;
|
|
|
|
| 280 |
const barColor = isFake ? '#ff3355' : '#00ff88';
|
| 281 |
const barGlow = isFake ? 'rgba(255,51,85,0.5)' : 'rgba(0,255,136,0.5)';
|
| 282 |
|
| 283 |
+
frames.forEach((point, i) => {
|
| 284 |
+
// Support both {fake_pct: 72.1} and {fake_probability: 0.721}
|
| 285 |
+
const pct = point.fake_pct != null ? point.fake_pct : (point.fake_probability * 100);
|
| 286 |
+
const score = pct / 100;
|
| 287 |
+
const h = Math.max(4, Math.round(score * maxH));
|
| 288 |
+
const hot = pct >= 60;
|
| 289 |
|
| 290 |
const wrap = document.createElement('div');
|
| 291 |
wrap.className = 'bar-wrap';
|
|
|
|
| 298 |
const inner = document.createElement('div');
|
| 299 |
inner.className = 'bar-inner';
|
| 300 |
inner.style.height = '0px';
|
| 301 |
+
inner.style.background = hot
|
| 302 |
? `linear-gradient(to top, ${barColor}, rgba(255,255,255,0.3))`
|
| 303 |
: 'rgba(255,255,255,0.12)';
|
| 304 |
+
if (hot) inner.style.boxShadow = `0 0 8px ${barGlow}`;
|
| 305 |
|
| 306 |
outer.appendChild(inner);
|
| 307 |
|
| 308 |
const tip = document.createElement('div');
|
| 309 |
tip.className = 'bar-tooltip';
|
| 310 |
+
tip.textContent = `Frame ${point.frame != null ? point.frame : i}: ${pct.toFixed(1)}%`;
|
| 311 |
|
| 312 |
wrap.appendChild(outer);
|
| 313 |
wrap.appendChild(tip);
|
| 314 |
chart.appendChild(wrap);
|
| 315 |
|
|
|
|
| 316 |
setTimeout(() => { inner.style.height = h + 'px'; }, 50 + i * 20);
|
| 317 |
});
|
| 318 |
|