--- title: FaceSwap GPU emoji: 🎬 colorFrom: indigo colorTo: purple sdk: gradio sdk_version: 5.29.0 app_file: app.py pinned: false license: unknown short_description: GPU-accelerated all-in-one face swapping (photo + video) --- # FaceSwap GPU – Rented-GPU Ready All-in-one face swapping suite optimised for **CUDA GPUs** (RunPod, Vast.ai, Lambda, local RTX, HF GPU Spaces, etc.). ## What changed vs the original - Explicit `CUDAExecutionProvider` preference via onnxruntime - Robust Gradio video path handling (fixes all video tabs) - Cleaned frame extraction + resume logic - Better error reporting in the Log box - Workdir isolation under `workdir/` - `opencv-python-headless` (safer on servers) - Proper `demo.queue()` for concurrent jobs - `ssr_mode=False` to avoid Gradio SSR 405 errors - ffmpeg system package declared ## Requirements on the rented machine - NVIDIA GPU + drivers - CUDA-compatible onnxruntime-gpu (already in requirements) - ~4–8 GB VRAM recommended for 1080p video - ffmpeg installed (packages.txt) ## Local / rented GPU launch ```bash pip install -r requirements.txt python app.py --share # creates a public link # or python app.py --server-port 7860 ``` First run downloads `buffalo_l` + `inswapper_128.onnx` (~300 MB). ## Tips for long videos - Keep “Delete extracted frames” checked to save disk. - Processing is frame-by-frame; a 1-minute 30 fps clip ≈ 1800 swaps. - On a modern GPU expect 5–15 fps effective (depends on resolution & number of faces). - Resume is automatic: if the process is killed, re-run and already-swapped frames are skipped. ## Face indices Faces are sorted left-to-right. Index 1 = leftmost face.