Add circular bar to analyze
Browse files202 unmodified lines203204205206206207208209210211212209213214211215216217218219220213221222215216223224225218219220221222223224226227228229230231232233234235236237238239240241242243244245246247248249250251232233234252253254202 unmodified lines <p className="text-sm text-emerald-200/80 mb-3">Overall confidence based on all faces found.</p> {result ? ( (() => { const fakeProb = typeof result.final_score === "number" ? result.final_score : 0; const rawScore = typeof result.final_score === "number" ? result.final_score : Number(result.final_score) || 0; const fakeProb = Math.max(0, Math.min(1, rawScore)); const realProb = 1 - fakeProb; const isFake = result.final_label === "fake"; const percent = Math.round((isFake ? fakeProb : realProb) * 100); const percent = Math.round(fakeProb * 100); const labelText = isFake ? "FAKE" : "REAL"; const barColor = isFake ? "bg-red-500" : "bg-emerald-500"; const primaryColor = isFake ? "#ef4444" : "#22c55e"; // red-500 or emerald-500 const trackColor = "#020617"; // slate-950 const safePercent = isNaN(percent) ? 0 : Math.max(0, Math.min(100, percent)); const angle = (safePercent / 100) * 360;
return ( <div className="space-y-3"> <div className="space-y-4"> <div className="flex items-center justify-between text-xs font-mono text-emerald-200/80"> <span>{labelText} confidence</span> <span>{isNaN(percent) ? '-' : `${percent}%`}</span> <span>Fake probability</span> <span>{isNaN(percent) ? "-" : `${safePercent}%`}</span> </div> <div className="flex items-end gap-4 h-28"> <div className="flex-1 flex items-end justify-center"> <div className="h-full w-4 rounded-full bg-slate-800 overflow-hidden border border-slate-700"> <div className={`${barColor} w-full transition-all`} style={{ height: `${Math.max(0, Math.min(100, isNaN(percent) ? 0 : percent))}%` }} />
<div className="flex items-center gap-5"> <div className="relative h-28 w-28 rounded-full flex items-center justify-center mx-auto" style={{ background: `conic-gradient(${primaryColor} ${angle}deg, ${trackColor} ${angle}deg)`, }} > <div className="h-20 w-20 rounded-full bg-slate-950 flex flex-col items-center justify-center border border-slate-700"> <span className="text-[10px] font-mono text-emerald-200/80"> {labelText} </span> <span className="text-sm font-semibold"> {isNaN(percent) ? "-" : `${safePercent}%`} </span> </div> </div>
<div className="text-[11px] text-emerald-200/80 space-y-1"> <div>REAL: {realProb.toFixed(3)}</div> <div>FAKE: {fakeProb.toFixed(3)}</div> <div className="text-emerald-300/80 text-[10px]"> Circle shows how much of the model's belief is fake. </div> </div> </div> <p className="text-xs text-emerald-300/80"> Taller bar means stronger confidence that this video is {labelText.toLowerCase()}. </p> </div> ); })()frontend/pages/analyze.jsx+33-16