Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,21 +14,18 @@ os.environ["VECLIB_MAXIMUM_THREADS"] = "2"
|
|
| 14 |
os.environ["NUMEXPR_NUM_THREADS"] = "2"
|
| 15 |
|
| 16 |
# ==============================================================================
|
| 17 |
-
# КРИТИЧНИЙ ФІКС 2
|
| 18 |
-
# Створюємо кастомний КЛАС замість функції, щоб зберегти можливість наслідування для insightface.
|
| 19 |
# ==============================================================================
|
| 20 |
import onnxruntime as ort
|
| 21 |
_orig_InferenceSession = ort.InferenceSession
|
| 22 |
|
| 23 |
class PatchedInferenceSession(_orig_InferenceSession):
|
| 24 |
def __init__(self, path_or_bytes, *args, **kwargs):
|
| 25 |
-
# Якщо ініціалізується модель деформації обличчя — примусово перемикаємо на CPU
|
| 26 |
if isinstance(path_or_bytes, str) and "warping_spade" in path_or_bytes:
|
| 27 |
print(f"🎯 [MONKEYPATCH] Forcing {path_or_bytes} to run strictly on CPUExecutionProvider!")
|
| 28 |
kwargs["providers"] = ["CPUExecutionProvider"]
|
| 29 |
super().__init__(path_or_bytes, *args, **kwargs)
|
| 30 |
|
| 31 |
-
# Перезаписуємо класи в просторах імен ONNX Runtime
|
| 32 |
ort.InferenceSession = PatchedInferenceSession
|
| 33 |
if hasattr(ort, 'capi') and hasattr(ort.capi, 'onnxruntime_inference_collection'):
|
| 34 |
ort.capi.onnxruntime_inference_collection.InferenceSession = PatchedInferenceSession
|
|
@@ -36,6 +33,19 @@ if hasattr(ort, 'capi') and hasattr(ort.capi, 'onnxruntime_inference_collection'
|
|
| 36 |
|
| 37 |
import pdb
|
| 38 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
import os.path as osp
|
| 40 |
from omegaconf import OmegaConf
|
| 41 |
|
|
|
|
| 14 |
os.environ["NUMEXPR_NUM_THREADS"] = "2"
|
| 15 |
|
| 16 |
# ==============================================================================
|
| 17 |
+
# КРИТИЧНИЙ ФІКС 2: Патч для 5D GridSample на CUDA.
|
|
|
|
| 18 |
# ==============================================================================
|
| 19 |
import onnxruntime as ort
|
| 20 |
_orig_InferenceSession = ort.InferenceSession
|
| 21 |
|
| 22 |
class PatchedInferenceSession(_orig_InferenceSession):
|
| 23 |
def __init__(self, path_or_bytes, *args, **kwargs):
|
|
|
|
| 24 |
if isinstance(path_or_bytes, str) and "warping_spade" in path_or_bytes:
|
| 25 |
print(f"🎯 [MONKEYPATCH] Forcing {path_or_bytes} to run strictly on CPUExecutionProvider!")
|
| 26 |
kwargs["providers"] = ["CPUExecutionProvider"]
|
| 27 |
super().__init__(path_or_bytes, *args, **kwargs)
|
| 28 |
|
|
|
|
| 29 |
ort.InferenceSession = PatchedInferenceSession
|
| 30 |
if hasattr(ort, 'capi') and hasattr(ort.capi, 'onnxruntime_inference_collection'):
|
| 31 |
ort.capi.onnxruntime_inference_collection.InferenceSession = PatchedInferenceSession
|
|
|
|
| 33 |
|
| 34 |
import pdb
|
| 35 |
import gradio as gr
|
| 36 |
+
|
| 37 |
+
# ==============================================================================
|
| 38 |
+
# КРИТИЧНИЙ ФІКС 3 (MONKEYPATCH FOR GR.INFO):
|
| 39 |
+
# Вирішуємо конфлікт версій Gradio. Вирізаємо 'duration', якого немає в Gradio 4.36.1,
|
| 40 |
+
# щоб уникнути TypeError на самому фініші генерації відео.
|
| 41 |
+
# ==============================================================================
|
| 42 |
+
_orig_Info = gr.Info
|
| 43 |
+
def patched_Info(message, *args, **kwargs):
|
| 44 |
+
kwargs.pop('duration', None) # Видаляємо duration, якщо він переданий автором
|
| 45 |
+
return _orig_Info(message, *args, **kwargs)
|
| 46 |
+
gr.Info = patched_Info
|
| 47 |
+
# ==============================================================================
|
| 48 |
+
|
| 49 |
import os.path as osp
|
| 50 |
from omegaconf import OmegaConf
|
| 51 |
|