Skip to content

Local-first AI image detector with a FastAPI backend and React frontend (WIP)

Notifications You must be signed in to change notification settings

inspiringsource/AI-Image-Checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AI Image Checker (Local-First)

Warning

Work in Progress / Demo

  • This is a small side project/demonstration, not a forensic tool.
  • Results are probabilistic and based on a general-purpose model (dima806/ai_vs_real_image_detection).
  • Thresholds are not fully optimized. Compression, resizing, or editing can affect results.
  • Do not rely on this tool for critical verification.

A privacy-focused tool to estimate if an image is AI-generated, running entirely locally on your machine.


Project Structure

  • backend/: FastAPI Python application.
    • app/detectors/: Contains detector implementations (Dummy, ONNX, Hugging Face).
    • app/api/: API route definitions.
  • frontend/: Vite React TypeScript application.
    • src/components/: UI components (ResultCard, StatusBadge, Dropzone).
    • src/api/: Typed API client.

Getting Started

Prerequisites

  • Python 3.10+
  • Node.js & npm (v18+ recommended)

1. Backend Setup

Windows (PowerShell)

cd backend
python -m venv .venv
.\.venv\Scripts\Activate
pip install -r requirements.txt
# Run Tests (Optional)
python -m pytest
# Start Server
python -m uvicorn app.main:app --reload --port 8000

macOS / Linux (Bash/Zsh)

cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Run Tests (Optional)
python3 -m pytest
# Start Server
python3 -m uvicorn app.main:app --reload --port 8000

The API will be available at http://localhost:8000.

2. Frontend Setup

Open a new terminal window.

All Platforms

cd frontend
npm install
npm run dev

The app will open at http://localhost:5173. Ensure the backend is running.


Real Detector Mode (Hugging Face)

By default, the app may use a "Dummy" or "ONNX" detector. To use the state-of-the-art Hugging Face model (dima806/ai_vs_real_image_detection), follow these steps.

Windows PowerShell

$env:USE_HF_DETECTOR="1"
$env:HF_HOME=".\.hf_cache"  # Caches model in backend/.hf_cache
python -m uvicorn app.main:app --reload --port 8000

macOS / Linux

export USE_HF_DETECTOR=1
export HF_HOME="./.hf_cache"
python3 -m uvicorn app.main:app --reload --port 8000

Note: The first run will download model weights (~300MB) to .hf_cache.

Offline Mode

Once downloaded, you can run entirely offline:

Windows:

$env:HF_HUB_OFFLINE="1"
python -m uvicorn app.main:app --reload --port 8000

macOS / Linux:

export HF_HUB_OFFLINE=1
python3 -m uvicorn app.main:app --reload --port 8000

Known Limitations

  • Accuracy: The model identifies patterns common in AI generation but can false-positive on heavily edited or compressed "real" photos.
  • Performance: Inference runs on CPU by default. Latency depends on your machine specs.
  • Scope: Intended for standard photography vs. generative AI (Midjourney/Flux/DALLE). May not detect subtle edits (Photoshop AI fill).

About

Local-first AI image detector with a FastAPI backend and React frontend (WIP)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published