Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- Dockerfile +22 -0
- README.md +12 -64
- app.py +6 -3
- requirements.txt +4 -4
Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# System deps
|
| 6 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
+
libgl1 libglib2.0-0 && \
|
| 8 |
+
rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# Install Python deps
|
| 11 |
+
COPY requirements.txt .
|
| 12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
+
|
| 14 |
+
# Copy app
|
| 15 |
+
COPY app.py .
|
| 16 |
+
|
| 17 |
+
# HF Spaces expects port 7860
|
| 18 |
+
EXPOSE 7860
|
| 19 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 20 |
+
ENV GRADIO_SERVER_PORT="7860"
|
| 21 |
+
|
| 22 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -1,64 +1,12 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: AI Image Detector
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom: purple
|
| 5 |
-
colorTo: blue
|
| 6 |
-
sdk:
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
# ποΈ AI Image Detector Ensemble
|
| 14 |
-
|
| 15 |
-
A 6-engine ensemble that detects whether an image is **AI-generated** or **real**.
|
| 16 |
-
|
| 17 |
-
## Engines
|
| 18 |
-
|
| 19 |
-
| # | Engine | Model / Method |
|
| 20 |
-
|---|--------|---------------|
|
| 21 |
-
| 1 | FFT | Fast Fourier Transform β frequency-domain artifact detection |
|
| 22 |
-
| 2 | ELA | Error Level Analysis β compression-tampering map |
|
| 23 |
-
| 3 | ResNet | `umm-maybe/AI-image-detector` |
|
| 24 |
-
| 4 | SigLIP | `Ateeqq/ai-vs-human-image-detector` |
|
| 25 |
-
| 5 | SDXL | `Organika/sdxl-detector` |
|
| 26 |
-
| 6 | ViT | `prithivMLmods/Deep-Fake-Detector-v2-Model` |
|
| 27 |
-
|
| 28 |
-
The **Final Verdict** averages all four deep-learning scores.
|
| 29 |
-
|
| 30 |
-
## API Usage (Android / Mobile)
|
| 31 |
-
|
| 32 |
-
Gradio exposes a REST API automatically.
|
| 33 |
-
Use the `/api/predict` endpoint (or the auto-generated client) to integrate with any Android app:
|
| 34 |
-
|
| 35 |
-
```
|
| 36 |
-
POST https://<your-space-url>/api/predict
|
| 37 |
-
Content-Type: application/json
|
| 38 |
-
|
| 39 |
-
{
|
| 40 |
-
"data": ["<base64-encoded-image-or-public-URL>"]
|
| 41 |
-
}
|
| 42 |
-
```
|
| 43 |
-
|
| 44 |
-
The JSON response includes:
|
| 45 |
-
```json
|
| 46 |
-
{
|
| 47 |
-
"verdict": "FAKE | REAL",
|
| 48 |
-
"confidence": 87.45,
|
| 49 |
-
"scores": {
|
| 50 |
-
"resnet": 92.3,
|
| 51 |
-
"siglip": 88.1,
|
| 52 |
-
"sdxl": 85.0,
|
| 53 |
-
"deepfake": 84.5
|
| 54 |
-
}
|
| 55 |
-
}
|
| 56 |
-
```
|
| 57 |
-
|
| 58 |
-
## Files
|
| 59 |
-
|
| 60 |
-
| File | Purpose |
|
| 61 |
-
|------|---------|
|
| 62 |
-
| `app.py` | Everything β pre-processing, all engines, ensemble, Gradio UI |
|
| 63 |
-
| `requirements.txt` | Python dependencies (CPU PyTorch for fast HF builds) |
|
| 64 |
-
| `README.md` | This file (also configures the HF Space) |
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: AI Image Detector
|
| 3 |
+
emoji: π§¬
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# 𧬠AI Image Detector β Fine-Tuned Model
|
| 11 |
+
|
| 12 |
+
Powered by a custom fine-tuned Vision Transformer (99.4% test accuracy).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -372,7 +372,6 @@ footer { display: none !important; }
|
|
| 372 |
"""
|
| 373 |
|
| 374 |
HEADER_HTML = f"""
|
| 375 |
-
<style>{CUSTOM_CSS}</style>
|
| 376 |
<div class="hero-header">
|
| 377 |
<h1>𧬠AI Image Detector</h1>
|
| 378 |
<p class="tagline">Powered by a <b>fine-tuned Vision Transformer</b> with 99.4% accuracy</p>
|
|
@@ -443,7 +442,11 @@ def analyze_image(pil_image):
|
|
| 443 |
return html, result["_fft_img"], result["_ela_img"], result["_noise_img"], s.get("finetuned",0), s.get("siglip",0), s.get("smogy",0), s.get("noise",0), j
|
| 444 |
|
| 445 |
|
| 446 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
|
| 448 |
gr.HTML(HEADER_HTML)
|
| 449 |
|
|
@@ -468,7 +471,7 @@ with gr.Blocks(title="AI Image Detector β Fine-Tuned") as demo:
|
|
| 468 |
noise_score_out = gr.Number(label="π¬ Noise (20%)", precision=2)
|
| 469 |
|
| 470 |
gr.HTML('<div class="section-title">π¦ API Response</div>')
|
| 471 |
-
json_out = gr.Textbox(label="JSON", lines=8, interactive=False)
|
| 472 |
|
| 473 |
submit_btn.click(
|
| 474 |
fn=analyze_image,
|
|
|
|
| 372 |
"""
|
| 373 |
|
| 374 |
HEADER_HTML = f"""
|
|
|
|
| 375 |
<div class="hero-header">
|
| 376 |
<h1>𧬠AI Image Detector</h1>
|
| 377 |
<p class="tagline">Powered by a <b>fine-tuned Vision Transformer</b> with 99.4% accuracy</p>
|
|
|
|
| 442 |
return html, result["_fft_img"], result["_ela_img"], result["_noise_img"], s.get("finetuned",0), s.get("siglip",0), s.get("smogy",0), s.get("noise",0), j
|
| 443 |
|
| 444 |
|
| 445 |
+
with gr.Blocks(
|
| 446 |
+
title="AI Image Detector β Fine-Tuned",
|
| 447 |
+
theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue", neutral_hue="slate"),
|
| 448 |
+
css=CUSTOM_CSS,
|
| 449 |
+
) as demo:
|
| 450 |
|
| 451 |
gr.HTML(HEADER_HTML)
|
| 452 |
|
|
|
|
| 471 |
noise_score_out = gr.Number(label="π¬ Noise (20%)", precision=2)
|
| 472 |
|
| 473 |
gr.HTML('<div class="section-title">π¦ API Response</div>')
|
| 474 |
+
json_out = gr.Textbox(label="JSON", lines=8, show_copy_button=True, interactive=False)
|
| 475 |
|
| 476 |
submit_btn.click(
|
| 477 |
fn=analyze_image,
|
requirements.txt
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
# AI Image Detector β New Approach
|
| 2 |
-
#
|
| 3 |
|
| 4 |
-
# PyTorch CPU
|
| 5 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 6 |
torch==2.6.0+cpu
|
| 7 |
|
| 8 |
-
# Core
|
| 9 |
-
|
| 10 |
transformers>=4.38.0
|
| 11 |
Pillow>=9.0.0
|
| 12 |
numpy<2.0
|
|
|
|
| 1 |
# AI Image Detector β New Approach
|
| 2 |
+
# Uses Dockerfile to control exact versions (bypasses HF forced Gradio 6)
|
| 3 |
|
| 4 |
+
# PyTorch CPU
|
| 5 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 6 |
torch==2.6.0+cpu
|
| 7 |
|
| 8 |
+
# Core β pinned Gradio 5.12.0 (stable, tested)
|
| 9 |
+
gradio==5.12.0
|
| 10 |
transformers>=4.38.0
|
| 11 |
Pillow>=9.0.0
|
| 12 |
numpy<2.0
|