Skip to content

About

Software Engineering Project

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

TruePixels.rgb — AI Image Detection System

TruePixels.rgb is a web application that estimates whether an image was generated by AI or is a real photograph. A user uploads a JPG or PNG and gets:

  • a verdict, AI Generated or Real;
  • a confidence;
  • the scores behind the verdict;
  • optional explanation images showing where the detectors looked;
  • a downloadable PDF report.

Carried out as part of the Software Engineering Project.

Team member Roll number
Amogh R Gowda 241IT008
Anurag V Rao 241IT011
Debanshu Mitra 241IT019

Course instructor: Prof. Jaidhar C D


How it works

Two independently pretrained detectors read the same image. They look for different kinds of evidence: a generator that fools one has no particular reason to also fool the other.

upload ──► validate ──► Content detector  (Community Forensics) ──┐
                   └──► Frequency detector (SPAI) ────────────────┤
                                                                  ▼
                              combined = 0.55 × content + 0.45 × frequency
                                                                  ▼
                              AI Generated if combined ≥ 0.4524, else Real
Content detector Frequency detector
Model Community Forensics, ViT-S/16 (CVPR 2025) SPAI, ViT-B/16 (CVPR 2025)
Looks at What the picture shows: texture, lighting, the "too clean" look Fine detail in the pixel grid, via a Fourier transform of each 224 × 224 patch
Input Centre 384 × 384 crop Every patch at native resolution, never resized
  • No training: both models are third-party checkpoints, used exactly as their authors published them. The project trains nothing. The fusion weight and threshold are settings, chosen on a separate selection set.
  • Confidence: this is how far the combined score lies from the threshold, in favour of the verdict shown. It is between 50 % and 100 %: High ≥ 85 %, Moderate 65–85 %, Low < 65 %. It is a margin, not a calibrated probability.
  • Small images: below 224 px the frequency detector has no complete patch. The verdict then rests on the content detector alone, and the result page says so.

Full walk-through: docs/how-a-score-is-computed.md.

Results

Measured on images that played no part in choosing the weight or the threshold. Brackets are 95 % confidence intervals.

Test set Accuracy Recall (AI caught) False alarms on real photos AUC
19 generators released in 2025 vs matching real photos (559 + 559) 0.798 [0.77, 0.82] 0.626 0.030 0.895
9 generators from 2022–23 vs camera photos (99 + 99) 0.939 [0.90, 0.96] 0.949 0.071 0.986

These numbers describe how well these generators' images are separated from these real photographs. They are not a general accuracy for any image.

Known limitations

  • Some 2025 generators are often missed: FLUX.2 pro (23 % caught), FLUX.2 max (17 %), FLUX 1.1 pro (26 %), GPT-image-1 (29 %). Newer generators are untested.
  • Resizing an image weakens the frequency detector; JPEG recompression barely affects it. Phone-camera enhancement and AI upscalers can make real photos look generated.
  • The content detector scores only the centre of the image.
  • The test sets are not fully independent of the detectors' authors.

All measurements: ml/evaluation/RESULTS.md.

Features

Users

  • Create an account, sign in (optional e-mailed one-time code), reset or change a password.
  • Upload and analyse an image (JPG or PNG, up to 10 MB), with or without explanation images.
  • See past results in a scan history, and download a PDF report for any result.
  • See only their own scans: every query is filtered by account.

Administrators

  • A dashboard of active models, daily usage, confidence distribution and latency.
  • Audit log and login activity.
  • User management (enable or disable accounts).
  • Model management: which detectors run, with one-step rollback guarded by a quality gate.
  • One-click verification of the whole system.

Interface

  • React app following the Government of India's Digital Brand Identity Manual: Blue colour group, Noto Sans, accessibility controls for text size and dark contrast.
  • Works on phones.
  • FAQ page; contact: truepixel.rgb@gmail.com.

Technology

Layer Stack
Front end React 18, TypeScript, Vite, Tailwind CSS
API Python 3.13, FastAPI, SQLAlchemy
Models PyTorch 2.13 (CUDA 12.6), timm, Hugging Face Transformers
Database PostgreSQL 16 (Docker), schema managed with Alembic
Web server Caddy: HTTPS, security headers, serves the built front end

Running it

You need:

  • Python 3.13;
  • Node.js 20+;
  • Docker Desktop;
  • about 2 GB of disk for model weights.

An NVIDIA GPU is optional but about 25× faster; the project was developed on an RTX 4050 (6 GB). Commands are for Windows PowerShell.

1. Install

python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r backend/requirements.txt
pip install --index-url https://download.pytorch.org/whl/cu126 "torch==2.13.0+cu126" "torchvision==0.28.0+cu126"   # GPU build
cd frontend; npm install; cd ..

2. Model weights (once).

  • SPAI: download spai.pth from the link in backend/app/shared/config.py (DETECTOR_FREQUENCY_SOURCE_URL) into storage/models/, then convert it:

    cd backend; python scripts/convert_spai_checkpoint.py; cd ..

    The server loads it only if its checksum matches.

  • Community Forensics downloads itself on first use.

3. Configure. Copy backend/.env.example to backend/.env and fill in:

  • the database credentials;
  • JWT_SECRET_KEY and PROXY_SHARED_SECRET;
  • SMTP settings, if sign-in codes should go by e-mail.

.env is never committed.

4. Start. Double-click start.cmd. It starts the database, applies migrations, starts the API and the HTTPS front end, and opens https://localhost. Create the first administrator once: from backend/, run python seed_admin.py. Stop everything with stop.cmd; data is kept.

Detailed options: docs/https.md (HTTPS), docs/auth-hardening.md (sign-in and one-time codes).

Testing

python -m pytest backend/tests -q                  # backend suite
python -m pytest backend/tests -q -m "not slow"    # without the model-backed tests
cd frontend; npm run typecheck; npm run lint; npm run build
  • Isolation: tests use their own scratch database and never touch real data.
  • Browser: frontend/e2e/ holds the browser (Playwright) suites, run against a scratch server.
  • Score regression: ml/evaluation/regression_check.py checks that every score stays bit-for-bit identical.

Project structure

backend/app/
  m1_access/     M1 - accounts, sign-in, one-time codes, upload validation
  m2_analysis/   M2 - the two detectors, fusion, explanations, model registry
  m3_results/    M3 - results, history, PDF reports, administration
  shared/        configuration, database, module contracts
backend/migrations/  database schema (Alembic)
backend/tests/       backend test suites
frontend/src/        React app (pages, components, API client)
ml/evaluation/       benchmarks, threshold selection, RESULTS.md
infra/               Caddy configuration and HTTPS checks
docs/                design documents

Further reading

Document Contents
docs/how-a-score-is-computed.md From upload to verdict, step by step
ml/evaluation/RESULTS.md Every measurement, with intervals and limits
docs/contracts/ The interfaces between the three modules
docs/https.md HTTPS, proxy trust and security headers
docs/auth-hardening.md Sign-in, one-time codes and throttling

Licences

  • SPAI (code and weights, backend/app/m2_analysis/vendor/spai/): Apache-2.0.
  • Community Forensics (code and weights, backend/app/m2_analysis/vendor/commfor/): MIT.
  • SigLIP 2 fine-tune (alternative content detector, kept for rollback): Apache-2.0.
  • Evaluation data is used only for measurement and is not redistributed:
    • Synthbuster: CC-BY-NC-SA-4.0;
    • RAISE-1k: research use only;
    • AIGenImages2026: CC-BY-4.0.

About

Software Engineering Project

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages