Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,12 @@ import sys
|
|
| 6 |
os.environ["TORCH_COMPILE_DISABLE"] = "1"
|
| 7 |
os.environ["TORCHDYNAMO_DISABLE"] = "1"
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Clone LTX-2 repo and install packages
|
| 10 |
LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
|
| 11 |
LTX_REPO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "LTX-2")
|
|
@@ -78,19 +84,14 @@ from ltx_pipelines.utils.media_io import decode_audio_from_file, encode_video
|
|
| 78 |
from ltx_core.loader.primitives import LoraPathStrengthAndSDOps
|
| 79 |
from ltx_core.loader.sd_ops import LTXV_LORA_COMFY_RENAMING_MAP
|
| 80 |
|
| 81 |
-
from
|
| 82 |
|
|
|
|
|
|
|
| 83 |
print(f"[ATTN] Before patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
|
| 84 |
try:
|
| 85 |
from xformers.ops import memory_efficient_attention as _mea
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
def _cutlass_memory_efficient_attention(*args, **kwargs):
|
| 89 |
-
# Force CUTLASS and avoid FlashAttention paths that are crashing.
|
| 90 |
-
kwargs["op"] = (cutlass.FwOp, cutlass.BwOp)
|
| 91 |
-
return _mea(*args, **kwargs)
|
| 92 |
-
|
| 93 |
-
_attn_mod.memory_efficient_attention = _cutlass_memory_efficient_attention
|
| 94 |
print(f"[ATTN] After patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
|
| 95 |
except Exception as e:
|
| 96 |
print(f"[ATTN] xformers patch FAILED: {type(e).__name__}: {e}")
|
|
@@ -249,18 +250,10 @@ class LTX23DistilledA2VPipeline:
|
|
| 249 |
video_state=video_state,
|
| 250 |
audio_state=audio_state,
|
| 251 |
stepper=stepper,
|
| 252 |
-
denoise_fn=
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
),
|
| 257 |
-
audio_guider=MultiModalGuider(
|
| 258 |
-
params=audio_guider_params,
|
| 259 |
-
negative_context=a_context_n,
|
| 260 |
-
),
|
| 261 |
-
v_context=v_context_p,
|
| 262 |
-
a_context=a_context_p,
|
| 263 |
-
transformer=transformer,
|
| 264 |
),
|
| 265 |
)
|
| 266 |
|
|
|
|
| 6 |
os.environ["TORCH_COMPILE_DISABLE"] = "1"
|
| 7 |
os.environ["TORCHDYNAMO_DISABLE"] = "1"
|
| 8 |
|
| 9 |
+
# Install xformers for memory-efficient attention
|
| 10 |
+
subprocess.run(
|
| 11 |
+
[sys.executable, "-m", "pip", "install", "xformers==0.0.32.post2", "--no-build-isolation"],
|
| 12 |
+
check=False,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
# Clone LTX-2 repo and install packages
|
| 16 |
LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
|
| 17 |
LTX_REPO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "LTX-2")
|
|
|
|
| 84 |
from ltx_core.loader.primitives import LoraPathStrengthAndSDOps
|
| 85 |
from ltx_core.loader.sd_ops import LTXV_LORA_COMFY_RENAMING_MAP
|
| 86 |
|
| 87 |
+
from ltx_pipelines.utils.types import OffloadMode
|
| 88 |
|
| 89 |
+
# xformers attention patch (same as the outpaint app).
|
| 90 |
+
from ltx_core.model.transformer import attention as _attn_mod
|
| 91 |
print(f"[ATTN] Before patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
|
| 92 |
try:
|
| 93 |
from xformers.ops import memory_efficient_attention as _mea
|
| 94 |
+
_attn_mod.memory_efficient_attention = _mea
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
print(f"[ATTN] After patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
|
| 96 |
except Exception as e:
|
| 97 |
print(f"[ATTN] xformers patch FAILED: {type(e).__name__}: {e}")
|
|
|
|
| 250 |
video_state=video_state,
|
| 251 |
audio_state=audio_state,
|
| 252 |
stepper=stepper,
|
| 253 |
+
denoise_fn=simple_denoising_func(
|
| 254 |
+
video_context=v_context_p,
|
| 255 |
+
audio_context=a_context_p,
|
| 256 |
+
transformer=transformer, # noqa: F821
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
),
|
| 258 |
)
|
| 259 |
|