radai-api / README.md
RageCoder2006's picture
Update README with RADAI and HF configuration
7af3b1c
|
Raw
History Blame Contribute Delete
7.86 kB
metadata
title: Radai Api
emoji: ๐Ÿง 
colorFrom: blue
colorTo: indigo
sdk: docker
app_file: app.py
pinned: false

๐Ÿง  RADAI โ€” Real-Time AI Image Detection Extension

Bringing trust back to the internet โ€” one image at a time.

Status Model Backend Platform PyTorch Python

Report Bug โ€ข Request Feature โ€ข View Demo

Built for Prakalp 4.0


โœจ What is AI Detector?

With the explosion of generative AI tools like Stable Diffusion, Midjourney, and DALLยทE, distinguishing real images from synthetic ones has become nearly impossible for the human eye.

RADAI is a real-time deepfake detection Chrome extension that scans every image on any webpage and classifies it as:

  • ๐Ÿง  AI Generated โ€” flagged with a red border and confidence score
  • ๐Ÿ“ท Real โ€” confirmed with a green border and confidence score

It doesn't just stop there. It calculates a full page-level risk score so you can instantly understand how much synthetic content you're being served โ€” on any website, at any time.

In a world where AI can generate anything โ€” this system helps you understand what is real.


๐Ÿš€ Features

๐Ÿ” Real-Time Image Scanning

  • Detects all visible images on any webpage
  • Works on Google Images, blogs, news sites, social media โ€” anywhere
  • Ignores hidden or non-visible DOM elements for accurate results

๐ŸŽฏ AI vs Real Classification

  • Powered by OpenCLIP (ViT-L-14) & ConvNeXt-Base deep vision models
  • Transfer learning with a custom binary classification head
  • Outputs a clean probability score per image

๐ŸŽจ Visual Highlighting

  • ๐Ÿ”ด Red border โ†’ AI Generated
  • ๐ŸŸข Green border โ†’ Real
  • Hover over any image to see its label + confidence score

๐Ÿ“Š Page Risk Analysis

Calculates an overall AI content percentage for the entire page:

Risk Level Range Meaning
๐ŸŸข Low Risk 0โ€“30% Mostly real content
๐ŸŸก Moderate Risk 30โ€“70% Mixed content
๐Ÿ”ด High Risk 70โ€“100% Mostly AI-generated

โšก Clean UI/UX

  • Minimal, Apple-inspired design
  • Fast and non-intrusive
  • Confidence scores displayed inline

โš™๏ธ How It Works

Step 1 โ€” Image Extraction

The extension scans the webpage DOM and collects all visible <img> elements, extracting their src URLs for backend processing.

Step 2 โ€” URL-Based Backend Processing

Image URLs are sent directly to the Flask backend โ€” no screenshots, no compression artifacts. This ensures maximum accuracy and faster processing.

Step 3 โ€” Feature Extraction via OpenCLIP

The backend uses a frozen OpenCLIP (ViT-L-14) backbone pretrained on datacomp_xl_s13b_b90k to convert each image into rich deep feature embeddings.

Step 4 โ€” Custom Classification Head

A lightweight neural network processes those embeddings:

Linear โ†’ ReLU โ†’ Dropout โ†’ Linear โ†’ Sigmoid

Output: A probability score indicating how likely the image is AI-generated.

Step 5 โ€” UI Rendering

Results are pushed back to the extension, which:

  • Highlights each image directly on the page
  • Overlays confidence labels on hover
  • Updates the popup with page-level risk analysis

๐Ÿงช Model Details

Property Value
Ensemble OpenCLIP (ViT-L-14) + ConvNeXt-Base
Pretrained On datacomp_xl_s13b_b90k
Approach Transfer Learning
Encoder Frozen
Head Custom Binary Classifier
Output AI / Real + Probability

๐Ÿ“‚ Training Dataset

AI Images: Stable Diffusion, Midjourney, DALLยทE, Flux

Real Images: Unsplash dataset


๐Ÿ— Project Structure

extension-deepfake/
โ”‚
โ”œโ”€โ”€ app.py                        # Flask backend โ€” model inference & API
โ”œโ”€โ”€ OpenCLIP_forensic_head.pth      # Trained model weights
โ”œโ”€โ”€ train.py                      # Training script (reference only)
โ”‚
โ””โ”€โ”€ extension/
    โ”œโ”€โ”€ manifest.json             # Chrome extension configuration
    โ”œโ”€โ”€ popup.html                # Extension UI layout
    โ”œโ”€โ”€ popup.js                  # Button logic & UI state updates
    โ””โ”€โ”€ content.js                # DOM scanning & image highlighting

โš™๏ธ Setup & Installation

Prerequisites

  • Python 3.8+
  • pip
  • Google Chrome browser

1. Clone the Repository

git clone https://github.com/How2Invade/extension-deepfake.git
cd extension-deepfake

2. Install Backend Dependencies

pip install torch torchvision flask pillow open_clip_torch

3. Run the Flask Backend

python app.py

The server will start at:

http://127.0.0.1:5000

Keep this terminal running while using the extension.


4. Load the Chrome Extension

  1. Open Chrome and navigate to chrome://extensions/
  2. Toggle Developer Mode (top right)
  3. Click Load Unpacked
  4. Select the extension/ folder from the cloned repo

5. Start Detecting

  1. Open any webpage (try Google Images)
  2. Click the AI Detector extension icon
  3. Hit Scan Images

Every image on the page will be analyzed and highlighted instantly.


๐ŸŽฏ Output

Each scanned image receives:

  • A colored border (Red = AI, Green = Real)
  • A confidence label on hover (e.g., AI โ€” 78% or Real โ€” 64%)

The popup displays:

  • Overall risk percentage
  • Page-level verdict (Low / Moderate / High Risk)

๐Ÿ”ฎ Future Scope

  • ๐ŸŽฅ Video deepfake detection โ€” frame-by-frame analysis
  • ๐ŸŽ™๏ธ Audio deepfake detection โ€” voice synthesis identification
  • โ˜๏ธ Cloud deployment โ€” remove the local backend requirement
  • ๐Ÿ“Š Advanced analytics dashboard โ€” historical scan data & trends
  • โšก Batch inference optimization โ€” faster multi-image processing

โš ๏ธ Limitations

  • Accuracy depends on training data coverage
  • Some false positives may occur on heavily stylized images
  • Backend must be running locally for the extension to work

๐Ÿ† Impact

AI Detector directly addresses one of the most pressing issues of the AI era:

  • โœ… Detecting fake and synthetic content at scale
  • โœ… Reducing the spread of AI-powered misinformation
  • โœ… Empowering users to verify what they see online
  • โœ… Assisting journalists, researchers, and media professionals

๐Ÿ™ Acknowledgments


๐Ÿ’ก Built to bring trust in an AI-generated world

โญ Star on GitHub โ€ข ๐Ÿ› Report an Issue