lukhsaankumar commited on
Commit
2de2f1c
Β·
1 Parent(s): 7ee6359

Deploy DeepFake Detector API - 2026-04-20 00:23:33

Browse files
Files changed (1) hide show
  1. README.md +43 -7
README.md CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  # DeepFake Detector Backend
2
 
3
  FastAPI backend for detecting AI-generated (deepfake) images using a multi-model fusion pipeline.
@@ -16,7 +26,7 @@ FastAPI backend for detecting AI-generated (deepfake) images using a multi-model
16
  - pip
17
 
18
  ## Quick Start (Local)
19
- docker run -p 7860:7860 deepfake-detector-api
20
  ```bash
21
  cd backend
22
 
@@ -32,7 +42,11 @@ cp .env.example .env # Windows PowerShell: Copy-Item .env.example .env
32
 
33
  # Run API
34
  uvicorn app.main:app --reload
35
- - copy backend files as-is (single `Dockerfile` setup)
 
 
 
 
36
  - `http://localhost:8000/redoc`
37
 
38
  ## Environment Configuration
@@ -40,12 +54,13 @@ uvicorn app.main:app --reload
40
  Use [backend/.env.example](.env.example) as the source of truth.
41
 
42
  Common runtime variables:
 
43
  - `HF_FUSION_REPO_ID` (default: `DeepFakeDetector/fusion-logreg-final`)
44
  - `HF_CACHE_DIR` (default: `.hf_cache`)
45
  - `HF_TOKEN` (optional; required for private model repos or non-interactive HF auth)
46
  - `GOOGLE_API_KEY` (optional; required for Gemini explanations)
47
  - `HOST` (default: `0.0.0.0`)
48
- - `PORT` (default: `8000`)
49
  - `CORS_ORIGINS` (comma-separated origins)
50
  - `ENABLE_DEBUG`, `LOG_LEVEL`
51
 
@@ -77,26 +92,33 @@ Build and run locally:
77
 
78
  ```bash
79
  docker build -t deepfake-detector-api .
80
- docker run -p 8000:8000 deepfake-detector-api
81
  ```
82
 
83
  ## Deploy to Hugging Face Spaces
84
 
85
- Recommended path is the Bash deploy script:
86
 
87
  1. Configure [backend/.env](.env) from [backend/.env.example](.env.example)
88
  2. Ensure `HF_SPACE_URL` and related deploy variables are set
89
- 3. Run from repo root:
90
 
91
  ```bash
92
  bash ./deploy-to-hf.sh
93
  ```
94
 
 
 
 
 
 
 
95
  The script will:
96
 
97
  - install Hugging Face CLI if needed
98
  - prompt/authenticate with HF (`hf auth login`) when required
99
  - clone Space repo into a separate temp deploy directory
 
100
  - commit and push to the HF Space
101
 
102
  After deploy, set Space secrets in Hugging Face:
@@ -104,6 +126,12 @@ After deploy, set Space secrets in Hugging Face:
104
  - `GOOGLE_API_KEY` (if using explanation endpoints)
105
  - `CORS_ORIGINS` (frontend domains)
106
 
 
 
 
 
 
 
107
  ## Troubleshooting
108
 
109
  - Build fails: inspect Space/Railway logs first
@@ -118,7 +146,15 @@ backend/
118
  β”œβ”€β”€ app/
119
  β”œβ”€β”€ tests/
120
  β”œβ”€β”€ Dockerfile
121
- β”œβ”€β”€ Dockerfile.huggingface
 
 
 
 
 
 
 
 
122
  β”œβ”€β”€ deploy-to-hf.sh
123
  β”œβ”€β”€ deploy-to-hf.ps1
124
  β”œβ”€β”€ requirements.txt
 
1
+ ---
2
+ title: DeepFake Detector API
3
+ emoji: 🎭
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
  # DeepFake Detector Backend
12
 
13
  FastAPI backend for detecting AI-generated (deepfake) images using a multi-model fusion pipeline.
 
26
  - pip
27
 
28
  ## Quick Start (Local)
29
+
30
  ```bash
31
  cd backend
32
 
 
42
 
43
  # Run API
44
  uvicorn app.main:app --reload
45
+ ```
46
+
47
+ API docs:
48
+
49
+ - `http://localhost:8000/docs`
50
  - `http://localhost:8000/redoc`
51
 
52
  ## Environment Configuration
 
54
  Use [backend/.env.example](.env.example) as the source of truth.
55
 
56
  Common runtime variables:
57
+
58
  - `HF_FUSION_REPO_ID` (default: `DeepFakeDetector/fusion-logreg-final`)
59
  - `HF_CACHE_DIR` (default: `.hf_cache`)
60
  - `HF_TOKEN` (optional; required for private model repos or non-interactive HF auth)
61
  - `GOOGLE_API_KEY` (optional; required for Gemini explanations)
62
  - `HOST` (default: `0.0.0.0`)
63
+ - `PORT` (default: `8000` locally, `7860` in Space by default)
64
  - `CORS_ORIGINS` (comma-separated origins)
65
  - `ENABLE_DEBUG`, `LOG_LEVEL`
66
 
 
92
 
93
  ```bash
94
  docker build -t deepfake-detector-api .
95
+ docker run -p 7860:7860 deepfake-detector-api
96
  ```
97
 
98
  ## Deploy to Hugging Face Spaces
99
 
100
+ Recommended path is the Bash deploy script.
101
 
102
  1. Configure [backend/.env](.env) from [backend/.env.example](.env.example)
103
  2. Ensure `HF_SPACE_URL` and related deploy variables are set
104
+ 3. Run from backend folder:
105
 
106
  ```bash
107
  bash ./deploy-to-hf.sh
108
  ```
109
 
110
+ Or run from repo root:
111
+
112
+ ```bash
113
+ bash ./backend/deploy-to-hf.sh
114
+ ```
115
+
116
  The script will:
117
 
118
  - install Hugging Face CLI if needed
119
  - prompt/authenticate with HF (`hf auth login`) when required
120
  - clone Space repo into a separate temp deploy directory
121
+ - copy backend files as-is (single `Dockerfile` setup)
122
  - commit and push to the HF Space
123
 
124
  After deploy, set Space secrets in Hugging Face:
 
126
  - `GOOGLE_API_KEY` (if using explanation endpoints)
127
  - `CORS_ORIGINS` (frontend domains)
128
 
129
+ ## Deploy to Railway
130
+
131
+ - Set service root to `backend`
132
+ - Configure required env vars (`CORS_ORIGINS`, `HF_FUSION_REPO_ID`, `HF_CACHE_DIR`, `PORT`)
133
+ - Push to main branch to trigger deployment
134
+
135
  ## Troubleshooting
136
 
137
  - Build fails: inspect Space/Railway logs first
 
146
  β”œβ”€β”€ app/
147
  β”œβ”€β”€ tests/
148
  β”œβ”€β”€ Dockerfile
149
+ β”œβ”€β”€ deploy-to-hf.sh
150
+ β”œβ”€β”€ deploy-to-hf.ps1
151
+ β”œβ”€β”€ requirements.txt
152
+ └── README.md
153
+ ```
154
+
155
+ ## License
156
+
157
+ MIT
158
  β”œβ”€β”€ deploy-to-hf.sh
159
  β”œβ”€β”€ deploy-to-hf.ps1
160
  β”œβ”€β”€ requirements.txt