An image detector that estimates whether a picture is AI-generated using a trained spectral and texture classifier on the backend.
The local classifier measures directional frequency energy, block cosine coefficients and neighboring pixel differences at two image sizes. It learns which combinations occur in labeled training images. Photos and generated images can share these patterns, and resizing or recompression can change the score.
ββββββββββββββββββββββββββββββββ
β Spatial RGB Input Image β
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β 2D Fast Fourier Transform (FFT-2D) β
β F(u,v) = β¬ f(x,y) e^{-j2Ο(ux+vy)} β
βββββββββββββββββββββββ¬ββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β Centered Log-Magnitude Spectrum β
β S(u,v) = log(1 + |F(u,v)|) β
βββββββββββββββββββββββ¬ββββββββββββββββββββββ
β
ββββββββββββββββββββ΄βββββββββββββββββββ
βΌ βΌ
βββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
β Directional FFT, block β β Inferno Visual Spectrum β
β DCT and pixel texture β β PNG Data URI Generator β
ββββββββββββββββ¬βββββββββββββββ βββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Scikit-Learn Classifier β
β Spectral + Texture Model β
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Forensic Classification β
β AUTHENTIC vs. SYNTHETIC β
βββββββββββββββββββββββββββββββ
-
2D Continuous Fourier Transform: The grayscale spatial representation
$f(x, y)$ is transformed into the frequency plane$F(u, v)$ with the zero-frequency DC component shifted to the center. -
Log-Magnitude Spectrum: Computes
$S(u, v) = \log(1 + |F(u, v)|)$ and maps it to a normalized dynamic range with aninfernocolormap. -
1D Azimuthal Radial Integration: Averages circular frequency bands from radius
$r=0$ (DC component) to$r=r_{\max}$ (Nyquist frequency$\pi$ ), generating a 1D spectral energy profile. - Local classification uses 474 measurements from the image pixels. The radial plot provides a visual diagnostic alongside the classifier score.
Open the live detector and choose an image, drop a file, or paste one from the clipboard. The result shows the classifier score alongside the Fourier spectrum, radial profile, and texture diagnostics. Test again analyzes the same file. New image opens the file picker. The eye logo returns to the upload screen.
The demo presets draw canvas patterns so visitors can explore the interface. The accuracy results below come from labeled image files.
On the first visit, choose Install The Eyes. Browsers that support an install prompt show their confirmation dialog. On iPhone or iPad, open the site in Safari and use Share β Add to Home Screen. Not now dismisses the invitation on that browser, and the smaller install link remains available.
The installed app opens in its own window. Image analysis requires a connection to the Render backend. When an installed app launches offline, it offers a retry link.
the eyes/
βββ backend/
β βββ app/
β β βββ __init__.py
β β βββ main.py # FastAPI backend, CORS, /predict endpoint
β β βββ feature_extractor.py # extract_fingerprint, FFT spectrum & diagnostics
β β βββ image_features.py # Spectral and texture features shared with training
β β βββ sightengine_service.py # Sightengine GenAI API client
β βββ .env.example # Sample environment variables
β βββ requirements.txt # Python dependencies
β βββ model.pkl # (Optional location for trained model)
β
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Header.jsx # System status bar with live telemetry
β β β βββ Dropzone.jsx # Drag-and-drop / paste image zone
β β β βββ SamplePresets.jsx # 1-click test benchmark suite
β β β βββ VerdictBadge.jsx # Hero REAL vs AI-GENERATED verdict
β β β βββ ForensicMetrics.jsx # Diagnostic numerical readouts
β β β βββ RadialProfileChart.jsx # 1D Azimuthal radial decay chart
β β β βββ ImageComparisonSlider.jsx # Interactive split wiper slider
β β β βββ InstallInvite.jsx # Browser installation prompt and guidance
β β β βββ ResultDashboard.jsx # Unified multi-mode workspace
β β βββ App.jsx # Application state & routing
β β βββ main.jsx # React entrypoint
β β βββ index.css # Tailwind CSS & animations
β βββ index.html
β βββ package.json
β βββ vite.config.js
β βββ tailwind.config.js
β βββ postcss.config.js
β
βββ ai_detector_svm.pkl # Fallback copy of the local classifier
βββ .gitignore
βββ README.md
- Python 3.11+
- Node.js 18+ & npm
# Navigate to the backend directory
cd backend
# Create and activate a virtual environment
python -m venv venv
# On Windows PowerShell:
.\venv\Scripts\Activate.ps1
# On macOS / Linux:
# source venv/bin/activate
# Install Python requirements
pip install -r requirements.txt
# (Optional) Setup Sightengine API credentials
cp .env.example .env
# Start the FastAPI development server
uvicorn app.main:app --reload --port 8000- Backend API:
http://localhost:8000 - API Health Status:
http://localhost:8000/health - Interactive OpenAPI Docs:
http://localhost:8000/docs
In a separate terminal:
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start Vite dev server
npm run devOpen your browser at http://localhost:5173.
The saved local detector combines gradient-boosted trees with a neural network. Training used 94,170 portrait originals and 4,515 public scene originals, plus 49,353 edited views. It gave the portrait and scene sources 70% and 30% of the training weight respectively, balancing real and generated examples within each source. Validation selected the average of the two classifiers at a fixed AI-score cutoff of 0.5. On the same 482 public validation scenes, the portrait-only run scored 47.3% and the mixed run scored 78.4%.
| Held-out test images | Previous accuracy | Retrained accuracy | Real images flagged as AI, previous β retrained |
|---|---|---|---|
| Original audit, 2,000 portraits | 53.75% | 71.60% | 574 β 323 of 1,000 |
| Another 2,000 test portraits | 54.85% | 72.20% | 563 β 317 of 1,000 |
| Publisher's 1,000 test scenes | 43.10% | 84.00% | 378 β 87 of 500 |
On 200 reference portraits, JPEG recompression changed 41 retrained verdicts (previously 64), and halving the resolution changed 60 (previously 102). Exporting every public scene at 256 Γ 256 JPEG quality 80 reduced the retrained accuracy to 70.1%. The retrained model flagged 34 of 100 photographs from the independent Berkeley BSDS300 test set, down from 71. These measurements cover local inference using dataset labels. See the full comparison and weight hashes.
From the repository root, install backend/requirements.txt and place the portrait archive at data-set/archive.zip. To reproduce the run with additional scenes, prepare the public scene dataset and train a candidate.
python -m pip install pyarrow
python training/fetch_public_data.py
python training/prepare_public_data.py
python train_model.py --with-public-scenes --output data-set/candidate.pklThe trainer reserves the test and validation splits before sampling. It excludes exact file matches and screens for near-identical decoded images across splits using a perceptual hash and thumbnail distance. It trains on original, resized and recompressed images and selects the classifier using validation data. Run python train_model.py for portrait-only training. Without --output, the trainer writes both application weight files.
To repeat the comparison, supply the original radial model (backend/model.pkl at Git revision 3bb3fba) as --previous. The reference cohort uses the same 2,000 images as the first audit. A second cohort samples 2,000 different test portraits. The public test split measures performance on other scenes. The optional --photo-test data-set/BSDS300-images.tgz argument includes the Berkeley check.
python -m training.evaluate --previous data-set/baseline-radial.pkl --candidate data-set/candidate.pkl --with-public-scenesThe backend reads the feature version stored in the weights. New models use the shared extractor in backend/app/image_features.py. Older 40-feature weights use the original radial extractor. Restart the backend after replacing the weights.
For custom features, update the shared extractor and its FEATURE_VERSION before retraining. The health endpoint and each local prediction include the SHA-256 of the loaded weights.
To include an optional external benchmark in the API response:
- Create a free account at Sightengine.
- In
backend/.env, set:SIGHTENGINE_API_USER=your_user_id SIGHTENGINE_API_SECRET=your_secret_key
- Restart the backend server. When configured, the backend sends the uploaded image to Sightengine and returns its benchmark separately from the detector verdict.
This project is open-source and available under the MIT License.