A newer version of the Gradio SDK is available:
6.8.0
π Forensic Image Analysis Agent
AI-powered forensic image analysis system that detects AI-generated, manipulated, or deepfake images using vision-capable LLMs and forensic tools.
π Features
- Vision Analysis: Direct image analysis using GPT-5
- Forensic Tools: Multiple forensic analysis tools including:
- JPEG compression analysis
- Frequency domain analysis (DCT/FFT)
- Denoiser residual statistics
- Error Level Analysis (ELA)
- TruFor AI-driven forgery detection
- Camera fingerprint extraction (noiseprint)
- Streaming Output: Real-time analysis updates
- Transparent Reasoning: Detailed explanations of findings
π Setup for Hugging Face Spaces
1. Create a New Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose:
- SDK: Gradio
- Hardware: CPU (or GPU if you need faster inference)
- Visibility: Public or Private
2. Upload Files
Upload these files to your Space:
app.py(main Gradio application)requirements_hf.txtβ copy/rename torequirements.txt(HF Spaces compatible dependencies)README.md(this file)src/directory (your source code)weights/directory (optional - TruFor weights will auto-download on first use)example_images/directory (optional, for examples)
Note: TruFor model weights (~500MB) will be automatically downloaded on first use. You can optionally pre-upload them to weights/trufor/trufor.pth.tar to skip the download.
3. Set API Key
- Go to your Space settings
- Navigate to "Variables and secrets"
- Add a new secret:
- Name:
OPENAI_API_KEY - Value: Your OpenAI API key
- Name:
4. Configure Space
Create or update .env file (optional, API key should be set via HF Secrets):
OPENAI_API_KEY=your-key-here
π― Usage
- Upload an Image: Click the image upload area or drag & drop an image
- Optional Query: Add a specific question about the image (e.g., "Is this AI-generated?")
- Configure Settings:
- Enable/disable forensic tools
- Choose LLM model (gpt-5.1 recommended)
- Adjust temperature
- Analyze: Click "π Analyze Image" button
- View Results: See detailed analysis with visual description, forensic findings, and conclusion
βοΈ Configuration
Models Supported
gpt-5.1(recommended) - Latest vision modelgpt-5- Standard GPT-5gpt-5-mini- Faster, more cost-effectivegpt-5-nano- Lightweight option
Forensic Tools
When enabled, the agent can use:
- analyze_jpeg_compression: Analyzes JPEG compression artifacts
- analyze_frequency_domain: DCT/FFT frequency analysis
- extract_residuals: Denoiser residual statistics
- perform_ela: Error Level Analysis
- perform_trufor: AI-driven forgery detection
- extract_noiseprint: Camera fingerprint extraction
- execute_python_code: Custom Python analysis
π Project Structure
.
βββ app.py # Gradio UI application
βββ app_requirements.txt # Dependencies for HF Spaces
βββ README.md # This file
βββ src/
β βββ agents/
β β βββ forensic_agent.py
β βββ tools/
β βββ forensic_tools.py
βββ weights/ # Model weights (if any)
π Privacy & Security
- Images are processed temporarily and deleted after analysis
- API keys are stored securely via Hugging Face Secrets
- No data is stored permanently
π Troubleshooting
API Key Issues
- Ensure
OPENAI_API_KEYis set in Space Secrets - Check that your API key is valid and has credits
Model Loading Issues
- For TruFor, ensure model weights are in
weights/trufor/ - Check that all dependencies are installed correctly
Memory Issues
- Use
gpt-5-minifor lower memory usage - Disable forensic tools if running on CPU-only hardware
π License
[Add your license here]
π Acknowledgments
- Built with LangChain and LangGraph
- Powered by OpenAI GPT-5
- UI built with Gradio