Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,28 @@ Gradio interface for WAN-VACE video generation
|
|
| 3 |
"""
|
| 4 |
import gradio as gr
|
| 5 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
import time
|
| 7 |
from typing import Optional
|
| 8 |
|
|
|
|
| 3 |
"""
|
| 4 |
import gradio as gr
|
| 5 |
import torch
|
| 6 |
+
|
| 7 |
+
# -----------------------------------------------------------------------------
|
| 8 |
+
# XPU shim for CPU‑only environments
|
| 9 |
+
#
|
| 10 |
+
# `diffusers` attempts to access `torch.xpu.empty_cache()` when cleaning up
|
| 11 |
+
# device memory. On CPU‑only builds of PyTorch (or builds without Intel
|
| 12 |
+
# extension support), the `xpu` attribute does not exist on the `torch`
|
| 13 |
+
# module. Defining a dummy `torch.xpu` prevents AttributeError during
|
| 14 |
+
# import.
|
| 15 |
+
# -----------------------------------------------------------------------------
|
| 16 |
+
if not hasattr(torch, "xpu"):
|
| 17 |
+
class _DummyXPU:
|
| 18 |
+
@staticmethod
|
| 19 |
+
def empty_cache() -> None:
|
| 20 |
+
return None
|
| 21 |
+
@staticmethod
|
| 22 |
+
def is_available() -> bool:
|
| 23 |
+
return False
|
| 24 |
+
@staticmethod
|
| 25 |
+
def device_count() -> int:
|
| 26 |
+
return 0
|
| 27 |
+
torch.xpu = _DummyXPU() # type: ignore[attr-defined]
|
| 28 |
import time
|
| 29 |
from typing import Optional
|
| 30 |
|