Update theme toggle and pages
Browse filesFiles changed (4)
2 unmodified lines345667894 unmodified lines141516171817181920212 unmodified linesimport { useEffect, useState } from "react";
export default function ThemeToggle() { const [theme, setTheme] = useState("light"); const [theme, setTheme] = useState("dark"); const isDark = theme === "dark";
useEffect(() => {4 unmodified lines setTheme(stored); document.documentElement.classList.toggle("dark", stored === "dark"); } else { const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches; const initial = prefersDark ? "dark" : "light"; // Default to dark theme for a forensic look if no preference stored const initial = "dark"; setTheme(initial); document.documentElement.classList.toggle("dark", initial === "dark"); }67 unmodified lines68697071717273748 unmodified lines83848586868788899091929293949513 unmodified lines1091101111121121131141141151161173 unmodified lines1211221231241241251261272 unmodified lines1301311321331331341351361371381381391401411421431441451461451461471481491501511501511521531531541551561 unmodified line15815916016116116216316316416516616616716816917017017117217317417517617617717817967 unmodified lines
return ( <div className="min-h-screen"> <header className="bg-white border-b dark:bg-gray-900 dark:border-gray-800"> <header className="bg-slate-950 border-b border-emerald-900"> <div className="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between"> <h1 className="text-xl font-semibold">Analyze a Video</h1> <div className="flex items-center gap-3">8 unmodified lines </div> </header>
<main className="max-w-7xl mx-auto px-4 py-6 space-y-6"> <main className="max-w-7xl mx-auto px-4 py-6 space-y-6 text-emerald-50"> <div className="grid lg:grid-cols-2 gap-6 items-start"> <section className="space-y-4"> <div onDrop={onDrop} onDragOver={onDragOver} className="bg-white dark:bg-gray-800 border-dashed border-2 border-gray-200 dark:border-gray-700 rounded-xl p-6 shadow-sm flex flex-col items-center justify-center text-center cursor-pointer hover:border-blue-400 dark:hover:border-blue-500" className="bg-slate-950 border-dashed border-2 border-emerald-800 rounded-xl p-6 shadow-md shadow-emerald-900/40 flex flex-col items-center justify-center text-center cursor-pointer hover:border-emerald-500" onClick={() => fileInputRef.current?.click()} > <input13 unmodified lines {videoFile && ( <div className="w-full"> <div className="flex items-center justify-between mb-2"> <div className="text-sm text-gray-700 dark:text-gray-200 truncate"> <div className="text-sm text-emerald-50 truncate"> <span className="font-medium">Selected:</span> {videoFile.name} <span className="ml-2 text-gray-500 dark:text-gray-400">({Math.round(videoFile.size / 1024 / 1024)} MB)</span> <span className="ml-2 text-emerald-300/70">({Math.round(videoFile.size / 1024 / 1024)} MB)</span> </div> <button type="button"3 unmodified lines </div> {previewUrl && ( <video className="w-full aspect-video bg-black rounded-lg" className="w-full aspect-video bg-black rounded-lg border border-emerald-900/80" src={previewUrl} controls />2 unmodified lines )} </div>
<form onSubmit={onSubmit} className="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-5 shadow-sm flex flex-col gap-3"> <form onSubmit={onSubmit} className="bg-slate-950 border border-emerald-900 rounded-xl p-5 shadow-md shadow-emerald-900/40 flex flex-col gap-3"> <div className="flex items-center gap-3"> <button type="submit" disabled={loading || !videoFile} className="px-4 py-2 rounded bg-blue-600 text-white disabled:opacity-50 inline-flex items-center gap-2" className="px-4 py-2 rounded bg-emerald-500 text-slate-950 disabled:opacity-50 inline-flex items-center gap-2 hover:bg-emerald-400" > {loading && ( <span className="inline-block h-4 w-4 border-2 border-white/50 border-t-white rounded-full animate-spin"></span> )} {loading ? "Processing..." : "Analyze Video"} </button> {error && <span className="text-red-500 dark:text-red-400 text-sm">{error}</span>} {!videoFile && <span className="text-sm text-gray-600 dark:text-gray-400">Select a video to start.</span>} {error && <span className="text-red-400 text-sm">{error}</span>} {!videoFile && <span className="text-sm text-emerald-200/80">Select a video to start.</span>} </div> {loading && ( <div className="w-full space-y-1"> <div className="h-1 w-full bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden"> <div className="h-full w-1/2 bg-blue-500 dark:bg-blue-400 animate-pulse" /> <div className="h-1 w-full bg-slate-800 rounded-full overflow-hidden"> <div className="h-full w-1/2 bg-gradient-to-r from-emerald-400 to-emerald-600 animate-pulse" /> </div> <p className="text-xs text-gray-500 dark:text-gray-400">Analyzing video, this may take a moment…</p> <p className="text-xs text-emerald-200/75">Analyzing video, this may take a moment…</p> </div> )} </form>1 unmodified line </section>
<aside className="space-y-4"> <div className="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-5 shadow-sm"> <div className="bg-slate-950 border border-emerald-900 rounded-xl p-5 shadow-md shadow-emerald-900/40"> <h2 className="text-lg font-semibold mb-2">Final Conclusion</h2> <p className="text-sm text-gray-600 dark:text-gray-400 mb-3">Aggregated across all extracted frames</p> <p className="text-sm text-emerald-200/80 mb-3">Aggregated across all extracted frames</p> {result ? ( <div className="flex items-center gap-3 mb-3"> <span className={`px-3 py-1.5 rounded text-white text-sm ${result.final_label === 'fake' ? 'bg-red-500' : 'bg-green-600'}`}> <span className={`px-3 py-1.5 rounded text-xs tracking-wide font-mono ${result.final_label === 'fake' ? 'bg-red-500 text-white' : 'bg-emerald-500 text-slate-950'}`}> {result.final_label.toUpperCase()} </span> {result.final_label === 'fake' && ( <span className="text-sm text-gray-700 dark:text-gray-300"> <span className="text-sm text-emerald-200/80"> avg fake prob: {result.final_score.toFixed(3)} </span> )} </div> ) : ( <div className="text-sm text-gray-500 dark:text-gray-400 mb-3">Run analysis to see results here.</div> <div className="text-sm text-emerald-300/70 mb-3">Run analysis to see results here.</div> )} {result && ( <div className="border-t border-gray-200 dark:border-gray-700 mt-3 pt-3 max-h-[480px] overflow-y-auto">2 unmodified lines34567678910119101112131415161718192 unmodified lines222324202122252627282930313224253334353637383927282940414243443132334546474849505135363738395253545556575859606162434445636465666768697071727374757677474849787980818283848586878889909192939495961 unmodified line989910057585960616263646566671011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351366970717213713813914014114214314414514614714814915015115215315415515615715815916016116216316478791651661671681691701711722 unmodified lines
export default function Landing() { return ( <div className="min-h-screen flex flex-col bg-radial-fade"> <header className="bg-white/80 backdrop-blur border-b dark:bg-gray-900/70 dark:border-gray-800"> <div className="min-h-screen flex flex-col bg-slate-950 text-emerald-50 bg-radial-fade"> <header className="border-b border-emerald-800/60 bg-slate-950/80 backdrop-blur"> <div className="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between"> <div className="flex items-center gap-2"> <div className="h-8 w-8 rounded bg-blue-600 text-white flex items-center justify-center font-bold">DF</div> <span className="text-lg font-semibold">Deepfake Detector</span> <div className="flex items-center gap-3"> <div className="h-9 w-9 rounded-lg bg-emerald-500/20 border border-emerald-500/70 flex items-center justify-center text-emerald-300 font-mono text-sm"> FF </div> <div className="flex flex-col leading-tight"> <span className="text-sm uppercase tracking-[0.2em] text-emerald-400/80">FaceForensics Lab</span> <span className="text-lg font-semibold">Deepfake Detection Console</span> </div> </div> <div className="flex items-center gap-3"> <ThemeToggle />2 unmodified lines </header>
<main className="flex-1"> <section className="relative overflow-hidden"> <div className="absolute inset-0 bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-gray-900 dark:to-gray-950" /> <div className="relative max-w-7xl mx-auto px-4 py-20 grid md:grid-cols-2 gap-10 items-center"> <section className="relative overflow-hidden border-b border-emerald-900/60"> <div className="absolute inset-0 pointer-events-none"> <div className="absolute inset-0 opacity-20 bg-[radial-gradient(circle_at_top,_#22c55e33,_transparent_60%)]" /> <div className="absolute inset-0 opacity-[0.07] bg-[linear-gradient(to_right,#10b981_10%,transparent_10%),linear-gradient(to_bottom,#10b981_10%,transparent_10%)] bg-[length:20px_20px]" /> </div>
<div className="relative max-w-7xl mx-auto px-4 py-16 md:py-20 grid md:grid-cols-2 gap-10 items-center"> <div> <h1 className="text-4xl md:text-5xl font-bold leading-tight"> Detect Deepfakes with Frame-by-Frame Precision <p className="text-xs font-mono uppercase tracking-[0.35em] text-emerald-400/80"> Real-time video forensics </p> <h1 className="mt-3 text-4xl md:text-5xl font-semibold leading-tight"> Inspect every frame. <span className="block text-emerald-400">Unmask every fake.</span> </h1> <p className="mt-4 text-gray-600 dark:text-gray-300 max-w-prose"> Upload a video to analyze each frame with our AI model and get a transparent, per-frame breakdown plus an overall verdict. <p className="mt-4 text-sm md:text-base text-emerald-100/80 max-w-prose"> DeepDetection runs your video through a FaceForensics-inspired pipeline: we sample frames, isolate faces with YOLO, classify them with a fine-tuned ResNet18, and roll everything up into a clear, explainable verdict. </p> <div className="mt-8"> <Link href="/analyze" className="px-5 py-3 rounded bg-blue-600 text-white font-medium shadow hover:bg-blue-700"> Analyze a Video <div className="mt-8 flex flex-wrap items-center gap-4"> <Link href="/analyze" className="px-5 py-3 rounded-lg bg-emerald-500 text-slate-950 font-medium shadow-lg shadow-emerald-500/30 hover:bg-emerald-400 transition" > Launch Analyzer </Link> </div> <div className="mt-6 flex items-center gap-6 text-xs text-gray-600 dark:text-gray-400"> <div className="flex items-center gap-2"><span>🧠</span><span>ResNet18 (2‑class head)</span></div> <div className="flex items-center gap-2"><span>🖼️</span><span>224×224 • ImageNet norm</span></div> <div className="flex items-center gap-2"><span>📊</span><span>Softmax per‑frame • majority vote</span></div> <div className="text-xs text-emerald-200/80 font-mono"> <div className="flex items-center gap-2"> <span className="h-2 w-2 rounded-full bg-emerald-400 animate-pulse" /> <span>Pipeline: FaceForensics++ → YOLOv8-face → ResNet18</span> </div> <div className="mt-1 opacity-70">No training UI – this is your forensic viewer.</div> </div> </div> </div>
<div className="relative"> <div className="rounded-2xl border border-gray-200 bg-white shadow p-4 dark:bg-gray-800 dark:border-gray-700"> <div className="aspect-video rounded-lg bg-gray-100 flex items-center justify-center text-gray-500 dark:bg-gray-700 dark:text-gray-300"> Upload a video to start <div className="rounded-2xl border border-emerald-700/60 bg-slate-950/60 shadow-[0_0_40px_rgba(16,185,129,0.25)] p-4"> <div className="aspect-video rounded-xl bg-slate-900/70 border border-emerald-900/80 flex flex-col justify-between p-4"> <div className="flex items-center justify-between text-xs text-emerald-200/80 font-mono"> <span>video_feed.mp4</span> <span className="px-2 py-0.5 rounded-full bg-emerald-500/10 border border-emerald-500/40 text-[10px]"> LIVE ANALYSIS </span> </div> <div className="flex-1 flex items-center justify-center text-emerald-300/80 text-xs"> Drop a video in the analyzer to see per-frame labels. </div> <div className="mt-3 h-1.5 w-full rounded-full bg-slate-800 overflow-hidden"> <div className="h-full w-1/2 bg-gradient-to-r from-emerald-400 to-emerald-600 animate-pulse" /> </div> </div> <div className="mt-4 grid grid-cols-4 gap-2"> {Array.from({ length: 8 }).map((_, i) => ( <div key={i} className="h-16 bg-gray-100 rounded dark:bg-gray-700" />
<div className="mt-4 grid grid-cols-5 gap-2 text-[10px] text-emerald-100/80 font-mono"> {[ "Frame sampling", "YOLOv8-face", "Face crops", "ResNet18 logits", "Video verdict", ].map((label, i) => ( <div key={label} className="rounded-lg border border-emerald-700/60 bg-slate-950/80 px-2 py-2 flex flex-col gap-1" > <span className="text-[9px] uppercase tracking-wide text-emerald-500/90">Step {i + 1}</span> <span>{label}</span> </div> ))} </div> </div>1 unmodified line </div> </section>
<section className="max-w-7xl mx-auto px-4 py-12"> <div className="grid md:grid-cols-3 gap-6"> <div className="p-5 rounded-xl border border-gray-200 bg-white shadow-sm dark:bg-gray-800 dark:border-gray-700"> <div className="text-sm uppercase tracking-wide text-gray-500 dark:text-gray-400">Architecture</div> <div className="mt-1 font-medium">ResNet18 • 2-class head</div> <div className="mt-1 text-sm text-gray-600 dark:text-gray-400">Weights: bestresnetclassweights.pth</div> </div> <div className="p-5 rounded-xl border border-gray-200 bg-white shadow-sm dark:bg-gray-800 dark:border-gray-700"> <div className="text-sm uppercase tracking-wide text-gray-500 dark:text-gray-400">Preprocessing</div> <div className="mt-1 font-medium">Resize 224×224 • RGB</div> <div className="mt-1 text-sm text-gray-600 dark:text-gray-400">Normalize mean [0.485,0.456,0.406], std [0.229,0.224,0.225]</div> <section className="max-w-7xl mx-auto px-4 py-12 md:py-16"> <div className="max-w-3xl"> <h2 className="text-xl md:text-2xl font-semibold">How the workflow fits together</h2> <p className="mt-3 text-sm md:text-base text-emerald-100/75"> The system mirrors a typical FaceForensics-style research pipeline, but wraps it in a focused inspection UI. Each stage hands clean information to the next so you can see exactly how the final verdict was formed. </p> </div>
<div className="mt-8 space-y-6"> <div className="grid md:grid-cols-5 gap-4 text-xs md:text-sm font-mono"> <div className="md:col-span-1 rounded-lg border border-emerald-700/60 bg-slate-950/80 p-3"> <div className="text-[10px] uppercase tracking-wide text-emerald-400/90">1 · Input</div> <div className="mt-1 font-semibold">Upload video</div> <p className="mt-1 text-emerald-100/70">MP4 video is streamed into the analyzer – nothing is stored.</p> </div> <div className="hidden md:flex items-center justify-center text-2xl text-emerald-500">➜</div> <div className="md:col-span-1 rounded-lg border border-emerald-700/60 bg-slate-950/80 p-3"> <div className="text-[10px] uppercase tracking-wide text-emerald-400/90">2 · Sampling</div> <div className="mt-1 font-semibold">20 frame slices</div> <p className="mt-1 text-emerald-100/70">Uniformly sample ~20 frames across the full duration.</p> </div> <div className="hidden md:flex items-center justify-center text-2xl text-emerald-500">➜</div> <div className="md:col-span-1 rounded-lg border border-emerald-700/60 bg-slate-950/80 p-3"> <div className="text-[10px] uppercase tracking-wide text-emerald-400/90">3 · Detection</div> <div className="mt-1 font-semibold">YOLOv8-face</div> <p className="mt-1 text-emerald-100/70">Run a face detector on each frame and crop faces at 299×299.</p> </div> <div className="hidden md:flex items-center justify-center text-2xl text-emerald-500">➜</div> <div className="md:col-span-1 rounded-lg border border-emerald-700/60 bg-slate-950/80 p-3"> <div className="text-[10px] uppercase tracking-wide text-emerald-400/90">4 · Classification</div> <div className="mt-1 font-semibold">ResNet18 · REAL/FAKE</div> <p className="mt-1 text-emerald-100/70">Faces are normalized (ImageNet style) and passed to a 2‑class head.</p> </div> </div> <div className="p-5 rounded-xl border border-gray-200 bg-white shadow-sm dark:bg-gray-800 dark:border-gray-700"> <div className="text-sm uppercase tracking-wide text-gray-500 dark:text-gray-400">Inference</div> <div className="mt-1 font-medium">Softmax per-frame</div> <div className="mt-1 text-sm text-gray-600 dark:text-gray-400">Final: majority vote • avg confidence</div>
<div className="grid md:grid-cols-3 gap-4 text-xs md:text-sm font-mono"> <div className="rounded-lg border border-emerald-700/60 bg-slate-950/80 p-3"> <div className="text-[10px] uppercase tracking-wide text-emerald-400/90">5 · Per‑frame report</div> <p className="mt-1 text-emerald-100/70"> Each sampled frame gets a REAL/FAKE label plus calibrated probabilities, shown as a grid of cropped faces. </p> </div> <div className="rounded-lg border border-emerald-700/60 bg-slate-950/80 p-3"> <div className="text-[10px] uppercase tracking-wide text-emerald-400/90">6 · Video verdict</div> <p className="mt-1 text-emerald-100/70"> We aggregate over frames with detected faces to compute a final REAL/FAKE decision and overall fake probability. </p> </div> <div className="rounded-lg border border-emerald-700/60 bg-slate-950/80 p-3"> <div className="text-[10px] uppercase tracking-wide text-emerald-400/90">7 · Investigator view</div> <p className="mt-1 text-emerald-100/70"> The UI is tuned for inspection – quickly scan frames, zoom in on suspicious ones, and correlate with the final verdict. </p> </div> </div> </div> </section> </main>
<footer className="text-center text-xs text-gray-500 dark:text-gray-400 py-8 border-t bg-white dark:bg-gray-900 dark:border-gray-800"> © {new Date().getFullYear()} Deepfake Detector • <Link className="text-blue-600" href="/analyze">Start Analysis</Link> <footer className="text-center text-xs text-emerald-300/70 py-6 border-t border-emerald-900 bg-slate-950/95"> © {new Date().getFullYear()} DeepDetection • FaceForensics-inspired workflow ·{' '} <Link className="text-emerald-400 hover:text-emerald-300" href="/analyze"> Start analysis </Link> </footer> </div> );3 unmodified lines4567891011121314158161718193 unmodified lines content: ["./pages/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}"], theme: { extend: { colors: { forensic: { bg: "#020617", // slate-950 panel: "#020c1b", accent: "#22c55e", // emerald-500 accentSoft: "#064e3b", // emerald-900 }, }, backgroundImage: { 'radial-fade': 'radial-gradient(1200px 600px at 80% -10%, rgba(59,130,246,0.15), transparent 70%)', 'radial-fade': 'radial-gradient(1200px 600px at 80% -10%, rgba(16,185,129,0.22), transparent 70%)', }, }, },frontend/components/ThemeToggle.jsx+3-3
frontend/pages/analyze.jsx+18-18
frontend/pages/index.jsx+134-44
frontend/tailwind.config.js+9-1