Spaces:
Build error
Build error
Upload 3 files
Browse files- Dockerfile +35 -0
- README.md +12 -0
- app.py +51 -0
Dockerfile
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
# System dependencies for face_recognition
|
6 |
+
RUN apt-get update && apt-get install -y \
|
7 |
+
build-essential \
|
8 |
+
cmake \
|
9 |
+
libsm6 \
|
10 |
+
libxext6 \
|
11 |
+
libxrender-dev \
|
12 |
+
libgl1-mesa-glx \
|
13 |
+
git \
|
14 |
+
curl \
|
15 |
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
16 |
+
|
17 |
+
# Copy server files
|
18 |
+
COPY server/ ./server/
|
19 |
+
|
20 |
+
# Install Python requirements
|
21 |
+
WORKDIR /app/server
|
22 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
23 |
+
RUN pip install face-recognition opencv-python-headless matplotlib fastapi uvicorn python-multipart
|
24 |
+
|
25 |
+
# Create necessary directories
|
26 |
+
RUN mkdir -p uploaded_images
|
27 |
+
RUN mkdir -p static
|
28 |
+
RUN mkdir -p models
|
29 |
+
RUN mkdir -p uploaded_videos
|
30 |
+
|
31 |
+
# Expose the port
|
32 |
+
EXPOSE 7860
|
33 |
+
|
34 |
+
# Start the server
|
35 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: DeepSight DeepFake Detection
|
3 |
+
emoji: 🕵️
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: purple
|
6 |
+
sdk: docker
|
7 |
+
sdk_version: latest
|
8 |
+
app_file: server/app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
from fastapi import FastAPI, Request
|
4 |
+
from fastapi.middleware.cors import CORSMiddleware
|
5 |
+
from fastapi.staticfiles import StaticFiles
|
6 |
+
from fastapi.responses import FileResponse, HTMLResponse
|
7 |
+
import uvicorn
|
8 |
+
|
9 |
+
# Add server directory to path
|
10 |
+
sys.path.insert(0, 'server')
|
11 |
+
|
12 |
+
# Import the original app
|
13 |
+
from server.app import app as server_app
|
14 |
+
|
15 |
+
# Create the main app
|
16 |
+
app = FastAPI()
|
17 |
+
|
18 |
+
# Configure CORS
|
19 |
+
app.add_middleware(
|
20 |
+
CORSMiddleware,
|
21 |
+
allow_origins=["*"],
|
22 |
+
allow_credentials=True,
|
23 |
+
allow_methods=["*"],
|
24 |
+
allow_headers=["*"],
|
25 |
+
)
|
26 |
+
|
27 |
+
# Mount the original server app
|
28 |
+
app.mount("/api", server_app)
|
29 |
+
|
30 |
+
# Mount static directories
|
31 |
+
app.mount("/uploaded_images", StaticFiles(directory="server/uploaded_images"), name="uploaded_images")
|
32 |
+
app.mount("/static", StaticFiles(directory="server/static"), name="static")
|
33 |
+
app.mount("/assets", StaticFiles(directory="frontend/dist/assets"), name="assets")
|
34 |
+
|
35 |
+
# Serve frontend
|
36 |
+
@app.get("/{path:path}")
|
37 |
+
async def serve_frontend(path: str):
|
38 |
+
# First check if the path exists in the frontend dist
|
39 |
+
if os.path.exists(f"frontend/dist/{path}"):
|
40 |
+
return FileResponse(f"frontend/dist/{path}")
|
41 |
+
|
42 |
+
# Otherwise return the index.html
|
43 |
+
return FileResponse("frontend/dist/index.html")
|
44 |
+
|
45 |
+
@app.get("/", response_class=HTMLResponse)
|
46 |
+
async def root():
|
47 |
+
return FileResponse("frontend/dist/index.html")
|
48 |
+
|
49 |
+
if __name__ == "__main__":
|
50 |
+
# Use port 7860 for Hugging Face Spaces
|
51 |
+
uvicorn.run("app:app", host="0.0.0.0", port=7860)
|