Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,8 +43,8 @@ from huggingface_hub import hf_hub_download
|
|
| 43 |
from ltx_core.model.video_vae import TilingConfig, get_video_chunks_number
|
| 44 |
from ltx_core.quantization import QuantizationPolicy
|
| 45 |
from ltx_core.text_encoders.gemma.embeddings_processor import EmbeddingsProcessorOutput
|
|
|
|
| 46 |
from ltx_pipelines.distilled import DistilledPipeline
|
| 47 |
-
from ltx_pipelines.utils import helpers as pipeline_helpers
|
| 48 |
from ltx_pipelines.utils.args import ImageConditioningInput
|
| 49 |
from ltx_pipelines.utils.media_io import encode_video
|
| 50 |
|
|
@@ -124,7 +124,7 @@ print("Pipeline ready!")
|
|
| 124 |
print("=" * 80)
|
| 125 |
|
| 126 |
|
| 127 |
-
@spaces.GPU(duration=
|
| 128 |
def generate_video(
|
| 129 |
input_image,
|
| 130 |
prompt: str,
|
|
@@ -195,15 +195,15 @@ def generate_video(
|
|
| 195 |
f"Please ensure {TEXT_ENCODER_SPACE} is running properly."
|
| 196 |
)
|
| 197 |
|
| 198 |
-
# Monkey-patch encode_prompts
|
| 199 |
-
#
|
| 200 |
precomputed = EmbeddingsProcessorOutput(
|
| 201 |
video_encoding=video_context,
|
| 202 |
audio_encoding=audio_context,
|
| 203 |
attention_mask=torch.ones(1, device="cuda"), # dummy mask
|
| 204 |
)
|
| 205 |
-
original_encode_prompts =
|
| 206 |
-
|
| 207 |
|
| 208 |
try:
|
| 209 |
tiling_config = TilingConfig.default()
|
|
@@ -233,7 +233,7 @@ def generate_video(
|
|
| 233 |
return str(output_path), current_seed
|
| 234 |
finally:
|
| 235 |
# Restore original encode_prompts
|
| 236 |
-
|
| 237 |
|
| 238 |
except Exception as e:
|
| 239 |
import traceback
|
|
|
|
| 43 |
from ltx_core.model.video_vae import TilingConfig, get_video_chunks_number
|
| 44 |
from ltx_core.quantization import QuantizationPolicy
|
| 45 |
from ltx_core.text_encoders.gemma.embeddings_processor import EmbeddingsProcessorOutput
|
| 46 |
+
import ltx_pipelines.distilled as distilled_module
|
| 47 |
from ltx_pipelines.distilled import DistilledPipeline
|
|
|
|
| 48 |
from ltx_pipelines.utils.args import ImageConditioningInput
|
| 49 |
from ltx_pipelines.utils.media_io import encode_video
|
| 50 |
|
|
|
|
| 124 |
print("=" * 80)
|
| 125 |
|
| 126 |
|
| 127 |
+
@spaces.GPU(duration=300)
|
| 128 |
def generate_video(
|
| 129 |
input_image,
|
| 130 |
prompt: str,
|
|
|
|
| 195 |
f"Please ensure {TEXT_ENCODER_SPACE} is running properly."
|
| 196 |
)
|
| 197 |
|
| 198 |
+
# Monkey-patch encode_prompts on the distilled module directly
|
| 199 |
+
# (it imports encode_prompts from helpers, so we must patch the local reference)
|
| 200 |
precomputed = EmbeddingsProcessorOutput(
|
| 201 |
video_encoding=video_context,
|
| 202 |
audio_encoding=audio_context,
|
| 203 |
attention_mask=torch.ones(1, device="cuda"), # dummy mask
|
| 204 |
)
|
| 205 |
+
original_encode_prompts = distilled_module.encode_prompts
|
| 206 |
+
distilled_module.encode_prompts = lambda *args, **kwargs: [precomputed]
|
| 207 |
|
| 208 |
try:
|
| 209 |
tiling_config = TilingConfig.default()
|
|
|
|
| 233 |
return str(output_path), current_seed
|
| 234 |
finally:
|
| 235 |
# Restore original encode_prompts
|
| 236 |
+
distilled_module.encode_prompts = original_encode_prompts
|
| 237 |
|
| 238 |
except Exception as e:
|
| 239 |
import traceback
|