Commit
·
d784b2b
1
Parent(s):
c7173e6
feat: integrate FastAPI with Gradio app - both UI and API now run together
Browse files- app.py +13 -1
- requirements.txt +8 -1
app.py
CHANGED
|
@@ -250,4 +250,16 @@ with gr.Blocks(title="Video Face Swap", theme=gr.themes.Soft()) as demo:
|
|
| 250 |
demo.queue()
|
| 251 |
|
| 252 |
if __name__ == "__main__":
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
demo.queue()
|
| 251 |
|
| 252 |
if __name__ == "__main__":
|
| 253 |
+
import threading
|
| 254 |
+
import uvicorn
|
| 255 |
+
from api.main import app as api_app
|
| 256 |
+
|
| 257 |
+
# Start FastAPI server in background thread
|
| 258 |
+
def run_api():
|
| 259 |
+
uvicorn.run(api_app, host="0.0.0.0", port=8000)
|
| 260 |
+
|
| 261 |
+
api_thread = threading.Thread(target=run_api, daemon=True)
|
| 262 |
+
api_thread.start()
|
| 263 |
+
|
| 264 |
+
# Launch Gradio app
|
| 265 |
+
demo.launch(server_port=7860)
|
requirements.txt
CHANGED
|
@@ -9,4 +9,11 @@ insightface==0.7.3
|
|
| 9 |
onnxruntime==1.17.3
|
| 10 |
psutil==5.9.5
|
| 11 |
tqdm==4.65.0
|
| 12 |
-
huggingface_hub>=0.23.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
onnxruntime==1.17.3
|
| 10 |
psutil==5.9.5
|
| 11 |
tqdm==4.65.0
|
| 12 |
+
huggingface_hub>=0.23.0
|
| 13 |
+
fastapi==0.104.1
|
| 14 |
+
uvicorn[standard]==0.24.0
|
| 15 |
+
python-multipart==0.0.6
|
| 16 |
+
motor==3.3.2
|
| 17 |
+
pymongo==4.6.0
|
| 18 |
+
python-dotenv==1.0.0
|
| 19 |
+
dnspython==2.4.2
|