Commit
·
5f12d8e
1
Parent(s):
ab05d19
Add Dockerfile and document FastAPI usage
Browse files- Dockerfile +27 -0
- README.md +27 -1
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 4 |
+
PYTHONUNBUFFERED=1
|
| 5 |
+
|
| 6 |
+
# System deps for OpenCV/ffmpeg
|
| 7 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
+
ffmpeg \
|
| 9 |
+
libgl1 \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
+
WORKDIR /app
|
| 13 |
+
|
| 14 |
+
# Install Python deps
|
| 15 |
+
COPY requirements.txt .
|
| 16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
+
|
| 18 |
+
# Copy source
|
| 19 |
+
COPY . .
|
| 20 |
+
|
| 21 |
+
EXPOSE 8000
|
| 22 |
+
|
| 23 |
+
# Optional: set at runtime
|
| 24 |
+
ENV FACE_SWAP_API_KEY=""
|
| 25 |
+
|
| 26 |
+
CMD ["python3", "-m", "uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "8000"]
|
| 27 |
+
|
README.md
CHANGED
|
@@ -11,4 +11,30 @@ license: unknown
|
|
| 11 |
short_description: 'All-in-one face swapping: single photo, video, multi-source,'
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
short_description: 'All-in-one face swapping: single photo, video, multi-source,'
|
| 12 |
---
|
| 13 |
|
| 14 |
+
## Run locally (FastAPI)
|
| 15 |
+
|
| 16 |
+
1. Install deps:
|
| 17 |
+
- `python3 -m pip install -r requirements.txt`
|
| 18 |
+
2. (Optional) set API key:
|
| 19 |
+
- `export FACE_SWAP_API_KEY=your_key`
|
| 20 |
+
3. Start server:
|
| 21 |
+
- `python3 -m uvicorn fastapi_app:app --host 0.0.0.0 --port 8000`
|
| 22 |
+
|
| 23 |
+
Endpoints:
|
| 24 |
+
- `GET /health`
|
| 25 |
+
- `POST /swap/photo` (multipart form: `source_image`, `destination_image`, optional `source_face_idx`, `destination_face_idx`)
|
| 26 |
+
- `POST /swap/video` (multipart form: `source_image`, `target_video`, optional indices)
|
| 27 |
+
Include header `X-API-Key` if `FACE_SWAP_API_KEY` is set.
|
| 28 |
+
|
| 29 |
+
## Docker
|
| 30 |
+
|
| 31 |
+
Build:
|
| 32 |
+
- `docker build -t faceswapall .`
|
| 33 |
+
|
| 34 |
+
Run:
|
| 35 |
+
- `docker run -p 8000:8000 -e FACE_SWAP_API_KEY=your_key faceswapall`
|
| 36 |
+
|
| 37 |
+
## Original Gradio app
|
| 38 |
+
|
| 39 |
+
The space still includes `app.py` for the Gradio UI; run with:
|
| 40 |
+
- `python3 app.py --share`
|