Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -273,8 +273,8 @@ PENDING_LORA_STATUS: str = "No LoRA state prepared yet."
|
|
| 273 |
weights_dir = Path("weights")
|
| 274 |
weights_dir.mkdir(exist_ok=True)
|
| 275 |
checkpoint_path = hf_hub_download(
|
| 276 |
-
repo_id="
|
| 277 |
-
filename="
|
| 278 |
local_dir=str(weights_dir),
|
| 279 |
local_dir_use_symlinks=False,
|
| 280 |
)
|
|
@@ -290,6 +290,8 @@ LORA_REPO = "dagloop5/LoRA"
|
|
| 290 |
print("=" * 80)
|
| 291 |
print("Downloading LoRA adapters from dagloop5/LoRA...")
|
| 292 |
print("=" * 80)
|
|
|
|
|
|
|
| 293 |
pose_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2_3_NSFW_furry_concat_v2.safetensors")
|
| 294 |
general_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_reasoning_I2V_V3.safetensors")
|
| 295 |
motion_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="Sulphur_LTX 2.3_better _NSFW_motion.safetensors")
|
|
@@ -306,6 +308,8 @@ physics_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_Physics_
|
|
| 306 |
reasoning_lora_path = hf_hub_download(repo_id="LiconStudio/Ltx2.3-VBVR-lora-I2V", filename="Ltx2.3-Licon-VBVR-I2V-390K-R32.safetensors")
|
| 307 |
twostep_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_Multi_step_video_reasoning_V0.1.safetensors")
|
| 308 |
|
|
|
|
|
|
|
| 309 |
print(f"Pose LoRA: {pose_lora_path}")
|
| 310 |
print(f"General LoRA: {general_lora_path}")
|
| 311 |
print(f"Motion LoRA: {motion_lora_path}")
|
|
@@ -334,11 +338,13 @@ pipeline = LTX23DistilledA2VPipeline(
|
|
| 334 |
spatial_upsampler_path=spatial_upsampler_path,
|
| 335 |
gemma_root=gemma_root,
|
| 336 |
loras=[],
|
| 337 |
-
quantization=
|
| 338 |
)
|
| 339 |
# ----------------------------------------------------------------
|
| 340 |
|
| 341 |
-
def _make_lora_key(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) -> tuple[str, str]:
|
|
|
|
|
|
|
| 342 |
rp = round(float(pose_strength), 2)
|
| 343 |
rg = round(float(general_strength), 2)
|
| 344 |
rm = round(float(motion_strength), 2)
|
|
@@ -354,12 +360,14 @@ def _make_lora_key(pose_strength: float, general_strength: float, motion_strengt
|
|
| 354 |
ry = round(float(physics_strength), 2)
|
| 355 |
ri = round(float(reasoning_strength), 2)
|
| 356 |
rw = round(float(twostep_strength), 2)
|
| 357 |
-
key_str = f"{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}"
|
| 358 |
key = hashlib.sha256(key_str.encode("utf-8")).hexdigest()
|
| 359 |
return key, key_str
|
| 360 |
|
| 361 |
|
| 362 |
def prepare_lora_cache(
|
|
|
|
|
|
|
| 363 |
pose_strength: float,
|
| 364 |
general_strength: float,
|
| 365 |
motion_strength: float,
|
|
@@ -387,7 +395,7 @@ def prepare_lora_cache(
|
|
| 387 |
global PENDING_LORA_KEY, PENDING_LORA_STATE, PENDING_LORA_STATUS
|
| 388 |
|
| 389 |
ledger = pipeline.model_ledger
|
| 390 |
-
key, _ = _make_lora_key(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)
|
| 391 |
cache_path = LORA_CACHE_DIR / f"{key}.safetensors"
|
| 392 |
|
| 393 |
progress(0.05, desc="Preparing LoRA state")
|
|
@@ -403,6 +411,8 @@ def prepare_lora_cache(
|
|
| 403 |
print(f"[LoRA] Cache load failed: {type(e).__name__}: {e}")
|
| 404 |
|
| 405 |
entries = [
|
|
|
|
|
|
|
| 406 |
(pose_lora_path, round(float(pose_strength), 2)),
|
| 407 |
(general_lora_path, round(float(general_strength), 2)),
|
| 408 |
(motion_lora_path, round(float(motion_strength), 2)),
|
|
@@ -602,6 +612,8 @@ def get_gpu_duration(
|
|
| 602 |
randomize_seed: bool = False,
|
| 603 |
height: int = 0.0,
|
| 604 |
width: int = 0.0,
|
|
|
|
|
|
|
| 605 |
pose_strength: float = 0.0,
|
| 606 |
general_strength: float = 0.0,
|
| 607 |
motion_strength: float = 0.0,
|
|
@@ -635,6 +647,8 @@ def generate_video(
|
|
| 635 |
randomize_seed: bool = True,
|
| 636 |
height: int = 0.0,
|
| 637 |
width: int = 0.0,
|
|
|
|
|
|
|
| 638 |
pose_strength: float = 0.0,
|
| 639 |
general_strength: float = 0.0,
|
| 640 |
motion_strength: float = 0.0,
|
|
@@ -758,6 +772,14 @@ with gr.Blocks(title="LTX-2.3 Distilled") as demo:
|
|
| 758 |
high_res = gr.Checkbox(label="High Resolution", value=True)
|
| 759 |
with gr.Column():
|
| 760 |
gr.Markdown("### LoRA adapter strengths (set to 0 to disable; slow and WIP)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 761 |
pose_strength = gr.Slider(
|
| 762 |
label="Anthro Enhancer strength",
|
| 763 |
minimum=0.0, maximum=2.0, value=0.0, step=0.01
|
|
@@ -835,49 +857,6 @@ with gr.Blocks(title="LTX-2.3 Distilled") as demo:
|
|
| 835 |
step=1.0,
|
| 836 |
)
|
| 837 |
|
| 838 |
-
gr.Examples(
|
| 839 |
-
examples=[
|
| 840 |
-
[
|
| 841 |
-
None,
|
| 842 |
-
"pinkknit.jpg",
|
| 843 |
-
None,
|
| 844 |
-
"The camera falls downward through darkness as if dropped into a tunnel. "
|
| 845 |
-
"As it slows, five friends wearing pink knitted hats and sunglasses lean "
|
| 846 |
-
"over and look down toward the camera with curious expressions. The lens "
|
| 847 |
-
"has a strong fisheye effect, creating a circular frame around them. They "
|
| 848 |
-
"crowd together closely, forming a symmetrical cluster while staring "
|
| 849 |
-
"directly into the lens.",
|
| 850 |
-
3.0,
|
| 851 |
-
80.0,
|
| 852 |
-
False,
|
| 853 |
-
42,
|
| 854 |
-
True,
|
| 855 |
-
1024,
|
| 856 |
-
1024,
|
| 857 |
-
0.0, # pose_strength (example)
|
| 858 |
-
0.0, # general_strength (example)
|
| 859 |
-
0.0, # motion_strength (example)
|
| 860 |
-
0.0,
|
| 861 |
-
0.0,
|
| 862 |
-
0.0,
|
| 863 |
-
0.0,
|
| 864 |
-
0.0,
|
| 865 |
-
0.0,
|
| 866 |
-
0.0,
|
| 867 |
-
0.0,
|
| 868 |
-
0.0,
|
| 869 |
-
0.0,
|
| 870 |
-
0.0,
|
| 871 |
-
0.0,
|
| 872 |
-
],
|
| 873 |
-
],
|
| 874 |
-
inputs=[
|
| 875 |
-
first_image, last_image, input_audio, prompt, duration, gpu_duration,
|
| 876 |
-
enhance_prompt, seed, randomize_seed, height, width,
|
| 877 |
-
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,
|
| 878 |
-
],
|
| 879 |
-
)
|
| 880 |
-
|
| 881 |
first_image.change(
|
| 882 |
fn=on_image_upload,
|
| 883 |
inputs=[first_image, last_image, high_res],
|
|
@@ -898,7 +877,7 @@ with gr.Blocks(title="LTX-2.3 Distilled") as demo:
|
|
| 898 |
|
| 899 |
prepare_lora_btn.click(
|
| 900 |
fn=prepare_lora_cache,
|
| 901 |
-
inputs=[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],
|
| 902 |
outputs=[lora_status],
|
| 903 |
)
|
| 904 |
|
|
@@ -907,7 +886,7 @@ with gr.Blocks(title="LTX-2.3 Distilled") as demo:
|
|
| 907 |
inputs=[
|
| 908 |
first_image, last_image, input_audio, prompt, duration, gpu_duration, enhance_prompt,
|
| 909 |
seed, randomize_seed, height, width,
|
| 910 |
-
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,
|
| 911 |
],
|
| 912 |
outputs=[output_video, seed],
|
| 913 |
)
|
|
|
|
| 273 |
weights_dir = Path("weights")
|
| 274 |
weights_dir.mkdir(exist_ok=True)
|
| 275 |
checkpoint_path = hf_hub_download(
|
| 276 |
+
repo_id="Lightricks/LTX-2.3",
|
| 277 |
+
filename="ltx-2.3-22b-distilled-1.1.safetensors",
|
| 278 |
local_dir=str(weights_dir),
|
| 279 |
local_dir_use_symlinks=False,
|
| 280 |
)
|
|
|
|
| 290 |
print("=" * 80)
|
| 291 |
print("Downloading LoRA adapters from dagloop5/LoRA...")
|
| 292 |
print("=" * 80)
|
| 293 |
+
teneros_lora_path = hf_hub_download(repo_id="maximsobolev275/LTX-10Eros-LoRA-r768", filename="LTX_10Eros_LoRA_r768.safetensors")
|
| 294 |
+
sulphur_lora_path =hf_hub_download(repo_id="SulphurAI/Sulphur-2-base", filename="sulphur_lora_rank_768.safetensors")
|
| 295 |
pose_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2_3_NSFW_furry_concat_v2.safetensors")
|
| 296 |
general_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_reasoning_I2V_V3.safetensors")
|
| 297 |
motion_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="Sulphur_LTX 2.3_better _NSFW_motion.safetensors")
|
|
|
|
| 308 |
reasoning_lora_path = hf_hub_download(repo_id="LiconStudio/Ltx2.3-VBVR-lora-I2V", filename="Ltx2.3-Licon-VBVR-I2V-390K-R32.safetensors")
|
| 309 |
twostep_lora_path = hf_hub_download(repo_id=LORA_REPO, filename="LTX2.3_Multi_step_video_reasoning_V0.1.safetensors")
|
| 310 |
|
| 311 |
+
print(f"10Eros LoRA: {teneros_lora_path}")
|
| 312 |
+
print(f"Sulphur LoRA: {sulphur_lora_path}")
|
| 313 |
print(f"Pose LoRA: {pose_lora_path}")
|
| 314 |
print(f"General LoRA: {general_lora_path}")
|
| 315 |
print(f"Motion LoRA: {motion_lora_path}")
|
|
|
|
| 338 |
spatial_upsampler_path=spatial_upsampler_path,
|
| 339 |
gemma_root=gemma_root,
|
| 340 |
loras=[],
|
| 341 |
+
quantization=QuantizationPolicy.fp8_cast(), # keep FP8 quantization unchanged
|
| 342 |
)
|
| 343 |
# ----------------------------------------------------------------
|
| 344 |
|
| 345 |
+
def _make_lora_key(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) -> tuple[str, str]:
|
| 346 |
+
ra = round(float(teneros_strength), 2)
|
| 347 |
+
rb = round(float(sulphur_strength), 2)
|
| 348 |
rp = round(float(pose_strength), 2)
|
| 349 |
rg = round(float(general_strength), 2)
|
| 350 |
rm = round(float(motion_strength), 2)
|
|
|
|
| 360 |
ry = round(float(physics_strength), 2)
|
| 361 |
ri = round(float(reasoning_strength), 2)
|
| 362 |
rw = round(float(twostep_strength), 2)
|
| 363 |
+
key_str = f"{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}"
|
| 364 |
key = hashlib.sha256(key_str.encode("utf-8")).hexdigest()
|
| 365 |
return key, key_str
|
| 366 |
|
| 367 |
|
| 368 |
def prepare_lora_cache(
|
| 369 |
+
teneros_strength: float,
|
| 370 |
+
sulphur_strength: float,
|
| 371 |
pose_strength: float,
|
| 372 |
general_strength: float,
|
| 373 |
motion_strength: float,
|
|
|
|
| 395 |
global PENDING_LORA_KEY, PENDING_LORA_STATE, PENDING_LORA_STATUS
|
| 396 |
|
| 397 |
ledger = pipeline.model_ledger
|
| 398 |
+
key, _ = _make_lora_key(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)
|
| 399 |
cache_path = LORA_CACHE_DIR / f"{key}.safetensors"
|
| 400 |
|
| 401 |
progress(0.05, desc="Preparing LoRA state")
|
|
|
|
| 411 |
print(f"[LoRA] Cache load failed: {type(e).__name__}: {e}")
|
| 412 |
|
| 413 |
entries = [
|
| 414 |
+
(teneros_lora_path, round(float(teneros_strength), 2)),
|
| 415 |
+
(sulphur_lora_path, round(float(sulphur_strength), 2)),
|
| 416 |
(pose_lora_path, round(float(pose_strength), 2)),
|
| 417 |
(general_lora_path, round(float(general_strength), 2)),
|
| 418 |
(motion_lora_path, round(float(motion_strength), 2)),
|
|
|
|
| 612 |
randomize_seed: bool = False,
|
| 613 |
height: int = 0.0,
|
| 614 |
width: int = 0.0,
|
| 615 |
+
teneros_strength: float = 0.0,
|
| 616 |
+
sulphur_strength: float = 0.0,
|
| 617 |
pose_strength: float = 0.0,
|
| 618 |
general_strength: float = 0.0,
|
| 619 |
motion_strength: float = 0.0,
|
|
|
|
| 647 |
randomize_seed: bool = True,
|
| 648 |
height: int = 0.0,
|
| 649 |
width: int = 0.0,
|
| 650 |
+
teneros_strength: float = 0.0,
|
| 651 |
+
sulphur_strength: float = 0.0,
|
| 652 |
pose_strength: float = 0.0,
|
| 653 |
general_strength: float = 0.0,
|
| 654 |
motion_strength: float = 0.0,
|
|
|
|
| 772 |
high_res = gr.Checkbox(label="High Resolution", value=True)
|
| 773 |
with gr.Column():
|
| 774 |
gr.Markdown("### LoRA adapter strengths (set to 0 to disable; slow and WIP)")
|
| 775 |
+
teneros_strength = gr.Slider(
|
| 776 |
+
label="10Eros Lora strength",
|
| 777 |
+
minimum=0.0, maximum=2.0, value=0.0, step=0.01
|
| 778 |
+
)
|
| 779 |
+
sulphur_strength = gr.Slider(
|
| 780 |
+
label="Sulphur Lora strength",
|
| 781 |
+
minimum=0.0, maximum=2.0, value=0.0, step=0.01
|
| 782 |
+
)
|
| 783 |
pose_strength = gr.Slider(
|
| 784 |
label="Anthro Enhancer strength",
|
| 785 |
minimum=0.0, maximum=2.0, value=0.0, step=0.01
|
|
|
|
| 857 |
step=1.0,
|
| 858 |
)
|
| 859 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
first_image.change(
|
| 861 |
fn=on_image_upload,
|
| 862 |
inputs=[first_image, last_image, high_res],
|
|
|
|
| 877 |
|
| 878 |
prepare_lora_btn.click(
|
| 879 |
fn=prepare_lora_cache,
|
| 880 |
+
inputs=[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],
|
| 881 |
outputs=[lora_status],
|
| 882 |
)
|
| 883 |
|
|
|
|
| 886 |
inputs=[
|
| 887 |
first_image, last_image, input_audio, prompt, duration, gpu_duration, enhance_prompt,
|
| 888 |
seed, randomize_seed, height, width,
|
| 889 |
+
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,
|
| 890 |
],
|
| 891 |
outputs=[output_video, seed],
|
| 892 |
)
|