Fix no face detected validation
Browse filesFiles changed (2)
12345678910111213141516171819202122232423 unmodified lines48495051525354export default function FrameGrid({ frames = [], predictions = [], onFrameClick }) {const items = frames.map((frame, idx) => {const pred = predictions[idx] || {};const label = (pred.label || "").toLowerCase();const score = typeof pred.score === "number" ? pred.score : pred.prob_fake ?? pred.prob ?? 0;const hasFace = pred.has_face ?? pred.hasFace ?? true;// frame may be raw base64 or full data URLconst src = frame?.startsWith("data:") ? frame : `data:image/png;base64,${frame || ""}`;const badgeClass =label === "fake"? "bg-red-500/90 text-white": label === "real"? "bg-green-600/90 text-white": "bg-gray-400 text-white";return {idx,src,label,score,hasFace,badgeClass,23 unmodified lines<div className="w-full h-full flex items-center justify-center text-xs md:text-sm text-gray-400">No image</div>)}<span className={`absolute top-1 left-1 px-2 py-0.5 rounded text-[11px] md:text-xs font-semibold ${item.badgeClass}`}>{item.label ? item.label.toUpperCase() : "N/A"}</span></div><div className="px-2 py-1.5 flex items-center justify-between text-[12px] md:text-sm text-emerald-100/80">1234567891011121314151617181920212223242526272829303123 unmodified lines55565758596061export default function FrameGrid({ frames = [], predictions = [], onFrameClick }) {const items = frames.map((frame, idx) => {const pred = predictions[idx] || {};const rawLabel = (pred.label || "").toLowerCase();const score = typeof pred.score === "number" ? pred.score : pred.prob_fake ?? pred.prob ?? 0;const faceFlag = pred.has_face ?? pred.hasFace;const hasFace = typeof faceFlag === "boolean" ? faceFlag : !(rawLabel === "no face" || rawLabel === "no_face");// frame may be raw base64 or full data URLconst src = frame?.startsWith("data:") ? frame : `data:image/png;base64,${frame || ""}`;const { badgeClass, displayLabel } = (() => {if (!hasFace) {return { badgeClass: "bg-slate-700/90 text-white", displayLabel: "NO FACE" };}if (rawLabel === "fake") {return { badgeClass: "bg-red-500/90 text-white", displayLabel: "FAKE" };}if (rawLabel === "real") {return { badgeClass: "bg-green-600/90 text-white", displayLabel: "REAL" };}return { badgeClass: "bg-gray-500 text-white", displayLabel: "N/A" };})();return {idx,src,label: displayLabel,score,hasFace,badgeClass,23 unmodified lines<div className="w-full h-full flex items-center justify-center text-xs md:text-sm text-gray-400">No image</div>)}<span className={`absolute top-1 left-1 px-2 py-0.5 rounded text-[11px] md:text-xs font-semibold ${item.badgeClass}`}>{item.label}</span></div><div className="px-2 py-1.5 flex items-center justify-between text-[12px] md:text-sm text-emerald-100/80">
201 unmodified lines202203204205206207201 unmodified lines<h2 className="text-xl md:text-2xl font-semibold mb-1">Final conclusion</h2>{result ? ((() => {const rawScore =typeof result.final_score === "number"? result.final_score201 unmodified lines202203204205206207208209210211212213214215216217218219220221222223224225226227228201 unmodified lines<h2 className="text-xl md:text-2xl font-semibold mb-1">Final conclusion</h2>{result ? ((() => {const predictions = Array.isArray(result.predictions) ? result.predictions : [];const hasAnyFace = predictions.some((pred = {}) => {const flag = pred.has_face ?? pred.hasFace;if (typeof flag === "boolean") return flag;const lbl = (pred.label || "").toLowerCase();return lbl !== "no face" && lbl !== "no_face";});if (!hasAnyFace) {return (<div className="flex-1 flex flex-col items-center justify-center text-sm md:text-base text-emerald-200/80 space-y-2"><span className="px-3 py-1 rounded-full bg-slate-900 border border-emerald-800 text-xs md:text-sm font-mono">No faces detected</span><p className="max-w-sm text-emerald-300/80">None of the sampled frames contained a detectable face, so we cannot compute a reliable verdict.</p></div>);}const rawScore =typeof result.final_score === "number"? result.final_score
frontend/components/FrameGrid.jsx+17-10
frontend/pages/analyze.jsx+21