import React from 'react'; import { BarChart3, RotateCcw, X, Maximize2, Minimize2 } from 'lucide-react'; import { Radar, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, ResponsiveContainer, Tooltip as RechartsTooltip, BarChart, Bar, XAxis, YAxis, Cell } from 'recharts'; import TestDefinition from '../ui/TestDefinition'; const API_BASE = import.meta.env.VITE_API_URL || 'http://127.0.0.1:8000'; const FeaturesTab = ({ result, expandedCards, hiddenCards, toggleExpand, hideCard, restoreCards, getScoreColor, isVideo, }) => { return ( <>
{Object.keys(hiddenCards).some(k => hiddenCards[k]) && ( )}
{/* 1. DETECTOR SCORES (Col 1, spans 2 rows) */} {!hiddenCards['detector'] && (
Detector Scores
Ensemble Inputs
{[ { label: 'EfficientNet-B4', score: result.nn_score, weight: result.weights?.nn_score }, { label: 'Frequency Analysis', score: result.spectral_anomaly_score, weight: result.weights?.spectral_score }, { label: 'Error Level Analysis', score: result.ela_score, weight: result.weights?.ela_score }, { label: 'Face Geometry', score: result.geometry_anomaly_score, weight: result.weights?.geometry_anomaly }, { label: 'Sensor Noise', score: result.noise_score, weight: result.weights?.noise_score }, { label: 'Chrominance', score: result.color_score, weight: result.weights?.color_score }, { label: 'Lighting', score: result.lighting_score, weight: result.weights?.lighting_score }, { label: 'CFA Pattern', score: result.cfa_score || 0, weight: result.weights?.cfa_score }, { label: 'Corneal Reflection', score: result.corneal_score || 0, weight: result.weights?.corneal_score }, ...(isVideo ? [{ label: 'Eye Tracking', score: result.eye_score || 0, weight: result.weights?.eye_score }] : []), ...(isVideo ? [{ label: 'Optical Flow', score: result.flow_score || 0, weight: result.weights?.flow_score }] : []), ...(isVideo && result.file_metadata?.has_audio ? [{ label: 'Audio Desync', score: result.sync_score, weight: result.weights?.sync_score }] : []), ...(isVideo && result.file_metadata?.has_audio ? [{ label: 'Voice Spoofing', score: result.voice_score || 0, weight: result.weights?.voice_score }] : []), ...(isVideo ? [{ label: 'Pulse (rPPG)', score: result.rppg_score, weight: result.weights?.rppg_score }] : []) ].map((item, idx) => (
{item.label}
{item.weight !== undefined ? `${(item.weight * 100).toFixed(1)}%` : ''}
{(item.score * 100).toFixed(0)}%
))}
Ensemble Score
{(result.overall_score * 100).toFixed(1)}%
)} {/* 2. RADAR CHART (Col 2, Row 1) */} {!hiddenCards['radar'] && (

Fingerprint Radar

[`${value.toFixed(1)}%`, 'Anomaly Score']} />
A larger footprint strongly indicates AI generation.
)} {/* 3. SHAP (Col 3, Row 1) */} {!hiddenCards['shap'] && (
SHAP Importance
Top drivers
{ const match = feature.match(/\(?Impact:\s*(\d+(?:\.\d+)?)%\s*(.*?)\)/i) || feature.match(/\((\d+(?:\.\d+)?)%\s*(.*?)\)/); const importance = match ? parseFloat(match[1]) : Math.max(10, 100 - (idx * 20)); const direction = match ? match[2] : ""; const nameStr = feature.replace(/\s*\((?:Impact:\s*)?\d+(?:\.\d+)%\s*.*?\)/i, ''); return { name: nameStr.length > 20 ? nameStr.substring(0, 18) + '...' : nameStr, fullName: nameStr, importance: importance, direction: direction }; })} layout="vertical" margin={{ top: 0, right: 10, left: 0, bottom: 0 }}> { if (active && payload && payload.length) { const isFake = payload[0].payload.direction.includes("FAKE"); const color = isFake ? 'var(--danger)' : 'var(--success)'; return (

{payload[0].payload.fullName}

{payload[0].value}% {payload[0].payload.direction}

); } return null; }} /> { result.shap_top_features.map((feature, index) => { const isFake = feature.includes("FAKE"); return }) }
)} {/* 4. ARCHITECTURE (Col 2 & 3, Row 2) */} {!hiddenCards['arch'] && (
Meta-Classifier Architecture
PyTorch Tabular ResNet + Self-Attention

The Meta-Classifier acts as the final "Judge". It does not look at the video pixels; instead, it analyzes the numerical scores generated by all the independent physical and biological sensors.

  • Inputs: 12-14 distinct anomaly scores (0.0 to 1.0).
  • Self-Attention: Learns which sensors to trust based on the context (e.g. ignoring color anomalies if the video is black and white).
  • XAI Override: Hard-coded to automatically override the neural network and flag the video as a Deepfake if any critical biological sensor (like Geometry) exceeds 70% anomaly.
)}
); }; export default React.memo(FeaturesTab);