dagloop5 commited on
Commit
ed54daa
·
verified ·
1 Parent(s): 267ab70

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -1022
app.py DELETED
@@ -1,1022 +0,0 @@
1
- import os
2
- import subprocess
3
- import sys
4
-
5
- # Disable torch.compile / dynamo before any torch import
6
- os.environ["TORCH_COMPILE_DISABLE"] = "1"
7
- os.environ["TORCHDYNAMO_DISABLE"] = "1"
8
-
9
-
10
- # Clone LTX-2 repo and install packages
11
- LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
12
- LTX_REPO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "LTX-2")
13
-
14
- LTX_COMMIT = "ae855f8538843825f9015a419cf4ba5edaf5eec2" # known working commit with decode_video
15
-
16
- if not os.path.exists(LTX_REPO_DIR):
17
- print(f"Cloning {LTX_REPO_URL}...")
18
- subprocess.run(["git", "clone", LTX_REPO_URL, LTX_REPO_DIR], check=True)
19
- subprocess.run(["git", "checkout", LTX_COMMIT], cwd=LTX_REPO_DIR, check=True)
20
-
21
- print("Installing ltx-core and ltx-pipelines from cloned repo...")
22
- subprocess.run(
23
- [sys.executable, "-m", "pip", "install", "--force-reinstall", "--no-deps", "-e",
24
- os.path.join(LTX_REPO_DIR, "packages", "ltx-core"),
25
- "-e", os.path.join(LTX_REPO_DIR, "packages", "ltx-pipelines")],
26
- check=True,
27
- )
28
-
29
- sys.path.insert(0, os.path.join(LTX_REPO_DIR, "packages", "ltx-pipelines", "src"))
30
- sys.path.insert(0, os.path.join(LTX_REPO_DIR, "packages", "ltx-core", "src"))
31
-
32
- import logging
33
- import random
34
- import tempfile
35
- from pathlib import Path
36
- import gc
37
- import hashlib
38
- import shutil
39
-
40
- import spaces
41
- import torch
42
-
43
- torch._dynamo.config.suppress_errors = True
44
- torch._dynamo.config.disable = True
45
-
46
- _original_tensor_to = torch.Tensor.to
47
-
48
-
49
- def _is_cuda_target(x):
50
- return (
51
- x == "cuda"
52
- or (isinstance(x, torch.device) and x.type == "cuda")
53
- or (isinstance(x, str) and x.startswith("cuda"))
54
- or (isinstance(x, int) and x == 0)
55
- )
56
-
57
-
58
- def _spaces_safe_to(self, *args, **kwargs):
59
- """ZeroGPU emulates bare .to('cuda'), but LTX-2 uses non_blocking/copy."""
60
- if args and _is_cuda_target(args[0]):
61
- # keep dtype if it was passed positionally after the device
62
- new_args = ("cuda",) + args[1:]
63
- new_kwargs = {k: v for k, v in kwargs.items() if k not in ("non_blocking", "copy")}
64
- return _original_tensor_to(self, *new_args, **new_kwargs)
65
-
66
- if kwargs.get("device") is not None and _is_cuda_target(kwargs["device"]):
67
- new_kwargs = {k: v for k, v in kwargs.items() if k not in ("non_blocking", "copy")}
68
- new_kwargs["device"] = "cuda"
69
- return _original_tensor_to(self, *args, **new_kwargs)
70
-
71
- return _original_tensor_to(self, *args, **kwargs)
72
-
73
-
74
- torch.Tensor.to = _spaces_safe_to
75
-
76
- import gradio as gr
77
- import numpy as np
78
- from huggingface_hub import hf_hub_download, snapshot_download
79
- from safetensors import safe_open
80
- import json
81
- import requests
82
-
83
- from ltx_core.components.diffusion_steps import EulerDiffusionStep
84
- from ltx_core.components.noisers import GaussianNoiser
85
- from ltx_core.model.audio_vae import encode_audio as vae_encode_audio
86
- from ltx_core.model.upsampler import upsample_video
87
- from ltx_core.model.video_vae import TilingConfig, get_video_chunks_number, decode_video as vae_decode_video
88
- from ltx_core.quantization import QuantizationPolicy
89
- from ltx_core.types import Audio, AudioLatentShape, VideoPixelShape
90
- from ltx_pipelines.distilled import DistilledPipeline
91
- from ltx_pipelines.utils import euler_denoising_loop
92
- from ltx_pipelines.utils.args import ImageConditioningInput
93
- from ltx_pipelines.utils.constants import DISTILLED_SIGMA_VALUES, STAGE_2_DISTILLED_SIGMA_VALUES
94
- from ltx_pipelines.utils.helpers import (
95
- cleanup_memory,
96
- combined_image_conditionings,
97
- denoise_video_only,
98
- encode_prompts,
99
- simple_denoising_func,
100
- )
101
- from ltx_pipelines.utils.media_io import decode_audio_from_file, encode_video
102
- from ltx_core.loader.primitives import LoraPathStrengthAndSDOps
103
- from ltx_core.loader.sd_ops import LTXV_LORA_COMFY_RENAMING_MAP
104
-
105
- logging.getLogger().setLevel(logging.INFO)
106
-
107
- MAX_SEED = np.iinfo(np.int32).max
108
- DEFAULT_PROMPT = (
109
- "An astronaut hatches from a fragile egg on the surface of the Moon, "
110
- "the shell cracking and peeling apart in gentle low-gravity motion. "
111
- "Fine lunar dust lifts and drifts outward with each movement, floating "
112
- "in slow arcs before settling back onto the ground."
113
- )
114
- DEFAULT_FRAME_RATE = 24.0
115
-
116
- # Resolution presets: (width, height)
117
- RESOLUTIONS = {
118
- "low": {"16:9": (768, 512), "9:16": (512, 768), "1:1": (768, 768),
119
- "4:3": (768, 576), "3:4": (576, 768), "21:9": (768, 384)},
120
- "high": {"16:9": (1536, 1024), "9:16": (1024, 1536), "1:1": (1024, 1024),
121
- "4:3": (1536, 1152), "3:4": (1152, 1536), "21:9": (1536, 768)},
122
- }
123
-
124
-
125
- class LTX23DistilledA2VPipeline(DistilledPipeline):
126
- """DistilledPipeline with optional audio conditioning."""
127
-
128
- def __call__(
129
- self,
130
- prompt: str,
131
- seed: int,
132
- height: int,
133
- width: int,
134
- num_frames: int,
135
- frame_rate: float,
136
- images: list[ImageConditioningInput],
137
- audio_path: str | None = None,
138
- tiling_config: TilingConfig | None = None,
139
- enhance_prompt: bool = False,
140
- ):
141
- # Standard path when no audio input is provided.
142
- print(prompt)
143
- if audio_path is None:
144
- return super().__call__(
145
- prompt=prompt,
146
- seed=seed,
147
- height=height,
148
- width=width,
149
- num_frames=num_frames,
150
- frame_rate=frame_rate,
151
- images=images,
152
- tiling_config=tiling_config,
153
- enhance_prompt=enhance_prompt,
154
- )
155
-
156
- generator = torch.Generator(device=self.device).manual_seed(seed)
157
- noiser = GaussianNoiser(generator=generator)
158
- stepper = EulerDiffusionStep()
159
- dtype = torch.bfloat16
160
-
161
- (ctx_p,) = encode_prompts(
162
- [prompt],
163
- self.model_ledger,
164
- enhance_first_prompt=enhance_prompt,
165
- enhance_prompt_image=images[0].path if len(images) > 0 else None,
166
- )
167
- video_context, audio_context = ctx_p.video_encoding, ctx_p.audio_encoding
168
-
169
- video_duration = num_frames / frame_rate
170
- decoded_audio = decode_audio_from_file(audio_path, self.device, 0.0, video_duration)
171
- if decoded_audio is None:
172
- raise ValueError(f"Could not extract audio stream from {audio_path}")
173
-
174
- encoded_audio_latent = vae_encode_audio(decoded_audio, self.model_ledger.audio_encoder())
175
- audio_shape = AudioLatentShape.from_duration(batch=1, duration=video_duration, channels=8, mel_bins=16)
176
- expected_frames = audio_shape.frames
177
- actual_frames = encoded_audio_latent.shape[2]
178
-
179
- if actual_frames > expected_frames:
180
- encoded_audio_latent = encoded_audio_latent[:, :, :expected_frames, :]
181
- elif actual_frames < expected_frames:
182
- pad = torch.zeros(
183
- encoded_audio_latent.shape[0],
184
- encoded_audio_latent.shape[1],
185
- expected_frames - actual_frames,
186
- encoded_audio_latent.shape[3],
187
- device=encoded_audio_latent.device,
188
- dtype=encoded_audio_latent.dtype,
189
- )
190
- encoded_audio_latent = torch.cat([encoded_audio_latent, pad], dim=2)
191
-
192
- video_encoder = self.model_ledger.video_encoder()
193
- transformer = self.model_ledger.transformer()
194
- stage_1_sigmas = torch.tensor(DISTILLED_SIGMA_VALUES, device=self.device)
195
-
196
- def denoising_loop(sigmas, video_state, audio_state, stepper):
197
- return euler_denoising_loop(
198
- sigmas=sigmas,
199
- video_state=video_state,
200
- audio_state=audio_state,
201
- stepper=stepper,
202
- denoise_fn=simple_denoising_func(
203
- video_context=video_context,
204
- audio_context=audio_context,
205
- transformer=transformer,
206
- ),
207
- )
208
-
209
- stage_1_output_shape = VideoPixelShape(
210
- batch=1,
211
- frames=num_frames,
212
- width=width // 2,
213
- height=height // 2,
214
- fps=frame_rate,
215
- )
216
- stage_1_conditionings = combined_image_conditionings(
217
- images=images,
218
- height=stage_1_output_shape.height,
219
- width=stage_1_output_shape.width,
220
- video_encoder=video_encoder,
221
- dtype=dtype,
222
- device=self.device,
223
- )
224
- video_state = denoise_video_only(
225
- output_shape=stage_1_output_shape,
226
- conditionings=stage_1_conditionings,
227
- noiser=noiser,
228
- sigmas=stage_1_sigmas,
229
- stepper=stepper,
230
- denoising_loop_fn=denoising_loop,
231
- components=self.pipeline_components,
232
- dtype=dtype,
233
- device=self.device,
234
- initial_audio_latent=encoded_audio_latent,
235
- )
236
-
237
- torch.cuda.synchronize()
238
- cleanup_memory()
239
-
240
- upscaled_video_latent = upsample_video(
241
- latent=video_state.latent[:1],
242
- video_encoder=video_encoder,
243
- upsampler=self.model_ledger.spatial_upsampler(),
244
- )
245
- stage_2_sigmas = torch.tensor(STAGE_2_DISTILLED_SIGMA_VALUES, device=self.device)
246
- stage_2_output_shape = VideoPixelShape(batch=1, frames=num_frames, width=width, height=height, fps=frame_rate)
247
- stage_2_conditionings = combined_image_conditionings(
248
- images=images,
249
- height=stage_2_output_shape.height,
250
- width=stage_2_output_shape.width,
251
- video_encoder=video_encoder,
252
- dtype=dtype,
253
- device=self.device,
254
- )
255
- video_state = denoise_video_only(
256
- output_shape=stage_2_output_shape,
257
- conditionings=stage_2_conditionings,
258
- noiser=noiser,
259
- sigmas=stage_2_sigmas,
260
- stepper=stepper,
261
- denoising_loop_fn=denoising_loop,
262
- components=self.pipeline_components,
263
- dtype=dtype,
264
- device=self.device,
265
- noise_scale=stage_2_sigmas[0],
266
- initial_video_latent=upscaled_video_latent,
267
- initial_audio_latent=encoded_audio_latent,
268
- )
269
-
270
- torch.cuda.synchronize()
271
- del transformer
272
- del video_encoder
273
- cleanup_memory()
274
-
275
- decoded_video = vae_decode_video(
276
- video_state.latent,
277
- self.model_ledger.video_decoder(),
278
- tiling_config,
279
- generator,
280
- )
281
- original_audio = Audio(
282
- waveform=decoded_audio.waveform.squeeze(0),
283
- sampling_rate=decoded_audio.sampling_rate,
284
- )
285
- return decoded_video, original_audio
286
-
287
-
288
- # Model repos
289
- LTX_MODEL_REPO = "Lightricks/LTX-2.3"
290
- GEMMA_REPO ="Lightricks/gemma-3-12b-it-qat-q4_0-unquantized"
291
-
292
- # Download model checkpoints
293
- print("=" * 80)
294
- print("Downloading LTX-2.3 distilled model + Gemma...")
295
- print("=" * 80)
296
-
297
- # Legacy on-disk LoRA cache is no longer used; delete any old copies so the
298
- # Space does not run out of persistent storage and reset.
299
- _legacy_lora_cache_dir = Path("lora_cache")
300
- if _legacy_lora_cache_dir.exists():
301
- shutil.rmtree(_legacy_lora_cache_dir, ignore_errors=True)
302
-
303
- # Only the currently-loaded key and a single transient CPU-side pending state
304
- # are kept. The pending state is deleted as soon as it is copied to the GPU.
305
- current_lora_key: str | None = None
306
-
307
- PENDING_LORA_KEY: str | None = None
308
- PENDING_LORA_STATE: dict[str, torch.Tensor] | None = None
309
- PENDING_LORA_STATUS: str = "No LoRA state prepared yet."
310
-
311
- weights_dir = Path("weights")
312
- weights_dir.mkdir(exist_ok=True)
313
- checkpoint_path = hf_hub_download(
314
- repo_id="TenStrip/LTX2.3-10Eros",
315
- filename="10Eros_v1.4_bf16.safetensors",
316
- local_dir=str(weights_dir),
317
- local_dir_use_symlinks=False,
318
- )
319
-
320
- spatial_upsampler_path = hf_hub_download(repo_id=LTX_MODEL_REPO, filename="ltx-2.3-spatial-upscaler-x2-1.1.safetensors")
321
- gemma_root = snapshot_download(repo_id=GEMMA_REPO)
322
-
323
-
324
- # ---- Insert block (LoRA downloads) between lines 268 and 269 ----
325
- # LoRA repo + download the requested LoRA adapters
326
- LORA_REPO = "dagloop5/LoRA"
327
-
328
- print("=" * 80)
329
- print("Downloading LoRA adapters from dagloop5/LoRA...")
330
- print("=" * 80)
331
- singularity_lora_path = hf_hub_download(repo_id="TenStrip/LTX2.3_DMD_Lora", filename="LTX2.3_DMD_reshaped_r256.safetensors")
332
- teneros_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3-Furry-2D-NSFW-Multi-Purpose-Lora+Cum.safetensors")
333
- sulphur_lora_path =hf_hub_download(repo_id=LORA_REPO, filename="ltx23E28093SlowMotion26.Pkrs.safetensors")
334
- pose_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2_3_NSFW_furry_concat_v2.safetensors")
335
- general_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_reasoning_Sulphur-2_I2V_V4.safetensors")
336
- motion_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="Sulphur_LTX 2.3_better _NSFW_motion.safetensors")
337
- dreamlay_lora_path = hf_hub_download(repo_id="lynaNSFW/DR34ML4Y_AIO_NSFW_LTX23", filename="DR34ML4Y_LTXXX_V2.safetensors") # m15510n4ry, bl0wj0b, d0ubl3_bj, d0gg1e, c0wg1rl
338
- mself_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_2d_NSFW_motion_enhancer.safetensors") # Hyperfap
339
- dramatic_lora_path = hf_hub_download(repo_id="Muapi/valiantcat-ltx-2.3-transition-lora", filename="valiantcat-ltx-2.3-transition-lora.safetensors") # zhuanchang
340
- fluid_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="Cr3ampi3_animation_sulphur-2_i2v_v1.0.safetensors") # cr3ampi3 animation
341
- liquid_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="liquid_wet_dr1pp_ltx2_v1.0_scaled.safetensors") # wet dr1pp
342
- demopose_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="clapping-cheeks-audio-v001-alpha.safetensors")
343
- voice_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="hentai_voice_ltx23_v2.comfy.safetensors")
344
- realism_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="FurryenhancerLTX2.3V4.094fused.safetensors")
345
- transition_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX-2_takerpov_lora_v1.2.safetensors") # takerpov1, taker pov
346
- physics_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_Physics_V2_000002000.safetensors")
347
- reasoning_lora_path = hf_hub_download(repo_id="LiconStudio/Ltx2.3-VBVR-lora-I2V", filename="Ltx2.3-Licon-VBVR-I2V-390K-R32.safetensors")
348
- twostep_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_Multi_step_video_reasoning_V0.1.safetensors")
349
- mcfurry_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="mvmt_lora_v2_600.safetensors")
350
- dm_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="Doggy_mission_sulphur-2_v0.5.safetensors")
351
- praxis_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="Penile_Praxis_V4.safetensors")
352
- threed_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="ltx2-3d-animations-12500-steps-k3nk.safetensors")
353
- concept_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="ltx23_nsfw_helper_multi_concept_lora_v2.safetensors")
354
- bulge_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="stomach_bulge_10eros_sulphur_v1.safetensors")
355
-
356
- print(f"Singularity LoRA: {singularity_lora_path}")
357
- print(f"10Eros LoRA: {teneros_lora_path}")
358
- print(f"Sulphur LoRA: {sulphur_lora_path}")
359
- print(f"Pose LoRA: {pose_lora_path}")
360
- print(f"General LoRA: {general_lora_path}")
361
- print(f"Motion LoRA: {motion_lora_path}")
362
- print(f"Dreamlay LoRA: {dreamlay_lora_path}")
363
- print(f"Mself LoRA: {mself_lora_path}")
364
- print(f"Dramatic LoRA: {dramatic_lora_path}")
365
- print(f"Fluid LoRA: {fluid_lora_path}")
366
- print(f"Liquid LoRA: {liquid_lora_path}")
367
- print(f"Demopose LoRA: {demopose_lora_path}")
368
- print(f"Voice LoRA: {voice_lora_path}")
369
- print(f"Realism LoRA: {realism_lora_path}")
370
- print(f"Transition LoRA: {transition_lora_path}")
371
- print(f"Physics LoRA: {physics_lora_path}")
372
- print(f"Reasoning LoRA: {reasoning_lora_path}")
373
- print(f"Twostep LoRA: {twostep_lora_path}")
374
- print(f"Mcfurry LoRA: {mcfurry_lora_path}")
375
- print(f"DM LoRA: {dm_lora_path}")
376
- print(f"Praxis LoRA: {praxis_lora_path}")
377
- print(f"ThreeD LoRA: {threed_lora_path}")
378
- print(f"Concept LoRA: {concept_lora_path}")
379
- print(f"Bulge LoRA: {bulge_lora_path}")
380
- # ----------------------------------------------------------------
381
-
382
- print(f"Checkpoint: {checkpoint_path}")
383
- print(f"Spatial upsampler: {spatial_upsampler_path}")
384
- print(f"[Gemma] Root ready: {gemma_root}")
385
-
386
- # Initialize pipeline WITH text encoder and optional audio support
387
- # ---- Replace block (pipeline init) lines 275-281 ----
388
- pipeline = LTX23DistilledA2VPipeline(
389
- distilled_checkpoint_path=checkpoint_path,
390
- spatial_upsampler_path=spatial_upsampler_path,
391
- gemma_root=gemma_root,
392
- loras=[],
393
- quantization=None, # keep FP8 quantization unchanged
394
- )
395
- # ----------------------------------------------------------------
396
-
397
- def _make_lora_key(singularity_strength: float, teneros_strength: float, sulphur_strength: float, pose_strength: float, general_strength: float, motion_strength: float, dreamlay_strength: float, mself_strength: float, dramatic_strength: float, fluid_strength: float, liquid_strength: float, demopose_strength: float, voice_strength: float, realism_strength: float, transition_strength: float, physics_strength: float, reasoning_strength: float, twostep_strength: float, mcfurry_strength: float, dm_strength: float, praxis_strength: float, threed_strength: float, concept_strength: float, bulge_strength: float) -> tuple[str, str]:
398
- rx = round(float(singularity_strength), 2)
399
- ra = round(float(teneros_strength), 2)
400
- rb = round(float(sulphur_strength), 2)
401
- rp = round(float(pose_strength), 2)
402
- rg = round(float(general_strength), 2)
403
- rm = round(float(motion_strength), 2)
404
- rd = round(float(dreamlay_strength), 2)
405
- rs = round(float(mself_strength), 2)
406
- rr = round(float(dramatic_strength), 2)
407
- rf = round(float(fluid_strength), 2)
408
- rl = round(float(liquid_strength), 2)
409
- ro = round(float(demopose_strength), 2)
410
- rv = round(float(voice_strength), 2)
411
- re = round(float(realism_strength), 2)
412
- rt = round(float(transition_strength), 2)
413
- ry = round(float(physics_strength), 2)
414
- ri = round(float(reasoning_strength), 2)
415
- rw = round(float(twostep_strength), 2)
416
- mc = round(float(mcfurry_strength), 2)
417
- dm = round(float(dm_strength), 2)
418
- pr = round(float(praxis_strength), 2)
419
- td = round(float(threed_strength), 2)
420
- co = round(float(concept_strength), 2)
421
- bu = round(float(bulge_strength), 2)
422
- key_str = f"{singularity_lora_path}:{rx}|{teneros_lora_path}:{ra}|{sulphur_lora_path}:{rb}|{pose_lora_path}:{rp}|{general_lora_path}:{rg}|{motion_lora_path}:{rm}|{dreamlay_lora_path}:{rd}|{mself_lora_path}:{rs}|{dramatic_lora_path}:{rr}|{fluid_lora_path}:{rf}|{liquid_lora_path}:{rl}|{demopose_lora_path}:{ro}|{voice_lora_path}:{rv}|{realism_lora_path}:{re}|{transition_lora_path}:{rt}|{physics_lora_path}:{ry}|{reasoning_lora_path}:{ri}|{twostep_lora_path}:{rw}|{mcfurry_lora_path}:{mc}|{dm_lora_path}:{dm}|{praxis_lora_path}:{pr}|{threed_lora_path}:{td}|{concept_lora_path}:{co}|{bulge_lora_path}:{bu}"
423
- key = hashlib.sha256(key_str.encode("utf-8")).hexdigest()
424
- return key, key_str
425
-
426
-
427
- def prepare_lora_cache(
428
- singularity_strength: float,
429
- teneros_strength: float,
430
- sulphur_strength: float,
431
- pose_strength: float,
432
- general_strength: float,
433
- motion_strength: float,
434
- dreamlay_strength: float,
435
- mself_strength: float,
436
- dramatic_strength: float,
437
- fluid_strength: float,
438
- liquid_strength: float,
439
- demopose_strength: float,
440
- voice_strength: float,
441
- realism_strength: float,
442
- transition_strength: float,
443
- physics_strength: float,
444
- reasoning_strength: float,
445
- twostep_strength: float,
446
- mcfurry_strength: float,
447
- dm_strength: float,
448
- praxis_strength: float,
449
- threed_strength: float,
450
- concept_strength: float,
451
- bulge_strength: float,
452
- progress=gr.Progress(track_tqdm=True),
453
- ):
454
- """
455
- CPU-only step:
456
- - checks cache
457
- - loads cached fused transformer state_dict, or
458
- - builds fused transformer on CPU and saves it
459
- The resulting state_dict is stored in memory and can be applied later.
460
- """
461
- global PENDING_LORA_KEY, PENDING_LORA_STATE, PENDING_LORA_STATUS
462
-
463
- ledger = pipeline.model_ledger
464
- key, _ = _make_lora_key(
465
- singularity_strength, teneros_strength, sulphur_strength, pose_strength,
466
- general_strength, motion_strength, dreamlay_strength, mself_strength,
467
- dramatic_strength, fluid_strength, liquid_strength, demopose_strength,
468
- voice_strength, realism_strength, transition_strength, physics_strength,
469
- reasoning_strength, twostep_strength, mcfurry_strength, dm_strength,
470
- praxis_strength, threed_strength, concept_strength, bulge_strength,
471
- )
472
-
473
- progress(0.05, desc="Preparing LoRA state")
474
- entries = [
475
- (singularity_lora_path, round(float(singularity_strength), 2)),
476
- (teneros_lora_path, round(float(teneros_strength), 2)),
477
- (sulphur_lora_path, round(float(sulphur_strength), 2)),
478
- (pose_lora_path, round(float(pose_strength), 2)),
479
- (general_lora_path, round(float(general_strength), 2)),
480
- (motion_lora_path, round(float(motion_strength), 2)),
481
- (dreamlay_lora_path, round(float(dreamlay_strength), 2)),
482
- (mself_lora_path, round(float(mself_strength), 2)),
483
- (dramatic_lora_path, round(float(dramatic_strength), 2)),
484
- (fluid_lora_path, round(float(fluid_strength), 2)),
485
- (liquid_lora_path, round(float(liquid_strength), 2)),
486
- (demopose_lora_path, round(float(demopose_strength), 2)),
487
- (voice_lora_path, round(float(voice_strength), 2)),
488
- (realism_lora_path, round(float(realism_strength), 2)),
489
- (transition_lora_path, round(float(transition_strength), 2)),
490
- (physics_lora_path, round(float(physics_strength), 2)),
491
- (reasoning_lora_path, round(float(reasoning_strength), 2)),
492
- (twostep_lora_path, round(float(twostep_strength), 2)),
493
- (mcfurry_lora_path, round(float(mcfurry_strength), 2)),
494
- (dm_lora_path, round(float(dm_strength), 2)),
495
- (praxis_lora_path, round(float(praxis_strength), 2)),
496
- (threed_lora_path, round(float(threed_strength), 2)),
497
- (concept_lora_path, round(float(concept_strength), 2)),
498
- (bulge_lora_path, round(float(bulge_strength), 2)),
499
- ]
500
- loras_for_builder = [
501
- LoraPathStrengthAndSDOps(path, strength, LTXV_LORA_COMFY_RENAMING_MAP)
502
- for path, strength in entries
503
- if path is not None and float(strength) != 0.0
504
- ]
505
-
506
- if not loras_for_builder:
507
- PENDING_LORA_KEY = None
508
- PENDING_LORA_STATE = None
509
- PENDING_LORA_STATUS = "No non-zero LoRA strengths selected; nothing to prepare."
510
- return PENDING_LORA_STATUS
511
-
512
- tmp_ledger = None
513
- new_transformer_cpu = None
514
- try:
515
- progress(0.35, desc="Building fused CPU transformer")
516
- tmp_ledger = pipeline.model_ledger.__class__(
517
- dtype=ledger.dtype,
518
- device=torch.device("cpu"),
519
- checkpoint_path=str(checkpoint_path),
520
- spatial_upsampler_path=str(spatial_upsampler_path),
521
- gemma_root_path=str(gemma_root),
522
- loras=tuple(loras_for_builder),
523
- quantization=None,
524
- )
525
- new_transformer_cpu = tmp_ledger.transformer()
526
-
527
- progress(0.70, desc="Extracting fused state_dict")
528
- state = {
529
- k: v.detach().cpu().contiguous()
530
- for k, v in new_transformer_cpu.state_dict().items()
531
- }
532
- PENDING_LORA_KEY = key
533
- PENDING_LORA_STATE = state
534
- PENDING_LORA_STATUS = "Built LoRA state (ready to apply)."
535
- return PENDING_LORA_STATUS
536
-
537
- except Exception as e:
538
- import traceback
539
- print(f"[LoRA] Prepare failed: {type(e).__name__}: {e}")
540
- print(traceback.format_exc())
541
- PENDING_LORA_KEY = None
542
- PENDING_LORA_STATE = None
543
- PENDING_LORA_STATUS = f"LoRA prepare failed: {type(e).__name__}: {e}"
544
- return PENDING_LORA_STATUS
545
-
546
- finally:
547
- try:
548
- del new_transformer_cpu
549
- except Exception:
550
- pass
551
- try:
552
- del tmp_ledger
553
- except Exception:
554
- pass
555
- gc.collect()
556
-
557
-
558
- def apply_prepared_lora_state_to_pipeline():
559
- """
560
- Fast ZeroGPU step: copy the already prepared CPU state into the live
561
- transformer, then immediately free the CPU-side copy.
562
- """
563
- global current_lora_key, PENDING_LORA_KEY, PENDING_LORA_STATE, PENDING_LORA_STATUS
564
-
565
- if PENDING_LORA_KEY is None:
566
- print("[LoRA] No prepared LoRA key available; skipping.")
567
- return False
568
-
569
- # The same LoRA weights are already loaded into _transformer; just make
570
- # sure the CPU copy is not wasting RAM.
571
- if current_lora_key == PENDING_LORA_KEY:
572
- if PENDING_LORA_STATE is not None:
573
- PENDING_LORA_STATE = None
574
- PENDING_LORA_STATUS = "LoRA state already active; CPU copy freed."
575
- print("[LoRA] Prepared LoRA state already active; skipping.")
576
- return True
577
-
578
- if PENDING_LORA_STATE is None:
579
- print("[LoRA] LoRA key changed but no CPU state is available; skipping.")
580
- return False
581
-
582
- existing_transformer = _transformer
583
- with torch.no_grad():
584
- missing, unexpected = existing_transformer.load_state_dict(PENDING_LORA_STATE, strict=False)
585
- if missing or unexpected:
586
- print(f"[LoRA] load_state_dict mismatch: missing={len(missing)}, unexpected={len(unexpected)}")
587
-
588
- current_lora_key = PENDING_LORA_KEY
589
-
590
- # The weights now live in the live transformer, so drop the CPU copy to
591
- # avoid holding an extra full transformer in RAM.
592
- PENDING_LORA_STATE = None
593
- PENDING_LORA_STATUS = "LoRA state applied to pipeline."
594
- print("[LoRA] Prepared LoRA state applied to the pipeline.")
595
- return True
596
-
597
- # ---- REPLACE PRELOAD BLOCK START ----
598
- # Preload all models for ZeroGPU tensor packing.
599
- print("Preloading all models (including Gemma and audio components)...")
600
- ledger = pipeline.model_ledger
601
-
602
- # Save the original factory methods so we can rebuild individual components later.
603
- # These are bound callables on ledger that will call the builder when invoked.
604
- _orig_transformer_factory = ledger.transformer
605
- _orig_video_encoder_factory = ledger.video_encoder
606
- _orig_video_decoder_factory = ledger.video_decoder
607
- _orig_audio_encoder_factory = ledger.audio_encoder
608
- _orig_audio_decoder_factory = ledger.audio_decoder
609
- _orig_vocoder_factory = ledger.vocoder
610
- _orig_spatial_upsampler_factory = ledger.spatial_upsampler
611
- _orig_text_encoder_factory = ledger.text_encoder
612
- _orig_gemma_embeddings_factory = ledger.gemma_embeddings_processor
613
-
614
- # Call the original factories once to create the cached instances we will serve by default.
615
- _transformer = _orig_transformer_factory()
616
- _video_encoder = _orig_video_encoder_factory()
617
- _video_decoder = _orig_video_decoder_factory()
618
- _audio_encoder = _orig_audio_encoder_factory()
619
- _audio_decoder = _orig_audio_decoder_factory()
620
- _vocoder = _orig_vocoder_factory()
621
- _spatial_upsampler = _orig_spatial_upsampler_factory()
622
- _text_encoder = _orig_text_encoder_factory()
623
- _embeddings_processor = _orig_gemma_embeddings_factory()
624
-
625
- # Replace ledger methods with lightweight lambdas that return the cached instances.
626
- # We keep the original factories above so we can call them later to rebuild components.
627
- ledger.transformer = lambda: _transformer
628
- ledger.video_encoder = lambda: _video_encoder
629
- ledger.video_decoder = lambda: _video_decoder
630
- ledger.audio_encoder = lambda: _audio_encoder
631
- ledger.audio_decoder = lambda: _audio_decoder
632
- ledger.vocoder = lambda: _vocoder
633
- ledger.spatial_upsampler = lambda: _spatial_upsampler
634
- ledger.text_encoder = lambda: _text_encoder
635
- ledger.gemma_embeddings_processor = lambda: _embeddings_processor
636
-
637
- print("All models preloaded (including Gemma text encoder and audio encoder)!")
638
- # ---- REPLACE PRELOAD BLOCK END ----
639
-
640
- print("=" * 80)
641
- print("Pipeline ready!")
642
- print("=" * 80)
643
-
644
-
645
- def log_memory(tag: str):
646
- if torch.cuda.is_available():
647
- allocated = torch.cuda.memory_allocated() / 1024**3
648
- peak = torch.cuda.max_memory_allocated() / 1024**3
649
- free, total = torch.cuda.mem_get_info()
650
- print(f"[VRAM {tag}] allocated={allocated:.2f}GB peak={peak:.2f}GB free={free / 1024**3:.2f}GB total={total / 1024**3:.2f}GB")
651
-
652
-
653
- def detect_aspect_ratio(image) -> str:
654
- if image is None:
655
- return "16:9"
656
- if hasattr(image, "size"):
657
- w, h = image.size
658
- elif hasattr(image, "shape"):
659
- h, w = image.shape[:2]
660
- else:
661
- return "16:9"
662
- ratio = w / h
663
- candidates = {"16:9": 16 / 9, "9:16": 9 / 16, "1:1": 1.0}
664
- return min(candidates, key=lambda k: abs(ratio - candidates[k]))
665
-
666
-
667
- def on_image_upload(first_image, last_image, high_res):
668
- ref_image = first_image if first_image is not None else last_image
669
- aspect = detect_aspect_ratio(ref_image)
670
- tier = "high" if high_res else "low"
671
- w, h = RESOLUTIONS[tier][aspect]
672
- return gr.update(value=w), gr.update(value=h)
673
-
674
-
675
- def on_highres_toggle(first_image, last_image, high_res):
676
- ref_image = first_image if first_image is not None else last_image
677
- aspect = detect_aspect_ratio(ref_image)
678
- tier = "high" if high_res else "low"
679
- w, h = RESOLUTIONS[tier][aspect]
680
- return gr.update(value=w), gr.update(value=h)
681
-
682
-
683
- def get_gpu_duration(
684
- first_image,
685
- last_image,
686
- input_audio,
687
- prompt: str,
688
- duration: float = 0.0,
689
- gpu_duration: float = 0.0,
690
- enhance_prompt: bool = False,
691
- seed: int = 42,
692
- randomize_seed: bool = False,
693
- height: int = 0.0,
694
- width: int = 0.0,
695
- singularity_strength: float = 0.0,
696
- teneros_strength: float = 0.0,
697
- sulphur_strength: float = 0.0,
698
- pose_strength: float = 0.0,
699
- general_strength: float = 0.0,
700
- motion_strength: float = 0.0,
701
- dreamlay_strength: float = 0.0,
702
- mself_strength: float = 0.0,
703
- dramatic_strength: float = 0.0,
704
- fluid_strength: float = 0.0,
705
- liquid_strength: float = 0.0,
706
- demopose_strength: float = 0.0,
707
- voice_strength: float = 0.0,
708
- realism_strength: float = 0.0,
709
- transition_strength: float = 0.0,
710
- physics_strength: float = 0.0,
711
- reasoning_strength: float = 0.0,
712
- twostep_strength: float = 0.0,
713
- mcfurry_strength: float = 0.0,
714
- dm_strength: float = 0.0,
715
- praxis_strength: float = 0.0,
716
- threed_strength: float = 0.0,
717
- concept_strength: float = 0.0,
718
- bulge_strength: float = 0.0,
719
- progress=None,
720
- ):
721
- return int(gpu_duration)
722
-
723
- @spaces.GPU(duration=get_gpu_duration)
724
- @torch.inference_mode()
725
- def generate_video(
726
- first_image,
727
- last_image,
728
- input_audio,
729
- prompt: str,
730
- duration: float = 0.0,
731
- gpu_duration: float = 0.0,
732
- enhance_prompt: bool = True,
733
- seed: int = 42,
734
- randomize_seed: bool = True,
735
- height: int = 0.0,
736
- width: int = 0.0,
737
- singularity_strength: float = 0.0,
738
- teneros_strength: float = 0.0,
739
- sulphur_strength: float = 0.0,
740
- pose_strength: float = 0.0,
741
- general_strength: float = 0.0,
742
- motion_strength: float = 0.0,
743
- dreamlay_strength: float = 0.0,
744
- mself_strength: float = 0.0,
745
- dramatic_strength: float = 0.0,
746
- fluid_strength: float = 0.0,
747
- liquid_strength: float = 0.0,
748
- demopose_strength: float = 0.0,
749
- voice_strength: float = 0.0,
750
- realism_strength: float = 0.0,
751
- transition_strength: float = 0.0,
752
- physics_strength: float = 0.0,
753
- reasoning_strength: float = 0.0,
754
- twostep_strength: float = 0.0,
755
- mcfurry_strength: float = 0.0,
756
- dm_strength: float = 0.0,
757
- praxis_strength: float = 0.0,
758
- threed_strength: float = 0.0,
759
- concept_strength: float = 0.0,
760
- bulge_strength: float = 0.0,
761
- progress=gr.Progress(track_tqdm=True),
762
- ):
763
- try:
764
- torch.cuda.reset_peak_memory_stats()
765
- log_memory("start")
766
-
767
- current_seed = random.randint(0, MAX_SEED) if randomize_seed else int(seed)
768
-
769
- frame_rate = DEFAULT_FRAME_RATE
770
- num_frames = int(duration * frame_rate) + 1
771
- num_frames = ((num_frames - 1 + 7) // 8) * 8 + 1
772
-
773
- print(f"Generating: {height}x{width}, {num_frames} frames ({duration}s), seed={current_seed}")
774
-
775
- images = []
776
- output_dir = Path("outputs")
777
- output_dir.mkdir(exist_ok=True)
778
-
779
- if first_image is not None:
780
- temp_first_path = output_dir / f"temp_first_{current_seed}.jpg"
781
- if hasattr(first_image, "save"):
782
- first_image.save(temp_first_path)
783
- else:
784
- temp_first_path = Path(first_image)
785
- images.append(ImageConditioningInput(path=str(temp_first_path), frame_idx=0, strength=1.0))
786
-
787
- if last_image is not None:
788
- temp_last_path = output_dir / f"temp_last_{current_seed}.jpg"
789
- if hasattr(last_image, "save"):
790
- last_image.save(temp_last_path)
791
- else:
792
- temp_last_path = Path(last_image)
793
- images.append(ImageConditioningInput(path=str(temp_last_path), frame_idx=num_frames - 1, strength=1.0))
794
-
795
- tiling_config = TilingConfig.default()
796
- video_chunks_number = get_video_chunks_number(num_frames, tiling_config)
797
-
798
- log_memory("before pipeline call")
799
-
800
- apply_prepared_lora_state_to_pipeline()
801
-
802
- video, audio = pipeline(
803
- prompt=prompt,
804
- seed=current_seed,
805
- height=int(height),
806
- width=int(width),
807
- num_frames=num_frames,
808
- frame_rate=frame_rate,
809
- images=images,
810
- audio_path=input_audio,
811
- tiling_config=tiling_config,
812
- enhance_prompt=enhance_prompt,
813
- )
814
-
815
- log_memory("after pipeline call")
816
-
817
- output_path = tempfile.mktemp(suffix=".mp4")
818
- encode_video(
819
- video=video,
820
- fps=frame_rate,
821
- audio=audio,
822
- output_path=output_path,
823
- video_chunks_number=video_chunks_number,
824
- )
825
-
826
- log_memory("after encode_video")
827
- return str(output_path), current_seed
828
-
829
- except Exception as e:
830
- import traceback
831
- log_memory("on error")
832
- print(f"Error: {str(e)}\n{traceback.format_exc()}")
833
- return None, current_seed
834
-
835
-
836
- with gr.Blocks(title="LTX-2.3 Distilled") as demo:
837
- gr.Markdown("# LTX-2.3 F2LF with Fast Audio-Video Generation with Frame Conditioning")
838
-
839
-
840
- with gr.Row():
841
- with gr.Column():
842
- with gr.Row():
843
- first_image = gr.Image(label="First Frame (Optional)", type="pil")
844
- last_image = gr.Image(label="Last Frame (Optional)", type="pil")
845
- input_audio = gr.Audio(label="Audio Input (Optional)", type="filepath")
846
- prompt = gr.Textbox(
847
- label="Prompt",
848
- info="for best results - make it as elaborate as possible",
849
- value="Make this image come alive with cinematic motion, smooth animation",
850
- lines=3,
851
- placeholder="Describe the motion and animation you want...",
852
- )
853
- duration = gr.Slider(label="Duration (seconds)", minimum=1.0, maximum=30.0, value=10.0, step=0.1)
854
-
855
-
856
- generate_btn = gr.Button("Generate Video", variant="primary", size="lg")
857
-
858
- with gr.Accordion("Advanced Settings", open=False):
859
- seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, value=10, step=1)
860
- randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
861
- with gr.Row():
862
- width = gr.Number(label="Width", value=1536, precision=0)
863
- height = gr.Number(label="Height", value=1024, precision=0)
864
- with gr.Row():
865
- enhance_prompt = gr.Checkbox(label="Enhance Prompt", value=False)
866
- high_res = gr.Checkbox(label="High Resolution", value=True)
867
- with gr.Column():
868
- gr.Markdown("### LoRA adapter strengths (set to 0 to disable; slow and WIP)")
869
- singularity_strength = gr.Slider(
870
- label="Distilled Lora strength",
871
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
872
- )
873
- teneros_strength = gr.Slider(
874
- label="Multipurpose furry strength",
875
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
876
- )
877
- sulphur_strength = gr.Slider(
878
- label="Floaty/Slow Motion Reducer strength",
879
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
880
- )
881
- pose_strength = gr.Slider(
882
- label="Anthro Enhancer strength",
883
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
884
- )
885
- general_strength = gr.Slider(
886
- label="Reasoning Enhancer strength",
887
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
888
- )
889
- motion_strength = gr.Slider(
890
- label="Anthro Posing Helper strength",
891
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
892
- )
893
- dreamlay_strength = gr.Slider(
894
- label="Dreamlay strength",
895
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
896
- )
897
- mself_strength = gr.Slider(
898
- label="2D enhancer strength",
899
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
900
- )
901
- dramatic_strength = gr.Slider(
902
- label="Transition enhancer strength",
903
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
904
- )
905
- fluid_strength = gr.Slider(
906
- label="Fluid Helper strength",
907
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
908
- )
909
- liquid_strength = gr.Slider(
910
- label="Liquid Helper strength",
911
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
912
- )
913
- demopose_strength = gr.Slider(
914
- label="Audio Helper strength",
915
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
916
- )
917
- voice_strength = gr.Slider(
918
- label="Voice Helper strength",
919
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
920
- )
921
- realism_strength = gr.Slider(
922
- label="Anthro Realism strength",
923
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
924
- )
925
- transition_strength = gr.Slider(
926
- label="POV strength",
927
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
928
- )
929
- physics_strength = gr.Slider(
930
- label="Physics strength",
931
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
932
- )
933
- reasoning_strength = gr.Slider(
934
- label="Official Reasoning strength",
935
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
936
- )
937
- twostep_strength = gr.Slider(
938
- label="Two Step Reasoning strength",
939
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
940
- )
941
- mcfurry_strength = gr.Slider(
942
- label="I2V Motion enhancer strength",
943
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
944
- )
945
- dm_strength = gr.Slider(
946
- label="DM3D strength",
947
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
948
- )
949
- praxis_strength = gr.Slider(
950
- label="Praxis strength",
951
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
952
- )
953
- threed_strength = gr.Slider(
954
- label="3D animation strength",
955
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
956
- )
957
- concept_strength = gr.Slider(
958
- label="Conceptual strength",
959
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
960
- )
961
- bulge_strength = gr.Slider(
962
- label="Bulge strength",
963
- minimum=0.0, maximum=2.0, value=0.0, step=0.01
964
- )
965
- prepare_lora_btn = gr.Button("Prepare / Load LoRA Cache", variant="secondary")
966
- lora_status = gr.Textbox(
967
- label="LoRA Cache Status",
968
- value="No LoRA state prepared yet.",
969
- interactive=False,
970
- )
971
-
972
- with gr.Column():
973
- output_video = gr.Video(label="Generated Video", autoplay=False)
974
- gpu_duration = gr.Slider(
975
- label="ZeroGPU duration (seconds; 10 second Img2Vid with 1024x1024 and LoRAs = ~70)",
976
- minimum=30.0,
977
- maximum=240.0,
978
- value=75.0,
979
- step=1.0,
980
- )
981
-
982
- first_image.change(
983
- fn=on_image_upload,
984
- inputs=[first_image, last_image, high_res],
985
- outputs=[width, height],
986
- )
987
-
988
- last_image.change(
989
- fn=on_image_upload,
990
- inputs=[first_image, last_image, high_res],
991
- outputs=[width, height],
992
- )
993
-
994
- high_res.change(
995
- fn=on_highres_toggle,
996
- inputs=[first_image, last_image, high_res],
997
- outputs=[width, height],
998
- )
999
-
1000
- prepare_lora_btn.click(
1001
- fn=prepare_lora_cache,
1002
- inputs=[singularity_strength, teneros_strength, sulphur_strength, pose_strength, general_strength, motion_strength, dreamlay_strength, mself_strength, dramatic_strength, fluid_strength, liquid_strength, demopose_strength, voice_strength, realism_strength, transition_strength, physics_strength, reasoning_strength, twostep_strength, mcfurry_strength, dm_strength, praxis_strength, threed_strength, concept_strength, bulge_strength],
1003
- outputs=[lora_status],
1004
- )
1005
-
1006
- generate_btn.click(
1007
- fn=generate_video,
1008
- inputs=[
1009
- first_image, last_image, input_audio, prompt, duration, gpu_duration, enhance_prompt,
1010
- seed, randomize_seed, height, width,
1011
- singularity_strength, teneros_strength, sulphur_strength, pose_strength, general_strength, motion_strength, dreamlay_strength, mself_strength, dramatic_strength, fluid_strength, liquid_strength, demopose_strength, voice_strength, realism_strength, transition_strength, physics_strength, reasoning_strength, twostep_strength, mcfurry_strength, dm_strength, praxis_strength, threed_strength, concept_strength, bulge_strength,
1012
- ],
1013
- outputs=[output_video, seed],
1014
- )
1015
-
1016
-
1017
- css = """
1018
- .fillable{max-width: 1200px !important}
1019
- """
1020
-
1021
- if __name__ == "__main__":
1022
- demo.launch(theme=gr.themes.Citrus(), css=css)