dosesnrolls1 commited on
Commit
5273177
·
verified ·
1 Parent(s): 42d56c7

Upload 4 files

Browse files
Files changed (2) hide show
  1. README.md +32 -0
  2. app.py +8 -7
README.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Video FaceSwap GPU Only
3
+ emoji: 🎭
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
8
+ suggested_hardware: a10g-small
9
+ startup_duration_timeout: 1h
10
+ pinned: false
11
+ ---
12
+
13
+ # Video FaceSwap GPU Only
14
+
15
+ This Space is strict GPU-only. It refuses to process video unless ONNX Runtime exposes CUDAExecutionProvider.
16
+
17
+ ## Environment variables
18
+
19
+ - `MODEL_REPO_ID`: default `ezioruan/inswapper_128.onnx`
20
+ - `MODEL_FILENAME`: default `inswapper_128.onnx`
21
+ - `MODEL_REVISION`: optional branch, tag, or commit hash
22
+ - `HF_TOKEN`: recommended for gated/private repos and better Hub rate limits
23
+ - `FACE_MODEL_NAME`: default `buffalo_l`
24
+ - `DETECTION_SIZE`: default `640`
25
+ - `MAX_FRAMES`: optional frame cap for testing, default `0`
26
+
27
+ ## Deploy
28
+
29
+ 1. Create a Docker Space.
30
+ 2. Select a paid GPU hardware tier such as A10G small.
31
+ 3. Add these files.
32
+ 4. Add `HF_TOKEN` if needed.
app.py CHANGED
@@ -40,14 +40,15 @@ def available_providers():
40
 
41
 
42
  def gpu_ready():
43
- return "CUDAExecutionProvider" in available_providers()
 
44
 
45
 
46
  def gpu_guard():
47
- providers = available_providers()
48
- if "CUDAExecutionProvider" not in providers:
49
  raise RuntimeError(
50
- "GPU-only mode: CUDAExecutionProvider is missing. "
51
  f"Available providers: {providers}"
52
  )
53
 
@@ -112,8 +113,8 @@ def swap_frame(frame_bgr, source_face, analyzer, swapper):
112
 
113
 
114
  def startup_status():
115
- providers = available_providers()
116
- return f"Available providers: {providers} | GPU ready: {gpu_ready()}"
117
 
118
 
119
  def process_video(face_image_path, video_path, progress=gr.Progress(track_tqdm=False)):
@@ -163,7 +164,7 @@ def process_video(face_image_path, video_path, progress=gr.Progress(track_tqdm=F
163
 
164
  with gr.Blocks(title="Video FaceSwap GPU Only") as demo:
165
  gr.Markdown("""# Video FaceSwap GPU Only
166
- This Space will only run when ONNX Runtime exposes CUDAExecutionProvider. If not, it refuses to process video.""")
167
  gr.Textbox(label="GPU status", value=startup_status(), interactive=False)
168
  with gr.Row():
169
  face_image = gr.Image(type="filepath", label="Source face image")
 
40
 
41
 
42
  def gpu_ready():
43
+ providers = available_providers()
44
+ return "CUDAExecutionProvider" in providers, providers
45
 
46
 
47
  def gpu_guard():
48
+ ok, providers = gpu_ready()
49
+ if not ok:
50
  raise RuntimeError(
51
+ "GPU device not attached. CUDAExecutionProvider is missing. "
52
  f"Available providers: {providers}"
53
  )
54
 
 
113
 
114
 
115
  def startup_status():
116
+ ok, providers = gpu_ready()
117
+ return f"GPU ready: {ok} | Providers: {providers}"
118
 
119
 
120
  def process_video(face_image_path, video_path, progress=gr.Progress(track_tqdm=False)):
 
164
 
165
  with gr.Blocks(title="Video FaceSwap GPU Only") as demo:
166
  gr.Markdown("""# Video FaceSwap GPU Only
167
+ This Space only works when a real GPU is attached. If CUDA is missing, processing is blocked.""")
168
  gr.Textbox(label="GPU status", value=startup_status(), interactive=False)
169
  with gr.Row():
170
  face_image = gr.Image(type="filepath", label="Source face image")