import { motion, AnimatePresence } from 'framer-motion' import { X, Microscope, AlertTriangle, CheckCircle } from 'lucide-react' import { BarChart, Bar, XAxis, YAxis, Tooltip, CartesianGrid, ResponsiveContainer, Cell } from 'recharts' export function MethodologyDrawer({ isOpen, onClose }) { if (!isOpen) return null const metricsData = [ { name: 'ICL Accuracy', value: 98.9, type: 'ICL' }, { name: 'ICL F1', value: 99.2, type: 'ICL' }, { name: 'Phone 5-Fold CV (Honest)', value: 79.5, type: 'Honest' }, { name: 'Phone Calibration*', value: 100, type: 'Calibration' } ] const getBarColor = (type) => { if (type === 'ICL') return '#10b981' if (type === 'Honest') return '#f59e0b' return '#3f3f46' } // Mini Pipeline Diagram Animation Variants const nodeVariants = { hidden: { opacity: 0, scale: 0.8 }, visible: i => ({ opacity: 1, scale: 1, transition: { delay: i * 0.2, duration: 0.4 } }) } const pipelineSteps = [ "Image Input", "Preprocessing (1024px, Denoise)", "CV Extraction (21 features)", "Frequency / FFT Analysis", "XGBoost Score", "Rule Boost / Context", "Final Risk Score" ] return ( {isOpen && ( <> {/* Header */}

Methodology & Info

{/* Body */}
{/* 1. Overview */}

1. Overview

The goal is to classify whether an image is a direct physical photo or a recaptured screen/printout image.

// Evaluator Command

$ python predict.py image.jpg

// Example Output (1 = Screen, 0 = Real)

0.4870

{/* 2. Why this approach */}

2. Why This Hybrid Approach?

Deep CNNs (ResNet, MobileNet) require significant compute, large datasets, and heavy libraries (PyTorch/TF). This assignment rewards practical, interpretable signals.

  • Warm CPU prediction is about 210 ms per image on my local Windows laptop.
  • Command line prediction is about 1.8 s per image because Python, OpenCV, and the model load each run.
  • Cost per image is $0 locally or inside the Docker Space; no paid API, GPU, or cloud model call is used.
  • No GPU required for deployment.
  • Interpretable feature telemetry (no black box).
  • Small ~360KB model footprint.
  • Highly suitable for future phone deployment.
{/* 3. Pipeline Diagram */}

3. Processing Pipeline

{pipelineSteps.map((step, i) => (
{step}
{i < pipelineSteps.length - 1 && (
)}
))}
{/* 4. Features */}

4. Feature Extraction

Note: High raw feature values are not automatically fraud. The model evaluates them contextually.

A. Color & Lighting

Brightness, contrast, saturation, overexposure/glare patches.

B. Edge & Blur

Laplacian sharpness, Sobel magnitude, edge density.

C. Frequency & Texture

FFT HF ratio, local patch FFT, moiré score, banding cues.

D. Screen & Print Cues

Bezel score, perspective contour, printout paper texture.

E. Compression

JPEG blockiness, compression diff.

{/* 5. Trained Model */}

5. ML Classification Layer

Algorithm: Phone-Adapted XGBoost Classifier

Features: 21

Threshold: 0.65

final_score = clamp(raw_model_score + rule_boost_total, 0, 1)
{/* Risk Bands */}

Risk Bands

0.0 - 0.35 (Real)
0.35 - 0.65 (Review)
0.65 - 1.0 (Screen)
{/* 6. Metrics */}

6. Model Metrics

{metricsData.map((entry, index) => ( ))}

ICL Dataset

GroupShuffleSplit applied to ensure Leakage-Free evaluation across scenes.

Phone CV (Honest)

5-fold stratified cross-validation on small phone dataset.

*Calibration Set

100% score is on the same 53 images used to tune the threshold. Not independent.

{/* 8. Challenges */}

7. Project Challenges

  • Real photos contain text, books, screens (off), windows, and shiny patterns.
  • Screen recaptures often lack a visible physical bezel.
  • Organic textures (flowers, fabric) heavily mimic moiré and high-frequency noise.
  • WhatsApp/JPEG compression creates blockiness identical to digital screen pixels.
  • Bright sunlight patches mimic display glare.
{/* 9. Feature Audit */}

8. Feature Contextualization

We built an ablation suite to fix false positives on natural images:

Moiré Flatness Penalty: Moiré is downweighted if the surrounding texture is dense/organic.

Screen Context Boost: Rectangular contour, strong glare, and display-like texture together can lift an under-scored screen case.

FFT Downweighting: Reduced naive global FFT influence to prevent flagging real sharpness as fraud.

Multi-Cue Rules: Made rule boosts conservative and multi-cue only.

{/* 10. Why small and fast */}

9. Why This Can Run On A Phone

The design is phone-deployable in principle because the model is lightweight.

It uses C++ backed OpenCV operations and a tiny XGBoost tree structure on 21 numeric features instead of heavy GPU tensors or cloud API calls. Future implementations can convert the logic to ONNX/TFLite or native mobile C++.

{/* 11. Improvements */}

10. What Could Be Improved

  • Collect massive, diverse WhatsApp-compressed real/screen datasets.
  • Collect more diverse printout photos and lighting conditions.
  • Establish a true, large-scale held-out phone test set for independent validation.
  • Optionally train a tiny MobileNetV3/CNN as a secondary ensemble feature.
  • Implement SHAP values for true causal feature attribution.
{/* 12. Honesty Box */}

Phone metrics are limited because the phone dataset is small. The 100% phone calibration score is not an independent benchmark. The honest phone-domain CV score is around 79.5% F1. No production accuracy claim is made.

)}
) }