Commit Β·
47b4cf3
1
Parent(s): 7c48088
Deploy DeepFake Detector API - 2026-04-19 23:51:12
Browse files- Dockerfile +47 -47
- Dockerfile.huggingface +47 -47
- README.md +182 -182
- README_HF.md +182 -182
- app/__pycache__/main.cpython-312.pyc +0 -0
- app/api/__pycache__/routes_predict.cpython-312.pyc +0 -0
- app/core/__pycache__/config.cpython-312.pyc +0 -0
- app/models/wrappers/__pycache__/base_wrapper.cpython-312.pyc +0 -0
- app/models/wrappers/__pycache__/cnn_transfer_wrapper.cpython-312.pyc +0 -0
- app/models/wrappers/__pycache__/deit_distilled_wrapper.cpython-312.pyc +0 -0
- app/models/wrappers/__pycache__/gradfield_cnn_wrapper.cpython-312.pyc +0 -0
- app/models/wrappers/__pycache__/logreg_fusion_wrapper.cpython-312.pyc +0 -0
- app/models/wrappers/__pycache__/vit_base_wrapper.cpython-312.pyc +0 -0
- app/schemas/__pycache__/predict.cpython-312.pyc +0 -0
- app/services/__pycache__/explainability.cpython-312.pyc +0 -0
- app/services/__pycache__/hf_hub_service.cpython-312.pyc +0 -0
- app/services/__pycache__/llm_service.cpython-312.pyc +0 -0
- app/services/__pycache__/model_registry.cpython-312.pyc +0 -0
Dockerfile
CHANGED
|
@@ -1,47 +1,47 @@
|
|
| 1 |
-
# DeepFake Detector API - Hugging Face Spaces Docker Image
|
| 2 |
-
# Optimized for HF Spaces deployment with GPU support
|
| 3 |
-
|
| 4 |
-
FROM python:3.11-slim
|
| 5 |
-
|
| 6 |
-
# Set working directory
|
| 7 |
-
WORKDIR /app
|
| 8 |
-
|
| 9 |
-
# Set environment variables
|
| 10 |
-
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 11 |
-
PYTHONUNBUFFERED=1 \
|
| 12 |
-
PIP_NO_CACHE_DIR=1 \
|
| 13 |
-
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 14 |
-
PORT=7860
|
| 15 |
-
|
| 16 |
-
# Install system dependencies
|
| 17 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
-
curl \
|
| 19 |
-
git \
|
| 20 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 21 |
-
|
| 22 |
-
# Create non-root user (HF Spaces requirement)
|
| 23 |
-
RUN useradd -m -u 1000 user
|
| 24 |
-
USER user
|
| 25 |
-
|
| 26 |
-
# Set PATH for user-installed packages
|
| 27 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
| 28 |
-
|
| 29 |
-
# Copy requirements and install dependencies as user
|
| 30 |
-
COPY --chown=user:user requirements.txt .
|
| 31 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 32 |
-
|
| 33 |
-
# Copy application code
|
| 34 |
-
COPY --chown=user:user . /app
|
| 35 |
-
|
| 36 |
-
# Switch to root to create cache directory and set permissions
|
| 37 |
-
USER root
|
| 38 |
-
RUN mkdir -p /app/.hf_cache && chown -R user:user /app/.hf_cache && chmod +x /app/start.sh
|
| 39 |
-
|
| 40 |
-
# Switch back to user
|
| 41 |
-
USER user
|
| 42 |
-
|
| 43 |
-
# Expose HF Spaces port
|
| 44 |
-
EXPOSE 7860
|
| 45 |
-
|
| 46 |
-
# Run the application (start.sh already defaults to port 7860)
|
| 47 |
-
CMD ["./start.sh"]
|
|
|
|
| 1 |
+
# DeepFake Detector API - Hugging Face Spaces Docker Image
|
| 2 |
+
# Optimized for HF Spaces deployment with GPU support
|
| 3 |
+
|
| 4 |
+
FROM python:3.11-slim
|
| 5 |
+
|
| 6 |
+
# Set working directory
|
| 7 |
+
WORKDIR /app
|
| 8 |
+
|
| 9 |
+
# Set environment variables
|
| 10 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 11 |
+
PYTHONUNBUFFERED=1 \
|
| 12 |
+
PIP_NO_CACHE_DIR=1 \
|
| 13 |
+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 14 |
+
PORT=7860
|
| 15 |
+
|
| 16 |
+
# Install system dependencies
|
| 17 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
+
curl \
|
| 19 |
+
git \
|
| 20 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 21 |
+
|
| 22 |
+
# Create non-root user (HF Spaces requirement)
|
| 23 |
+
RUN useradd -m -u 1000 user
|
| 24 |
+
USER user
|
| 25 |
+
|
| 26 |
+
# Set PATH for user-installed packages
|
| 27 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 28 |
+
|
| 29 |
+
# Copy requirements and install dependencies as user
|
| 30 |
+
COPY --chown=user:user requirements.txt .
|
| 31 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 32 |
+
|
| 33 |
+
# Copy application code
|
| 34 |
+
COPY --chown=user:user . /app
|
| 35 |
+
|
| 36 |
+
# Switch to root to create cache directory and set permissions
|
| 37 |
+
USER root
|
| 38 |
+
RUN mkdir -p /app/.hf_cache && chown -R user:user /app/.hf_cache && chmod +x /app/start.sh
|
| 39 |
+
|
| 40 |
+
# Switch back to user
|
| 41 |
+
USER user
|
| 42 |
+
|
| 43 |
+
# Expose HF Spaces port
|
| 44 |
+
EXPOSE 7860
|
| 45 |
+
|
| 46 |
+
# Run the application (start.sh already defaults to port 7860)
|
| 47 |
+
CMD ["./start.sh"]
|
Dockerfile.huggingface
CHANGED
|
@@ -1,47 +1,47 @@
|
|
| 1 |
-
# DeepFake Detector API - Hugging Face Spaces Docker Image
|
| 2 |
-
# Optimized for HF Spaces deployment with GPU support
|
| 3 |
-
|
| 4 |
-
FROM python:3.11-slim
|
| 5 |
-
|
| 6 |
-
# Set working directory
|
| 7 |
-
WORKDIR /app
|
| 8 |
-
|
| 9 |
-
# Set environment variables
|
| 10 |
-
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 11 |
-
PYTHONUNBUFFERED=1 \
|
| 12 |
-
PIP_NO_CACHE_DIR=1 \
|
| 13 |
-
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 14 |
-
PORT=7860
|
| 15 |
-
|
| 16 |
-
# Install system dependencies
|
| 17 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
-
curl \
|
| 19 |
-
git \
|
| 20 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 21 |
-
|
| 22 |
-
# Create non-root user (HF Spaces requirement)
|
| 23 |
-
RUN useradd -m -u 1000 user
|
| 24 |
-
USER user
|
| 25 |
-
|
| 26 |
-
# Set PATH for user-installed packages
|
| 27 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
| 28 |
-
|
| 29 |
-
# Copy requirements and install dependencies as user
|
| 30 |
-
COPY --chown=user:user requirements.txt .
|
| 31 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 32 |
-
|
| 33 |
-
# Copy application code
|
| 34 |
-
COPY --chown=user:user . /app
|
| 35 |
-
|
| 36 |
-
# Switch to root to create cache directory and set permissions
|
| 37 |
-
USER root
|
| 38 |
-
RUN mkdir -p /app/.hf_cache && chown -R user:user /app/.hf_cache && chmod +x /app/start.sh
|
| 39 |
-
|
| 40 |
-
# Switch back to user
|
| 41 |
-
USER user
|
| 42 |
-
|
| 43 |
-
# Expose HF Spaces port
|
| 44 |
-
EXPOSE 7860
|
| 45 |
-
|
| 46 |
-
# Run the application (start.sh already defaults to port 7860)
|
| 47 |
-
CMD ["./start.sh"]
|
|
|
|
| 1 |
+
# DeepFake Detector API - Hugging Face Spaces Docker Image
|
| 2 |
+
# Optimized for HF Spaces deployment with GPU support
|
| 3 |
+
|
| 4 |
+
FROM python:3.11-slim
|
| 5 |
+
|
| 6 |
+
# Set working directory
|
| 7 |
+
WORKDIR /app
|
| 8 |
+
|
| 9 |
+
# Set environment variables
|
| 10 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 11 |
+
PYTHONUNBUFFERED=1 \
|
| 12 |
+
PIP_NO_CACHE_DIR=1 \
|
| 13 |
+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 14 |
+
PORT=7860
|
| 15 |
+
|
| 16 |
+
# Install system dependencies
|
| 17 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
+
curl \
|
| 19 |
+
git \
|
| 20 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 21 |
+
|
| 22 |
+
# Create non-root user (HF Spaces requirement)
|
| 23 |
+
RUN useradd -m -u 1000 user
|
| 24 |
+
USER user
|
| 25 |
+
|
| 26 |
+
# Set PATH for user-installed packages
|
| 27 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 28 |
+
|
| 29 |
+
# Copy requirements and install dependencies as user
|
| 30 |
+
COPY --chown=user:user requirements.txt .
|
| 31 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 32 |
+
|
| 33 |
+
# Copy application code
|
| 34 |
+
COPY --chown=user:user . /app
|
| 35 |
+
|
| 36 |
+
# Switch to root to create cache directory and set permissions
|
| 37 |
+
USER root
|
| 38 |
+
RUN mkdir -p /app/.hf_cache && chown -R user:user /app/.hf_cache && chmod +x /app/start.sh
|
| 39 |
+
|
| 40 |
+
# Switch back to user
|
| 41 |
+
USER user
|
| 42 |
+
|
| 43 |
+
# Expose HF Spaces port
|
| 44 |
+
EXPOSE 7860
|
| 45 |
+
|
| 46 |
+
# Run the application (start.sh already defaults to port 7860)
|
| 47 |
+
CMD ["./start.sh"]
|
README.md
CHANGED
|
@@ -1,182 +1,182 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: DeepFake Detector API
|
| 3 |
-
emoji: π
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 7860
|
| 8 |
-
---
|
| 9 |
-
|
| 10 |
-
# π DeepFake Detector API
|
| 11 |
-
|
| 12 |
-
FastAPI backend for detecting AI-generated (deepfake) images using an ensemble of state-of-the-art deep learning models.
|
| 13 |
-
|
| 14 |
-
## π€ Models
|
| 15 |
-
|
| 16 |
-
This API uses a fusion ensemble of 5 deep learning models:
|
| 17 |
-
|
| 18 |
-
- **CNN Transfer** (EfficientNet-B0) - Transfer learning from ImageNet
|
| 19 |
-
- **ViT Base** (Vision Transformer) - Attention-based architecture
|
| 20 |
-
- **DeiT Distilled** (Data-efficient Image Transformer) - Distilled ViT variant
|
| 21 |
-
- **Gradient Field CNN** - Custom architecture analyzing gradient patterns
|
| 22 |
-
- **FFT CNN** - Frequency domain analysis using Fast Fourier Transform
|
| 23 |
-
|
| 24 |
-
All models are combined using a **Logistic Regression stacking ensemble** for optimal accuracy.
|
| 25 |
-
|
| 26 |
-
## π API Endpoints
|
| 27 |
-
|
| 28 |
-
| Endpoint | Method | Description |
|
| 29 |
-
|----------|--------|-------------|
|
| 30 |
-
| `/health` | GET | Health check - returns API status |
|
| 31 |
-
| `/ready` | GET | Model readiness check - confirms models are loaded |
|
| 32 |
-
| `/models` | GET | List all loaded models with metadata |
|
| 33 |
-
| `/predict` | POST | Predict if an image is real or AI-generated |
|
| 34 |
-
| `/docs` | GET | Interactive Swagger API documentation |
|
| 35 |
-
| `/redoc` | GET | Alternative API documentation |
|
| 36 |
-
|
| 37 |
-
## π Usage Example
|
| 38 |
-
|
| 39 |
-
### Using cURL
|
| 40 |
-
|
| 41 |
-
```bash
|
| 42 |
-
# Check if API is ready
|
| 43 |
-
curl https://lukhsaankumar-deepfakedetectorbackend.hf.space/ready
|
| 44 |
-
|
| 45 |
-
# Make a prediction
|
| 46 |
-
curl -X POST "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict" \
|
| 47 |
-
-F "file=@image.jpg" \
|
| 48 |
-
-F "explain=true"
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
### Using Python
|
| 52 |
-
|
| 53 |
-
```python
|
| 54 |
-
import requests
|
| 55 |
-
|
| 56 |
-
# Upload an image for prediction
|
| 57 |
-
url = "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict"
|
| 58 |
-
files = {"file": open("image.jpg", "rb")}
|
| 59 |
-
data = {"explain": True}
|
| 60 |
-
|
| 61 |
-
response = requests.post(url, files=files, data=data)
|
| 62 |
-
result = response.json()
|
| 63 |
-
|
| 64 |
-
print(f"Prediction: {result['prediction']}")
|
| 65 |
-
print(f"Confidence: {result['confidence']:.2%}")
|
| 66 |
-
print(f"Explanation: {result['explanation']}")
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
## π― Response Format
|
| 70 |
-
|
| 71 |
-
```json
|
| 72 |
-
{
|
| 73 |
-
"prediction": "fake",
|
| 74 |
-
"confidence": 0.8734,
|
| 75 |
-
"probabilities": {
|
| 76 |
-
"real": 0.1266,
|
| 77 |
-
"fake": 0.8734
|
| 78 |
-
},
|
| 79 |
-
"model_predictions": {
|
| 80 |
-
"cnn_transfer": {"prediction": "fake", "confidence": 0.89},
|
| 81 |
-
"vit_base": {"prediction": "fake", "confidence": 0.92},
|
| 82 |
-
"deit": {"prediction": "fake", "confidence": 0.85},
|
| 83 |
-
"gradient_field": {"prediction": "real", "confidence": 0.55},
|
| 84 |
-
"fft_cnn": {"prediction": "fake", "confidence": 0.78}
|
| 85 |
-
},
|
| 86 |
-
"fusion_confidence": 0.8734,
|
| 87 |
-
"explanation": "AI-powered analysis of the prediction...",
|
| 88 |
-
"processing_time_ms": 342
|
| 89 |
-
}
|
| 90 |
-
```
|
| 91 |
-
|
| 92 |
-
## π§ Configuration
|
| 93 |
-
|
| 94 |
-
### Required Secrets
|
| 95 |
-
|
| 96 |
-
Set these in your Space Settings β Repository secrets:
|
| 97 |
-
|
| 98 |
-
| Secret | Description | Required |
|
| 99 |
-
|--------|-------------|----------|
|
| 100 |
-
| `GOOGLE_API_KEY` | Google Gemini API key for AI explanations | Yes |
|
| 101 |
-
| `HF_TOKEN` | Hugging Face token (auto-set by Spaces) | No |
|
| 102 |
-
|
| 103 |
-
### Optional Environment Variables
|
| 104 |
-
|
| 105 |
-
| Variable | Default | Description |
|
| 106 |
-
|----------|---------|-------------|
|
| 107 |
-
| `HF_FUSION_REPO_ID` | `DeepFakeDetector/fusion-logreg-final` | Hugging Face model repository |
|
| 108 |
-
| `CORS_ORIGINS` | Multiple defaults | Comma-separated allowed CORS origins |
|
| 109 |
-
| `GEMINI_MODEL` | `gemini-2.5-flash` | Gemini model for explanations |
|
| 110 |
-
|
| 111 |
-
## ποΈ Architecture
|
| 112 |
-
|
| 113 |
-
```
|
| 114 |
-
βββββββββββββββ
|
| 115 |
-
β Client β
|
| 116 |
-
ββββββββ¬βββββββ
|
| 117 |
-
β
|
| 118 |
-
βΌ
|
| 119 |
-
βββββββββββββββββββββββββββββββββββ
|
| 120 |
-
β FastAPI Backend β
|
| 121 |
-
β ββββββββββββββββββββββββββββ β
|
| 122 |
-
β β Model Registry β β
|
| 123 |
-
β β ββββββββββββββββββββ
|
| 124 |
-
β β β CNN Transfer β β β
|
| 125 |
-
β β β ViT Base β β β
|
| 126 |
-
β β β DeiT Distilled β β β
|
| 127 |
-
β β β Gradient Field β β β
|
| 128 |
-
β β β FFT CNN β β β
|
| 129 |
-
β β ββββββββββββββββββββββ β β
|
| 130 |
-
β β ββββββββββββββββββββββ β β
|
| 131 |
-
β β β Fusion Ensemble β β β
|
| 132 |
-
β β β (LogReg Stacking) β β β
|
| 133 |
-
β β ββββββββββββββββββββββ β β
|
| 134 |
-
β ββββββββββββββββββββββββββββ β
|
| 135 |
-
β ββββββββββββββββββββββββββββ β
|
| 136 |
-
β β Gemini Explainer β β
|
| 137 |
-
β ββββββββββββββββββββββββββββ β
|
| 138 |
-
βββββββββββββββββββββββββββββββββββ
|
| 139 |
-
```
|
| 140 |
-
|
| 141 |
-
## π Performance
|
| 142 |
-
|
| 143 |
-
- **Accuracy**: ~87% on test set (OpenFake dataset)
|
| 144 |
-
- **Inference Time**: ~200-500ms per image (with GPU)
|
| 145 |
-
- **Model Size**: ~500MB total
|
| 146 |
-
- **Supported Formats**: JPG, PNG, WEBP
|
| 147 |
-
|
| 148 |
-
## π Troubleshooting
|
| 149 |
-
|
| 150 |
-
### Models not loading?
|
| 151 |
-
- Check the Logs tab for specific errors
|
| 152 |
-
- Verify `HF_FUSION_REPO_ID` points to a valid repository
|
| 153 |
-
- Ensure the repository is public or `HF_TOKEN` is set
|
| 154 |
-
|
| 155 |
-
### Explanations not working?
|
| 156 |
-
- Verify `GOOGLE_API_KEY` is set in Space Settings
|
| 157 |
-
- Check if you have Gemini API quota remaining
|
| 158 |
-
- Review logs for API errors
|
| 159 |
-
|
| 160 |
-
### CORS errors?
|
| 161 |
-
- Add your frontend domain to `CORS_ORIGINS` in Space Settings
|
| 162 |
-
- Format: `https://yourdomain.com,https://www.yourdomain.com`
|
| 163 |
-
|
| 164 |
-
## π Documentation
|
| 165 |
-
|
| 166 |
-
- **Interactive Docs**: Visit `/docs` for Swagger UI
|
| 167 |
-
- **ReDoc**: Visit `/redoc` for alternative documentation
|
| 168 |
-
- **Source Code**: [GitHub Repository](https://github.com/lukhsaankumar/DeepFakeDetector)
|
| 169 |
-
|
| 170 |
-
## π License
|
| 171 |
-
|
| 172 |
-
This project is part of the MacAI Society research initiative.
|
| 173 |
-
|
| 174 |
-
## π Acknowledgments
|
| 175 |
-
|
| 176 |
-
- Models trained on OpenFake, ImageNet, and custom datasets
|
| 177 |
-
- Powered by PyTorch, Hugging Face, and FastAPI
|
| 178 |
-
- AI explanations by Google Gemini
|
| 179 |
-
|
| 180 |
-
---
|
| 181 |
-
|
| 182 |
-
**Built with β€οΈ by MacAI Society**
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: DeepFake Detector API
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# π DeepFake Detector API
|
| 11 |
+
|
| 12 |
+
FastAPI backend for detecting AI-generated (deepfake) images using an ensemble of state-of-the-art deep learning models.
|
| 13 |
+
|
| 14 |
+
## π€ Models
|
| 15 |
+
|
| 16 |
+
This API uses a fusion ensemble of 5 deep learning models:
|
| 17 |
+
|
| 18 |
+
- **CNN Transfer** (EfficientNet-B0) - Transfer learning from ImageNet
|
| 19 |
+
- **ViT Base** (Vision Transformer) - Attention-based architecture
|
| 20 |
+
- **DeiT Distilled** (Data-efficient Image Transformer) - Distilled ViT variant
|
| 21 |
+
- **Gradient Field CNN** - Custom architecture analyzing gradient patterns
|
| 22 |
+
- **FFT CNN** - Frequency domain analysis using Fast Fourier Transform
|
| 23 |
+
|
| 24 |
+
All models are combined using a **Logistic Regression stacking ensemble** for optimal accuracy.
|
| 25 |
+
|
| 26 |
+
## π API Endpoints
|
| 27 |
+
|
| 28 |
+
| Endpoint | Method | Description |
|
| 29 |
+
|----------|--------|-------------|
|
| 30 |
+
| `/health` | GET | Health check - returns API status |
|
| 31 |
+
| `/ready` | GET | Model readiness check - confirms models are loaded |
|
| 32 |
+
| `/models` | GET | List all loaded models with metadata |
|
| 33 |
+
| `/predict` | POST | Predict if an image is real or AI-generated |
|
| 34 |
+
| `/docs` | GET | Interactive Swagger API documentation |
|
| 35 |
+
| `/redoc` | GET | Alternative API documentation |
|
| 36 |
+
|
| 37 |
+
## π Usage Example
|
| 38 |
+
|
| 39 |
+
### Using cURL
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
# Check if API is ready
|
| 43 |
+
curl https://lukhsaankumar-deepfakedetectorbackend.hf.space/ready
|
| 44 |
+
|
| 45 |
+
# Make a prediction
|
| 46 |
+
curl -X POST "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict" \
|
| 47 |
+
-F "file=@image.jpg" \
|
| 48 |
+
-F "explain=true"
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Using Python
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import requests
|
| 55 |
+
|
| 56 |
+
# Upload an image for prediction
|
| 57 |
+
url = "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict"
|
| 58 |
+
files = {"file": open("image.jpg", "rb")}
|
| 59 |
+
data = {"explain": True}
|
| 60 |
+
|
| 61 |
+
response = requests.post(url, files=files, data=data)
|
| 62 |
+
result = response.json()
|
| 63 |
+
|
| 64 |
+
print(f"Prediction: {result['prediction']}")
|
| 65 |
+
print(f"Confidence: {result['confidence']:.2%}")
|
| 66 |
+
print(f"Explanation: {result['explanation']}")
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## π― Response Format
|
| 70 |
+
|
| 71 |
+
```json
|
| 72 |
+
{
|
| 73 |
+
"prediction": "fake",
|
| 74 |
+
"confidence": 0.8734,
|
| 75 |
+
"probabilities": {
|
| 76 |
+
"real": 0.1266,
|
| 77 |
+
"fake": 0.8734
|
| 78 |
+
},
|
| 79 |
+
"model_predictions": {
|
| 80 |
+
"cnn_transfer": {"prediction": "fake", "confidence": 0.89},
|
| 81 |
+
"vit_base": {"prediction": "fake", "confidence": 0.92},
|
| 82 |
+
"deit": {"prediction": "fake", "confidence": 0.85},
|
| 83 |
+
"gradient_field": {"prediction": "real", "confidence": 0.55},
|
| 84 |
+
"fft_cnn": {"prediction": "fake", "confidence": 0.78}
|
| 85 |
+
},
|
| 86 |
+
"fusion_confidence": 0.8734,
|
| 87 |
+
"explanation": "AI-powered analysis of the prediction...",
|
| 88 |
+
"processing_time_ms": 342
|
| 89 |
+
}
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## π§ Configuration
|
| 93 |
+
|
| 94 |
+
### Required Secrets
|
| 95 |
+
|
| 96 |
+
Set these in your Space Settings β Repository secrets:
|
| 97 |
+
|
| 98 |
+
| Secret | Description | Required |
|
| 99 |
+
|--------|-------------|----------|
|
| 100 |
+
| `GOOGLE_API_KEY` | Google Gemini API key for AI explanations | Yes |
|
| 101 |
+
| `HF_TOKEN` | Hugging Face token (auto-set by Spaces) | No |
|
| 102 |
+
|
| 103 |
+
### Optional Environment Variables
|
| 104 |
+
|
| 105 |
+
| Variable | Default | Description |
|
| 106 |
+
|----------|---------|-------------|
|
| 107 |
+
| `HF_FUSION_REPO_ID` | `DeepFakeDetector/fusion-logreg-final` | Hugging Face model repository |
|
| 108 |
+
| `CORS_ORIGINS` | Multiple defaults | Comma-separated allowed CORS origins |
|
| 109 |
+
| `GEMINI_MODEL` | `gemini-2.5-flash` | Gemini model for explanations |
|
| 110 |
+
|
| 111 |
+
## ποΈ Architecture
|
| 112 |
+
|
| 113 |
+
```
|
| 114 |
+
βββββββββββββββ
|
| 115 |
+
β Client β
|
| 116 |
+
ββββββββ¬βββββββ
|
| 117 |
+
β
|
| 118 |
+
βΌ
|
| 119 |
+
βββββββββββββββββββββββββββββββββββ
|
| 120 |
+
β FastAPI Backend β
|
| 121 |
+
β ββββββββββββββββββββββββββββ β
|
| 122 |
+
β β Model Registry β β
|
| 123 |
+
β β βοΏ½οΏ½οΏ½ββββββββββββββββββββ β β
|
| 124 |
+
β β β CNN Transfer β β β
|
| 125 |
+
β β β ViT Base β β β
|
| 126 |
+
β β β DeiT Distilled β β β
|
| 127 |
+
β β β Gradient Field β β β
|
| 128 |
+
β β β FFT CNN β β β
|
| 129 |
+
β β ββββββββββββββββββββββ β β
|
| 130 |
+
β β ββββββββββββββββββββββ β β
|
| 131 |
+
β β β Fusion Ensemble β β β
|
| 132 |
+
β β β (LogReg Stacking) β β β
|
| 133 |
+
β β ββββββββββββββββββββββ β β
|
| 134 |
+
β ββββββββββββββββββββββββββββ β
|
| 135 |
+
β ββββββββββββββββββββββββββββ β
|
| 136 |
+
β β Gemini Explainer β β
|
| 137 |
+
β ββββββββββββββββββββββββββββ β
|
| 138 |
+
βββββββββββββββββββββββββββββββββββ
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
## π Performance
|
| 142 |
+
|
| 143 |
+
- **Accuracy**: ~87% on test set (OpenFake dataset)
|
| 144 |
+
- **Inference Time**: ~200-500ms per image (with GPU)
|
| 145 |
+
- **Model Size**: ~500MB total
|
| 146 |
+
- **Supported Formats**: JPG, PNG, WEBP
|
| 147 |
+
|
| 148 |
+
## π Troubleshooting
|
| 149 |
+
|
| 150 |
+
### Models not loading?
|
| 151 |
+
- Check the Logs tab for specific errors
|
| 152 |
+
- Verify `HF_FUSION_REPO_ID` points to a valid repository
|
| 153 |
+
- Ensure the repository is public or `HF_TOKEN` is set
|
| 154 |
+
|
| 155 |
+
### Explanations not working?
|
| 156 |
+
- Verify `GOOGLE_API_KEY` is set in Space Settings
|
| 157 |
+
- Check if you have Gemini API quota remaining
|
| 158 |
+
- Review logs for API errors
|
| 159 |
+
|
| 160 |
+
### CORS errors?
|
| 161 |
+
- Add your frontend domain to `CORS_ORIGINS` in Space Settings
|
| 162 |
+
- Format: `https://yourdomain.com,https://www.yourdomain.com`
|
| 163 |
+
|
| 164 |
+
## π Documentation
|
| 165 |
+
|
| 166 |
+
- **Interactive Docs**: Visit `/docs` for Swagger UI
|
| 167 |
+
- **ReDoc**: Visit `/redoc` for alternative documentation
|
| 168 |
+
- **Source Code**: [GitHub Repository](https://github.com/lukhsaankumar/DeepFakeDetector)
|
| 169 |
+
|
| 170 |
+
## π License
|
| 171 |
+
|
| 172 |
+
This project is part of the MacAI Society research initiative.
|
| 173 |
+
|
| 174 |
+
## π Acknowledgments
|
| 175 |
+
|
| 176 |
+
- Models trained on OpenFake, ImageNet, and custom datasets
|
| 177 |
+
- Powered by PyTorch, Hugging Face, and FastAPI
|
| 178 |
+
- AI explanations by Google Gemini
|
| 179 |
+
|
| 180 |
+
---
|
| 181 |
+
|
| 182 |
+
**Built with β€οΈ by MacAI Society**
|
README_HF.md
CHANGED
|
@@ -1,182 +1,182 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: DeepFake Detector API
|
| 3 |
-
emoji: π
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 7860
|
| 8 |
-
---
|
| 9 |
-
|
| 10 |
-
# π DeepFake Detector API
|
| 11 |
-
|
| 12 |
-
FastAPI backend for detecting AI-generated (deepfake) images using an ensemble of state-of-the-art deep learning models.
|
| 13 |
-
|
| 14 |
-
## π€ Models
|
| 15 |
-
|
| 16 |
-
This API uses a fusion ensemble of 5 deep learning models:
|
| 17 |
-
|
| 18 |
-
- **CNN Transfer** (EfficientNet-B0) - Transfer learning from ImageNet
|
| 19 |
-
- **ViT Base** (Vision Transformer) - Attention-based architecture
|
| 20 |
-
- **DeiT Distilled** (Data-efficient Image Transformer) - Distilled ViT variant
|
| 21 |
-
- **Gradient Field CNN** - Custom architecture analyzing gradient patterns
|
| 22 |
-
- **FFT CNN** - Frequency domain analysis using Fast Fourier Transform
|
| 23 |
-
|
| 24 |
-
All models are combined using a **Logistic Regression stacking ensemble** for optimal accuracy.
|
| 25 |
-
|
| 26 |
-
## π API Endpoints
|
| 27 |
-
|
| 28 |
-
| Endpoint | Method | Description |
|
| 29 |
-
|----------|--------|-------------|
|
| 30 |
-
| `/health` | GET | Health check - returns API status |
|
| 31 |
-
| `/ready` | GET | Model readiness check - confirms models are loaded |
|
| 32 |
-
| `/models` | GET | List all loaded models with metadata |
|
| 33 |
-
| `/predict` | POST | Predict if an image is real or AI-generated |
|
| 34 |
-
| `/docs` | GET | Interactive Swagger API documentation |
|
| 35 |
-
| `/redoc` | GET | Alternative API documentation |
|
| 36 |
-
|
| 37 |
-
## π Usage Example
|
| 38 |
-
|
| 39 |
-
### Using cURL
|
| 40 |
-
|
| 41 |
-
```bash
|
| 42 |
-
# Check if API is ready
|
| 43 |
-
curl https://lukhsaankumar-deepfakedetectorbackend.hf.space/ready
|
| 44 |
-
|
| 45 |
-
# Make a prediction
|
| 46 |
-
curl -X POST "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict" \
|
| 47 |
-
-F "file=@image.jpg" \
|
| 48 |
-
-F "explain=true"
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
### Using Python
|
| 52 |
-
|
| 53 |
-
```python
|
| 54 |
-
import requests
|
| 55 |
-
|
| 56 |
-
# Upload an image for prediction
|
| 57 |
-
url = "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict"
|
| 58 |
-
files = {"file": open("image.jpg", "rb")}
|
| 59 |
-
data = {"explain": True}
|
| 60 |
-
|
| 61 |
-
response = requests.post(url, files=files, data=data)
|
| 62 |
-
result = response.json()
|
| 63 |
-
|
| 64 |
-
print(f"Prediction: {result['prediction']}")
|
| 65 |
-
print(f"Confidence: {result['confidence']:.2%}")
|
| 66 |
-
print(f"Explanation: {result['explanation']}")
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
## π― Response Format
|
| 70 |
-
|
| 71 |
-
```json
|
| 72 |
-
{
|
| 73 |
-
"prediction": "fake",
|
| 74 |
-
"confidence": 0.8734,
|
| 75 |
-
"probabilities": {
|
| 76 |
-
"real": 0.1266,
|
| 77 |
-
"fake": 0.8734
|
| 78 |
-
},
|
| 79 |
-
"model_predictions": {
|
| 80 |
-
"cnn_transfer": {"prediction": "fake", "confidence": 0.89},
|
| 81 |
-
"vit_base": {"prediction": "fake", "confidence": 0.92},
|
| 82 |
-
"deit": {"prediction": "fake", "confidence": 0.85},
|
| 83 |
-
"gradient_field": {"prediction": "real", "confidence": 0.55},
|
| 84 |
-
"fft_cnn": {"prediction": "fake", "confidence": 0.78}
|
| 85 |
-
},
|
| 86 |
-
"fusion_confidence": 0.8734,
|
| 87 |
-
"explanation": "AI-powered analysis of the prediction...",
|
| 88 |
-
"processing_time_ms": 342
|
| 89 |
-
}
|
| 90 |
-
```
|
| 91 |
-
|
| 92 |
-
## π§ Configuration
|
| 93 |
-
|
| 94 |
-
### Required Secrets
|
| 95 |
-
|
| 96 |
-
Set these in your Space Settings β Repository secrets:
|
| 97 |
-
|
| 98 |
-
| Secret | Description | Required |
|
| 99 |
-
|--------|-------------|----------|
|
| 100 |
-
| `GOOGLE_API_KEY` | Google Gemini API key for AI explanations | Yes |
|
| 101 |
-
| `HF_TOKEN` | Hugging Face token (auto-set by Spaces) | No |
|
| 102 |
-
|
| 103 |
-
### Optional Environment Variables
|
| 104 |
-
|
| 105 |
-
| Variable | Default | Description |
|
| 106 |
-
|----------|---------|-------------|
|
| 107 |
-
| `HF_FUSION_REPO_ID` | `DeepFakeDetector/fusion-logreg-final` | Hugging Face model repository |
|
| 108 |
-
| `CORS_ORIGINS` | Multiple defaults | Comma-separated allowed CORS origins |
|
| 109 |
-
| `GEMINI_MODEL` | `gemini-2.5-flash` | Gemini model for explanations |
|
| 110 |
-
|
| 111 |
-
## ποΈ Architecture
|
| 112 |
-
|
| 113 |
-
```
|
| 114 |
-
βββββββββββββββ
|
| 115 |
-
β Client β
|
| 116 |
-
ββββββββ¬βββββββ
|
| 117 |
-
β
|
| 118 |
-
βΌ
|
| 119 |
-
βββββββββββββββββββββββββββββββββββ
|
| 120 |
-
β FastAPI Backend β
|
| 121 |
-
β ββββββββββββββββββββββββββββ β
|
| 122 |
-
β β Model Registry β β
|
| 123 |
-
β β ββββββββββββββββββββ
|
| 124 |
-
β β β CNN Transfer β β β
|
| 125 |
-
β β β ViT Base β β β
|
| 126 |
-
β β β DeiT Distilled β β β
|
| 127 |
-
β β β Gradient Field β β β
|
| 128 |
-
β β β FFT CNN β β β
|
| 129 |
-
β β ββββββββββββββββββββββ β β
|
| 130 |
-
β β ββββββββββββββββββββββ β β
|
| 131 |
-
β β β Fusion Ensemble β β β
|
| 132 |
-
β β β (LogReg Stacking) β β β
|
| 133 |
-
β β ββββββββββββββββββββββ β β
|
| 134 |
-
β ββββββββββββββββββββββββββββ β
|
| 135 |
-
β ββββββββββββββββββββββββββββ β
|
| 136 |
-
β β Gemini Explainer β β
|
| 137 |
-
β ββββββββββββββββββββββββββββ β
|
| 138 |
-
βββββββββββββββββββββββββββββββββββ
|
| 139 |
-
```
|
| 140 |
-
|
| 141 |
-
## π Performance
|
| 142 |
-
|
| 143 |
-
- **Accuracy**: ~87% on test set (OpenFake dataset)
|
| 144 |
-
- **Inference Time**: ~200-500ms per image (with GPU)
|
| 145 |
-
- **Model Size**: ~500MB total
|
| 146 |
-
- **Supported Formats**: JPG, PNG, WEBP
|
| 147 |
-
|
| 148 |
-
## π Troubleshooting
|
| 149 |
-
|
| 150 |
-
### Models not loading?
|
| 151 |
-
- Check the Logs tab for specific errors
|
| 152 |
-
- Verify `HF_FUSION_REPO_ID` points to a valid repository
|
| 153 |
-
- Ensure the repository is public or `HF_TOKEN` is set
|
| 154 |
-
|
| 155 |
-
### Explanations not working?
|
| 156 |
-
- Verify `GOOGLE_API_KEY` is set in Space Settings
|
| 157 |
-
- Check if you have Gemini API quota remaining
|
| 158 |
-
- Review logs for API errors
|
| 159 |
-
|
| 160 |
-
### CORS errors?
|
| 161 |
-
- Add your frontend domain to `CORS_ORIGINS` in Space Settings
|
| 162 |
-
- Format: `https://yourdomain.com,https://www.yourdomain.com`
|
| 163 |
-
|
| 164 |
-
## π Documentation
|
| 165 |
-
|
| 166 |
-
- **Interactive Docs**: Visit `/docs` for Swagger UI
|
| 167 |
-
- **ReDoc**: Visit `/redoc` for alternative documentation
|
| 168 |
-
- **Source Code**: [GitHub Repository](https://github.com/lukhsaankumar/DeepFakeDetector)
|
| 169 |
-
|
| 170 |
-
## π License
|
| 171 |
-
|
| 172 |
-
This project is part of the MacAI Society research initiative.
|
| 173 |
-
|
| 174 |
-
## π Acknowledgments
|
| 175 |
-
|
| 176 |
-
- Models trained on OpenFake, ImageNet, and custom datasets
|
| 177 |
-
- Powered by PyTorch, Hugging Face, and FastAPI
|
| 178 |
-
- AI explanations by Google Gemini
|
| 179 |
-
|
| 180 |
-
---
|
| 181 |
-
|
| 182 |
-
**Built with β€οΈ by MacAI Society**
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: DeepFake Detector API
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# π DeepFake Detector API
|
| 11 |
+
|
| 12 |
+
FastAPI backend for detecting AI-generated (deepfake) images using an ensemble of state-of-the-art deep learning models.
|
| 13 |
+
|
| 14 |
+
## π€ Models
|
| 15 |
+
|
| 16 |
+
This API uses a fusion ensemble of 5 deep learning models:
|
| 17 |
+
|
| 18 |
+
- **CNN Transfer** (EfficientNet-B0) - Transfer learning from ImageNet
|
| 19 |
+
- **ViT Base** (Vision Transformer) - Attention-based architecture
|
| 20 |
+
- **DeiT Distilled** (Data-efficient Image Transformer) - Distilled ViT variant
|
| 21 |
+
- **Gradient Field CNN** - Custom architecture analyzing gradient patterns
|
| 22 |
+
- **FFT CNN** - Frequency domain analysis using Fast Fourier Transform
|
| 23 |
+
|
| 24 |
+
All models are combined using a **Logistic Regression stacking ensemble** for optimal accuracy.
|
| 25 |
+
|
| 26 |
+
## π API Endpoints
|
| 27 |
+
|
| 28 |
+
| Endpoint | Method | Description |
|
| 29 |
+
|----------|--------|-------------|
|
| 30 |
+
| `/health` | GET | Health check - returns API status |
|
| 31 |
+
| `/ready` | GET | Model readiness check - confirms models are loaded |
|
| 32 |
+
| `/models` | GET | List all loaded models with metadata |
|
| 33 |
+
| `/predict` | POST | Predict if an image is real or AI-generated |
|
| 34 |
+
| `/docs` | GET | Interactive Swagger API documentation |
|
| 35 |
+
| `/redoc` | GET | Alternative API documentation |
|
| 36 |
+
|
| 37 |
+
## π Usage Example
|
| 38 |
+
|
| 39 |
+
### Using cURL
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
# Check if API is ready
|
| 43 |
+
curl https://lukhsaankumar-deepfakedetectorbackend.hf.space/ready
|
| 44 |
+
|
| 45 |
+
# Make a prediction
|
| 46 |
+
curl -X POST "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict" \
|
| 47 |
+
-F "file=@image.jpg" \
|
| 48 |
+
-F "explain=true"
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Using Python
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import requests
|
| 55 |
+
|
| 56 |
+
# Upload an image for prediction
|
| 57 |
+
url = "https://lukhsaankumar-deepfakedetectorbackend.hf.space/predict"
|
| 58 |
+
files = {"file": open("image.jpg", "rb")}
|
| 59 |
+
data = {"explain": True}
|
| 60 |
+
|
| 61 |
+
response = requests.post(url, files=files, data=data)
|
| 62 |
+
result = response.json()
|
| 63 |
+
|
| 64 |
+
print(f"Prediction: {result['prediction']}")
|
| 65 |
+
print(f"Confidence: {result['confidence']:.2%}")
|
| 66 |
+
print(f"Explanation: {result['explanation']}")
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## π― Response Format
|
| 70 |
+
|
| 71 |
+
```json
|
| 72 |
+
{
|
| 73 |
+
"prediction": "fake",
|
| 74 |
+
"confidence": 0.8734,
|
| 75 |
+
"probabilities": {
|
| 76 |
+
"real": 0.1266,
|
| 77 |
+
"fake": 0.8734
|
| 78 |
+
},
|
| 79 |
+
"model_predictions": {
|
| 80 |
+
"cnn_transfer": {"prediction": "fake", "confidence": 0.89},
|
| 81 |
+
"vit_base": {"prediction": "fake", "confidence": 0.92},
|
| 82 |
+
"deit": {"prediction": "fake", "confidence": 0.85},
|
| 83 |
+
"gradient_field": {"prediction": "real", "confidence": 0.55},
|
| 84 |
+
"fft_cnn": {"prediction": "fake", "confidence": 0.78}
|
| 85 |
+
},
|
| 86 |
+
"fusion_confidence": 0.8734,
|
| 87 |
+
"explanation": "AI-powered analysis of the prediction...",
|
| 88 |
+
"processing_time_ms": 342
|
| 89 |
+
}
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## π§ Configuration
|
| 93 |
+
|
| 94 |
+
### Required Secrets
|
| 95 |
+
|
| 96 |
+
Set these in your Space Settings β Repository secrets:
|
| 97 |
+
|
| 98 |
+
| Secret | Description | Required |
|
| 99 |
+
|--------|-------------|----------|
|
| 100 |
+
| `GOOGLE_API_KEY` | Google Gemini API key for AI explanations | Yes |
|
| 101 |
+
| `HF_TOKEN` | Hugging Face token (auto-set by Spaces) | No |
|
| 102 |
+
|
| 103 |
+
### Optional Environment Variables
|
| 104 |
+
|
| 105 |
+
| Variable | Default | Description |
|
| 106 |
+
|----------|---------|-------------|
|
| 107 |
+
| `HF_FUSION_REPO_ID` | `DeepFakeDetector/fusion-logreg-final` | Hugging Face model repository |
|
| 108 |
+
| `CORS_ORIGINS` | Multiple defaults | Comma-separated allowed CORS origins |
|
| 109 |
+
| `GEMINI_MODEL` | `gemini-2.5-flash` | Gemini model for explanations |
|
| 110 |
+
|
| 111 |
+
## ποΈ Architecture
|
| 112 |
+
|
| 113 |
+
```
|
| 114 |
+
βββββββββββββββ
|
| 115 |
+
β Client β
|
| 116 |
+
ββββββββ¬βββββββ
|
| 117 |
+
β
|
| 118 |
+
βΌ
|
| 119 |
+
βββββββββββββββββββββββββββββββββββ
|
| 120 |
+
β FastAPI Backend β
|
| 121 |
+
β ββββββββββββββββββββββββββββ β
|
| 122 |
+
β β Model Registry β β
|
| 123 |
+
β β βοΏ½οΏ½οΏ½ββββββββββββββββββββ β β
|
| 124 |
+
β β β CNN Transfer β β β
|
| 125 |
+
β β β ViT Base β β β
|
| 126 |
+
β β β DeiT Distilled β β β
|
| 127 |
+
β β β Gradient Field β β β
|
| 128 |
+
β β β FFT CNN β β β
|
| 129 |
+
β β ββββββββββββββββββββββ β β
|
| 130 |
+
β β ββββββββββββββββββββββ β β
|
| 131 |
+
β β β Fusion Ensemble β β β
|
| 132 |
+
β β β (LogReg Stacking) β β β
|
| 133 |
+
β β ββββββββββββββββββββββ β β
|
| 134 |
+
β ββββββββββββββββββββββββββββ β
|
| 135 |
+
β ββββββββββββββββββββββββββββ β
|
| 136 |
+
β β Gemini Explainer β β
|
| 137 |
+
β ββββββββββββββββββββββββββββ β
|
| 138 |
+
βββββββββββββββββββββββββββββββββββ
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
## π Performance
|
| 142 |
+
|
| 143 |
+
- **Accuracy**: ~87% on test set (OpenFake dataset)
|
| 144 |
+
- **Inference Time**: ~200-500ms per image (with GPU)
|
| 145 |
+
- **Model Size**: ~500MB total
|
| 146 |
+
- **Supported Formats**: JPG, PNG, WEBP
|
| 147 |
+
|
| 148 |
+
## π Troubleshooting
|
| 149 |
+
|
| 150 |
+
### Models not loading?
|
| 151 |
+
- Check the Logs tab for specific errors
|
| 152 |
+
- Verify `HF_FUSION_REPO_ID` points to a valid repository
|
| 153 |
+
- Ensure the repository is public or `HF_TOKEN` is set
|
| 154 |
+
|
| 155 |
+
### Explanations not working?
|
| 156 |
+
- Verify `GOOGLE_API_KEY` is set in Space Settings
|
| 157 |
+
- Check if you have Gemini API quota remaining
|
| 158 |
+
- Review logs for API errors
|
| 159 |
+
|
| 160 |
+
### CORS errors?
|
| 161 |
+
- Add your frontend domain to `CORS_ORIGINS` in Space Settings
|
| 162 |
+
- Format: `https://yourdomain.com,https://www.yourdomain.com`
|
| 163 |
+
|
| 164 |
+
## π Documentation
|
| 165 |
+
|
| 166 |
+
- **Interactive Docs**: Visit `/docs` for Swagger UI
|
| 167 |
+
- **ReDoc**: Visit `/redoc` for alternative documentation
|
| 168 |
+
- **Source Code**: [GitHub Repository](https://github.com/lukhsaankumar/DeepFakeDetector)
|
| 169 |
+
|
| 170 |
+
## π License
|
| 171 |
+
|
| 172 |
+
This project is part of the MacAI Society research initiative.
|
| 173 |
+
|
| 174 |
+
## π Acknowledgments
|
| 175 |
+
|
| 176 |
+
- Models trained on OpenFake, ImageNet, and custom datasets
|
| 177 |
+
- Powered by PyTorch, Hugging Face, and FastAPI
|
| 178 |
+
- AI explanations by Google Gemini
|
| 179 |
+
|
| 180 |
+
---
|
| 181 |
+
|
| 182 |
+
**Built with β€οΈ by MacAI Society**
|
app/__pycache__/main.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/main.cpython-312.pyc and b/app/__pycache__/main.cpython-312.pyc differ
|
|
|
app/api/__pycache__/routes_predict.cpython-312.pyc
CHANGED
|
Binary files a/app/api/__pycache__/routes_predict.cpython-312.pyc and b/app/api/__pycache__/routes_predict.cpython-312.pyc differ
|
|
|
app/core/__pycache__/config.cpython-312.pyc
CHANGED
|
Binary files a/app/core/__pycache__/config.cpython-312.pyc and b/app/core/__pycache__/config.cpython-312.pyc differ
|
|
|
app/models/wrappers/__pycache__/base_wrapper.cpython-312.pyc
CHANGED
|
Binary files a/app/models/wrappers/__pycache__/base_wrapper.cpython-312.pyc and b/app/models/wrappers/__pycache__/base_wrapper.cpython-312.pyc differ
|
|
|
app/models/wrappers/__pycache__/cnn_transfer_wrapper.cpython-312.pyc
CHANGED
|
Binary files a/app/models/wrappers/__pycache__/cnn_transfer_wrapper.cpython-312.pyc and b/app/models/wrappers/__pycache__/cnn_transfer_wrapper.cpython-312.pyc differ
|
|
|
app/models/wrappers/__pycache__/deit_distilled_wrapper.cpython-312.pyc
CHANGED
|
Binary files a/app/models/wrappers/__pycache__/deit_distilled_wrapper.cpython-312.pyc and b/app/models/wrappers/__pycache__/deit_distilled_wrapper.cpython-312.pyc differ
|
|
|
app/models/wrappers/__pycache__/gradfield_cnn_wrapper.cpython-312.pyc
CHANGED
|
Binary files a/app/models/wrappers/__pycache__/gradfield_cnn_wrapper.cpython-312.pyc and b/app/models/wrappers/__pycache__/gradfield_cnn_wrapper.cpython-312.pyc differ
|
|
|
app/models/wrappers/__pycache__/logreg_fusion_wrapper.cpython-312.pyc
CHANGED
|
Binary files a/app/models/wrappers/__pycache__/logreg_fusion_wrapper.cpython-312.pyc and b/app/models/wrappers/__pycache__/logreg_fusion_wrapper.cpython-312.pyc differ
|
|
|
app/models/wrappers/__pycache__/vit_base_wrapper.cpython-312.pyc
CHANGED
|
Binary files a/app/models/wrappers/__pycache__/vit_base_wrapper.cpython-312.pyc and b/app/models/wrappers/__pycache__/vit_base_wrapper.cpython-312.pyc differ
|
|
|
app/schemas/__pycache__/predict.cpython-312.pyc
CHANGED
|
Binary files a/app/schemas/__pycache__/predict.cpython-312.pyc and b/app/schemas/__pycache__/predict.cpython-312.pyc differ
|
|
|
app/services/__pycache__/explainability.cpython-312.pyc
CHANGED
|
Binary files a/app/services/__pycache__/explainability.cpython-312.pyc and b/app/services/__pycache__/explainability.cpython-312.pyc differ
|
|
|
app/services/__pycache__/hf_hub_service.cpython-312.pyc
CHANGED
|
Binary files a/app/services/__pycache__/hf_hub_service.cpython-312.pyc and b/app/services/__pycache__/hf_hub_service.cpython-312.pyc differ
|
|
|
app/services/__pycache__/llm_service.cpython-312.pyc
CHANGED
|
Binary files a/app/services/__pycache__/llm_service.cpython-312.pyc and b/app/services/__pycache__/llm_service.cpython-312.pyc differ
|
|
|
app/services/__pycache__/model_registry.cpython-312.pyc
CHANGED
|
Binary files a/app/services/__pycache__/model_registry.cpython-312.pyc and b/app/services/__pycache__/model_registry.cpython-312.pyc differ
|
|
|