Spaces:
Sleeping
Sleeping
Commit Β·
aecda2f
1
Parent(s): 4036a63
updated .gitignore
Browse files- .gitignore +1 -1
- README_HUGGINGFACE.md +0 -128
- all.txt +0 -0
- setup.sh +0 -138
.gitignore
CHANGED
|
@@ -20,4 +20,4 @@ tests/
|
|
| 20 |
# Models / large files
|
| 21 |
*.pt
|
| 22 |
*.bin
|
| 23 |
-
*.onnx
|
|
|
|
| 20 |
# Models / large files
|
| 21 |
*.pt
|
| 22 |
*.bin
|
| 23 |
+
*.onnx
|
README_HUGGINGFACE.md
DELETED
|
@@ -1,128 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: AI Image Screener
|
| 3 |
-
emoji: π
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 7860
|
| 8 |
-
pinned: false
|
| 9 |
-
license: mit
|
| 10 |
-
tags:
|
| 11 |
-
- ai-detection
|
| 12 |
-
- image-forensics
|
| 13 |
-
- computer-vision
|
| 14 |
-
- content-moderation
|
| 15 |
-
- screening-tool
|
| 16 |
-
---
|
| 17 |
-
|
| 18 |
-
# AI Image Screener π
|
| 19 |
-
|
| 20 |
-
**A transparent, unsupervised first-pass screening system for identifying images requiring human review**
|
| 21 |
-
|
| 22 |
-
## Overview
|
| 23 |
-
|
| 24 |
-
AI Image Screener is a multi-metric ensemble system that analyzes images using five independent statistical detectors to identify potential AI-generated content. Unlike black-box classifiers, this system provides full explainability with per-metric breakdowns and human-readable explanations.
|
| 25 |
-
|
| 26 |
-
**Important**: This is a **screening tool, not a verdict engine**. It flags images for human review rather than making definitive "real vs fake" classifications.
|
| 27 |
-
|
| 28 |
-
## How It Works
|
| 29 |
-
|
| 30 |
-
The system analyzes five distinct image characteristics:
|
| 31 |
-
|
| 32 |
-
1. **Gradient-Field PCA (30%)**: Detects lighting inconsistencies typical of diffusion models
|
| 33 |
-
2. **Frequency Analysis (25%)**: Identifies unnatural spectral energy distributions via FFT
|
| 34 |
-
3. **Noise Pattern Analysis (20%)**: Detects missing or artificial sensor noise
|
| 35 |
-
4. **Texture Statistics (15%)**: Identifies overly smooth or repetitive regions
|
| 36 |
-
5. **Color Distribution (10%)**: Flags unnatural saturation and color patterns
|
| 37 |
-
|
| 38 |
-
Each metric produces a score (0.0-1.0), which are combined using weighted ensemble aggregation.
|
| 39 |
-
|
| 40 |
-
## Expected Performance
|
| 41 |
-
|
| 42 |
-
**Detection Rates (Honest Estimates):**
|
| 43 |
-
- Consumer AI tools (2022-2023): 80-90%
|
| 44 |
-
- Stable Diffusion 1.x/2.x: 70-80%
|
| 45 |
-
- Midjourney v5/v6: 55-70%
|
| 46 |
-
- DALL-E 3 / Gemini Imagen 3: 40-55%
|
| 47 |
-
- Post-processed AI images: 30-45%
|
| 48 |
-
|
| 49 |
-
**False Positive Rate**: ~10-20% on authentic photos (especially HDR, macro, long-exposure)
|
| 50 |
-
|
| 51 |
-
## Usage
|
| 52 |
-
|
| 53 |
-
### Web Interface
|
| 54 |
-
|
| 55 |
-
1. Click "Use this Space" above
|
| 56 |
-
2. Upload single or multiple images (max 50 per batch)
|
| 57 |
-
3. View results with detailed metric breakdowns
|
| 58 |
-
4. Export reports in CSV or PDF format
|
| 59 |
-
|
| 60 |
-
### API Access
|
| 61 |
-
|
| 62 |
-
```bash
|
| 63 |
-
# Single image analysis
|
| 64 |
-
curl -X POST https://huggingface.co/spaces/YOUR_USERNAME/ai-image-screener/api/analyze/image \
|
| 65 |
-
-F "file=@image.jpg"
|
| 66 |
-
|
| 67 |
-
# Batch analysis
|
| 68 |
-
curl -X POST https://huggingface.co/spaces/YOUR_USERNAME/ai-image-screener/api/analyze/batch \
|
| 69 |
-
-F "files=@img1.jpg" \
|
| 70 |
-
-F "files=@img2.png"
|
| 71 |
-
```
|
| 72 |
-
|
| 73 |
-
See full API documentation at `/docs` endpoint.
|
| 74 |
-
|
| 75 |
-
## Limitations
|
| 76 |
-
|
| 77 |
-
β οΈ **This system has known limitations:**
|
| 78 |
-
|
| 79 |
-
- **Not adversarially robust**: Simple post-processing can defeat detection
|
| 80 |
-
- **Declining effectiveness**: Detection rates decrease as AI models improve
|
| 81 |
-
- **False positives**: 10-20% of real photos may be flagged (HDR, macro, heavily edited)
|
| 82 |
-
- **No semantic understanding**: Cannot detect deepfakes, inpainting, or prompt-guided generation
|
| 83 |
-
|
| 84 |
-
## Appropriate Use Cases
|
| 85 |
-
|
| 86 |
-
β
**Suitable for:**
|
| 87 |
-
- Content moderation pre-screening (reduces human workload)
|
| 88 |
-
- Journalism workflows (identifies images needing verification)
|
| 89 |
-
- Stock photo platforms (flags for manual review)
|
| 90 |
-
- Legal discovery (prioritizes suspicious documents)
|
| 91 |
-
|
| 92 |
-
β **Not suitable for:**
|
| 93 |
-
- Law enforcement as sole evidence
|
| 94 |
-
- Automated content rejection without human review
|
| 95 |
-
- High-stakes decisions (criminal prosecution, copyright disputes)
|
| 96 |
-
|
| 97 |
-
## Technical Details
|
| 98 |
-
|
| 99 |
-
- **Framework**: FastAPI (Python 3.11+)
|
| 100 |
-
- **Processing Time**: 2-4 seconds per image
|
| 101 |
-
- **Dependencies**: OpenCV, NumPy, SciPy, ReportLab
|
| 102 |
-
- **No ML Models**: Purely statistical detection (no GPU required)
|
| 103 |
-
|
| 104 |
-
## Credits
|
| 105 |
-
|
| 106 |
-
**Author**: Satyaki Mitra (Data Scientist, AI-ML Practitioner)
|
| 107 |
-
|
| 108 |
-
**Research Foundations**:
|
| 109 |
-
- Gragnaniello et al. (2021) - Gradient analysis for GAN detection
|
| 110 |
-
- Dzanic et al. (2020) - Fourier spectrum discrepancies
|
| 111 |
-
- Kirchner & Johnson (2019) - Sensor pattern noise analysis
|
| 112 |
-
- Nataraj et al. (2019) - Co-occurrence matrix detection
|
| 113 |
-
- Marra et al. (2019) - GAN-specific artifacts
|
| 114 |
-
|
| 115 |
-
## License
|
| 116 |
-
|
| 117 |
-
MIT License - See [LICENSE](LICENSE) for details
|
| 118 |
-
|
| 119 |
-
## Links
|
| 120 |
-
|
| 121 |
-
- π [Full Documentation](https://github.com/satyakimitra/ai-image-screener)
|
| 122 |
-
- ποΈ [Architecture Details](https://github.com/satyakimitra/ai-image-screener/blob/main/docs/Architecture.md)
|
| 123 |
-
- π [Case Study Analysis](https://github.com/satyakimitra/ai-image-screener/blob/main/docs/CaseStudy_Analysis.md)
|
| 124 |
-
- π¬ [API Reference](https://github.com/satyakimitra/ai-image-screener/blob/main/docs/API.md)
|
| 125 |
-
|
| 126 |
-
---
|
| 127 |
-
|
| 128 |
-
**Disclaimer**: Results are indicative and should be verified manually for critical applications. This system provides screening assistance, not definitive judgments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
all.txt
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
setup.sh
DELETED
|
@@ -1,138 +0,0 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
|
| 3 |
-
# =========================================
|
| 4 |
-
# AI Image Screener - Setup Script
|
| 5 |
-
# Run this after cloning the repository
|
| 6 |
-
# =========================================
|
| 7 |
-
|
| 8 |
-
set -e # Exit on error
|
| 9 |
-
|
| 10 |
-
echo "================================================"
|
| 11 |
-
echo "AI Image Screener - Setup"
|
| 12 |
-
echo "================================================"
|
| 13 |
-
echo ""
|
| 14 |
-
|
| 15 |
-
# Check Python version
|
| 16 |
-
echo "π Checking Python version..."
|
| 17 |
-
python_version=$(python3 --version 2>&1 | awk '{print $2}')
|
| 18 |
-
required_version="3.11"
|
| 19 |
-
|
| 20 |
-
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then
|
| 21 |
-
echo "β Error: Python 3.11+ required (found $python_version)"
|
| 22 |
-
exit 1
|
| 23 |
-
fi
|
| 24 |
-
echo "β
Python $python_version detected"
|
| 25 |
-
echo ""
|
| 26 |
-
|
| 27 |
-
# Create virtual environment
|
| 28 |
-
echo "π¦ Creating virtual environment..."
|
| 29 |
-
if [ ! -d "venv" ]; then
|
| 30 |
-
python3 -m venv venv
|
| 31 |
-
echo "β
Virtual environment created"
|
| 32 |
-
else
|
| 33 |
-
echo "β οΈ Virtual environment already exists"
|
| 34 |
-
fi
|
| 35 |
-
echo ""
|
| 36 |
-
|
| 37 |
-
# Activate virtual environment
|
| 38 |
-
echo "π Activating virtual environment..."
|
| 39 |
-
source venv/bin/activate || {
|
| 40 |
-
echo "β Failed to activate virtual environment"
|
| 41 |
-
exit 1
|
| 42 |
-
}
|
| 43 |
-
echo "β
Virtual environment activated"
|
| 44 |
-
echo ""
|
| 45 |
-
|
| 46 |
-
# Upgrade pip
|
| 47 |
-
echo "β¬οΈ Upgrading pip..."
|
| 48 |
-
pip install --upgrade pip setuptools wheel > /dev/null 2>&1
|
| 49 |
-
echo "β
pip upgraded"
|
| 50 |
-
echo ""
|
| 51 |
-
|
| 52 |
-
# Install dependencies
|
| 53 |
-
echo "π Installing dependencies..."
|
| 54 |
-
if [ -f "requirements.txt" ]; then
|
| 55 |
-
pip install -r requirements.txt
|
| 56 |
-
echo "β
Dependencies installed"
|
| 57 |
-
else
|
| 58 |
-
echo "β Error: requirements.txt not found"
|
| 59 |
-
exit 1
|
| 60 |
-
fi
|
| 61 |
-
echo ""
|
| 62 |
-
|
| 63 |
-
# Create directories
|
| 64 |
-
echo "π Creating required directories..."
|
| 65 |
-
mkdir -p data/uploads data/reports data/cache logs
|
| 66 |
-
touch data/uploads/.gitkeep
|
| 67 |
-
touch data/reports/.gitkeep
|
| 68 |
-
touch data/cache/.gitkeep
|
| 69 |
-
touch logs/.gitkeep
|
| 70 |
-
echo "β
Directories created"
|
| 71 |
-
echo ""
|
| 72 |
-
|
| 73 |
-
# Create .env file if not exists
|
| 74 |
-
echo "βοΈ Setting up environment..."
|
| 75 |
-
if [ ! -f ".env" ]; then
|
| 76 |
-
if [ -f ".env.example" ]; then
|
| 77 |
-
cp .env.example .env
|
| 78 |
-
echo "β
Created .env from .env.example"
|
| 79 |
-
echo " β οΈ Please review and update .env with your settings"
|
| 80 |
-
else
|
| 81 |
-
echo "β οΈ .env.example not found, skipping .env creation"
|
| 82 |
-
fi
|
| 83 |
-
else
|
| 84 |
-
echo "β οΈ .env already exists"
|
| 85 |
-
fi
|
| 86 |
-
echo ""
|
| 87 |
-
|
| 88 |
-
# Check system dependencies
|
| 89 |
-
echo "π Checking system dependencies..."
|
| 90 |
-
missing_deps=()
|
| 91 |
-
|
| 92 |
-
if ! command -v identify &> /dev/null; then
|
| 93 |
-
missing_deps+=("ImageMagick")
|
| 94 |
-
fi
|
| 95 |
-
|
| 96 |
-
if [ ${#missing_deps[@]} -gt 0 ]; then
|
| 97 |
-
echo "β οΈ Optional dependencies missing:"
|
| 98 |
-
for dep in "${missing_deps[@]}"; do
|
| 99 |
-
echo " - $dep"
|
| 100 |
-
done
|
| 101 |
-
echo " The app will work, but some features may be limited."
|
| 102 |
-
else
|
| 103 |
-
echo "β
All optional dependencies present"
|
| 104 |
-
fi
|
| 105 |
-
echo ""
|
| 106 |
-
|
| 107 |
-
# Test import
|
| 108 |
-
echo "π§ͺ Testing installation..."
|
| 109 |
-
if python3 -c "import fastapi, cv2, numpy, scipy, PIL, reportlab" 2>/dev/null; then
|
| 110 |
-
echo "β
All core packages import successfully"
|
| 111 |
-
else
|
| 112 |
-
echo "β Some packages failed to import"
|
| 113 |
-
echo " Try: pip install -r requirements.txt"
|
| 114 |
-
exit 1
|
| 115 |
-
fi
|
| 116 |
-
echo ""
|
| 117 |
-
|
| 118 |
-
echo "================================================"
|
| 119 |
-
echo "β¨ Setup Complete!"
|
| 120 |
-
echo "================================================"
|
| 121 |
-
echo ""
|
| 122 |
-
echo "Next steps:"
|
| 123 |
-
echo ""
|
| 124 |
-
echo "1. Review and update .env file (optional)"
|
| 125 |
-
echo "2. Start the server:"
|
| 126 |
-
echo " $ source venv/bin/activate"
|
| 127 |
-
echo " $ python app.py"
|
| 128 |
-
echo ""
|
| 129 |
-
echo "3. Open browser:"
|
| 130 |
-
echo " http://localhost:8005"
|
| 131 |
-
echo ""
|
| 132 |
-
echo "4. Or build Docker image:"
|
| 133 |
-
echo " $ docker build -t ai-image-screener ."
|
| 134 |
-
echo " $ docker run -p 7860:7860 ai-image-screener"
|
| 135 |
-
echo ""
|
| 136 |
-
echo "π Documentation: docs/"
|
| 137 |
-
echo "π Issues: https://github.com/satyakimitra/ai-image-screener/issues"
|
| 138 |
-
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|