Commit
·
40590fc
1
Parent(s):
5c775f8
chore: force CPU providers, set OMP_NUM_THREADS=1, better progress/info messages
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import os, uuid, time
|
|
| 3 |
from gradio_client import Client, handle_file
|
| 4 |
from moviepy.editor import VideoFileClip
|
| 5 |
from typing import Optional
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Local pipeline imports
|
| 8 |
import DeepFakeAI.globals as DF_G
|
|
@@ -54,8 +56,13 @@ def _run_local_faceswap(source_image_path: str, target_video_path: str) -> Optio
|
|
| 54 |
DF_G.skip_audio = False
|
| 55 |
DF_G.execution_thread_count = 2
|
| 56 |
DF_G.execution_queue_count = 2
|
| 57 |
-
#
|
| 58 |
-
DF_G.execution_providers = DF_U.decode_execution_providers(['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
# Ensure model exists
|
| 61 |
DF_FS.pre_check()
|
|
@@ -97,6 +104,7 @@ def generate(input_image, input_video):
|
|
| 97 |
# Minimal mode: no gender selector
|
| 98 |
|
| 99 |
try:
|
|
|
|
| 100 |
pre_video = preprocess_video(input_video)
|
| 101 |
|
| 102 |
if client is not None:
|
|
@@ -114,13 +122,21 @@ def generate(input_image, input_video):
|
|
| 114 |
time.sleep(5)
|
| 115 |
if not job.status().success:
|
| 116 |
return None
|
| 117 |
-
|
|
|
|
|
|
|
| 118 |
else:
|
| 119 |
# Local fallback
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
except Exception as e:
|
| 123 |
gr.Error(f"Generation failed: {e}")
|
|
|
|
| 124 |
return None
|
| 125 |
|
| 126 |
def open_side(): # tiny helper
|
|
|
|
| 3 |
from gradio_client import Client, handle_file
|
| 4 |
from moviepy.editor import VideoFileClip
|
| 5 |
from typing import Optional
|
| 6 |
+
import traceback
|
| 7 |
+
import os as _os
|
| 8 |
|
| 9 |
# Local pipeline imports
|
| 10 |
import DeepFakeAI.globals as DF_G
|
|
|
|
| 56 |
DF_G.skip_audio = False
|
| 57 |
DF_G.execution_thread_count = 2
|
| 58 |
DF_G.execution_queue_count = 2
|
| 59 |
+
# Force CPU for stability first
|
| 60 |
+
DF_G.execution_providers = DF_U.decode_execution_providers(['cpu'])
|
| 61 |
+
# Fix invalid OMP thread settings in container
|
| 62 |
+
try:
|
| 63 |
+
_os.environ["OMP_NUM_THREADS"] = "1"
|
| 64 |
+
except Exception:
|
| 65 |
+
pass
|
| 66 |
|
| 67 |
# Ensure model exists
|
| 68 |
DF_FS.pre_check()
|
|
|
|
| 104 |
# Minimal mode: no gender selector
|
| 105 |
|
| 106 |
try:
|
| 107 |
+
gr.Info("Processing started. This may take 1-3 minutes on first run.")
|
| 108 |
pre_video = preprocess_video(input_video)
|
| 109 |
|
| 110 |
if client is not None:
|
|
|
|
| 122 |
time.sleep(5)
|
| 123 |
if not job.status().success:
|
| 124 |
return None
|
| 125 |
+
outp = job.outputs()[0]["video"]
|
| 126 |
+
gr.Info("Done.")
|
| 127 |
+
return outp
|
| 128 |
else:
|
| 129 |
# Local fallback
|
| 130 |
+
outp = _run_local_faceswap(input_image, pre_video)
|
| 131 |
+
if outp:
|
| 132 |
+
gr.Info("Done.")
|
| 133 |
+
else:
|
| 134 |
+
gr.Error("Local processing failed. Check logs for details.")
|
| 135 |
+
return outp
|
| 136 |
|
| 137 |
except Exception as e:
|
| 138 |
gr.Error(f"Generation failed: {e}")
|
| 139 |
+
print("Generation error:\n", traceback.format_exc())
|
| 140 |
return None
|
| 141 |
|
| 142 |
def open_side(): # tiny helper
|