amisima commited on
Commit
33ea71b
·
verified ·
1 Parent(s): c783e3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +94 -52
app.py CHANGED
@@ -475,6 +475,7 @@ def generate_video(
475
  flow_shift=6.0,
476
  frame_multiplier=16,
477
  safe_mode=False,
 
478
  lora1_preset="(None)",
479
  lora1_high_scale=1.0,
480
  lora1_low_scale=1.0,
@@ -484,11 +485,12 @@ def generate_video(
484
  lora3_preset="(None)",
485
  lora3_high_scale=1.0,
486
  lora3_low_scale=1.0,
487
- my_repo_link="",
488
- my_file_high="(None)",
489
- my_high_scale=1.0,
490
- my_file_low="(None)",
491
- my_low_scale=1.0,
 
492
  video_component=True,
493
  progress=gr.Progress(track_tqdm=True),
494
  ):
@@ -507,13 +509,11 @@ def generate_video(
507
  {"preset": lora1_preset, "high_scale": lora1_high_scale, "low_scale": lora1_low_scale},
508
  {"preset": lora2_preset, "high_scale": lora2_high_scale, "low_scale": lora2_low_scale},
509
  {"preset": lora3_preset, "high_scale": lora3_high_scale, "low_scale": lora3_low_scale},
510
- {
511
- "repo": my_repo_link,
512
- "file_high": my_file_high,
513
- "file_low": my_file_low,
514
- "high_scale": my_high_scale,
515
- "low_scale": my_low_scale,
516
- },
517
  ]
518
 
519
  video_path, task_n = run_inference(
@@ -540,6 +540,14 @@ def generate_video(
540
  return (video_path if video_component else None), video_path, current_seed
541
 
542
 
 
 
 
 
 
 
 
 
543
  CSS = """
544
  #hidden-timestamp {
545
  opacity: 0;
@@ -591,59 +599,87 @@ with gr.Blocks(delete_cache=(3600, 10800)) as demo:
591
  )
592
  flow_shift_slider = gr.Slider(minimum=0.5, maximum=15.0, step=0.1, value=3.0, label="Flow Shift")
593
 
594
- gr.Markdown("### 1) Original LoRA (NSFW) + strength")
595
  with gr.Row():
596
- lora1_preset = gr.Dropdown(choices=LORA_CHOICES, value="(None)", label="LoRA 1", filterable=True)
597
  lora1_high_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
598
  lora1_low_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
599
  with gr.Row():
600
- lora2_preset = gr.Dropdown(choices=LORA_CHOICES, value="(None)", label="LoRA 2", filterable=True)
601
  lora2_high_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
602
  lora2_low_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
603
  with gr.Row():
604
- lora3_preset = gr.Dropdown(choices=LORA_CHOICES, value="(None)", label="LoRA 3", filterable=True)
605
  lora3_high_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
606
  lora3_low_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
607
 
608
- gr.Markdown("### 2) My LoRA from HF repo link")
609
- gr.Markdown(
610
- "Paste repo link, click **Load files**, then pick High/Low file.\n\n"
611
- "Example: `username/my-lora-repo` or `https://huggingface.co/username/my-lora-repo`"
612
- )
 
 
 
613
  with gr.Row():
614
- my_repo_link = gr.Textbox(
615
- label="HF repo link",
616
- placeholder="username/my-loras",
617
- lines=1,
618
- scale=4,
619
- )
620
- load_repo_btn = gr.Button("Load files", scale=1)
621
 
 
 
622
  with gr.Row():
623
- my_file_high = gr.Dropdown(
624
- choices=["(None)"], value="(None)",
625
- label="My High LoRA file", filterable=True,
626
- )
627
- my_high_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="My High strength")
628
  with gr.Row():
629
- my_file_low = gr.Dropdown(
630
- choices=["(None)"], value="(None)",
631
- label="My Low LoRA file", filterable=True,
632
- )
633
- my_low_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="My Low strength")
634
-
635
- def _load_my_repo_files(repo_link):
636
- files = lora_loader.list_loras_from_repo(repo_link)
637
- return (
638
- gr.update(choices=files, value="(None)"),
639
- gr.update(choices=files, value="(None)"),
640
- )
641
-
642
- load_repo_btn.click(
643
- fn=_load_my_repo_files,
644
- inputs=[my_repo_link],
645
- outputs=[my_file_high, my_file_low],
646
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
 
648
  play_result_video = gr.Checkbox(label="Display result", value=True, interactive=True)
649
 
@@ -664,10 +700,16 @@ with gr.Blocks(delete_cache=(3600, 10800)) as demo:
664
  guidance_scale_input, guidance_scale_2_input, seed_input, randomize_seed_checkbox,
665
  quality_slider, scheduler_dropdown, flow_shift_slider, frame_multi,
666
  safe_mode_checkbox,
 
667
  lora1_preset, lora1_high_scale, lora1_low_scale,
668
  lora2_preset, lora2_high_scale, lora2_low_scale,
669
  lora3_preset, lora3_high_scale, lora3_low_scale,
670
- my_repo_link, my_file_high, my_high_scale, my_file_low, my_low_scale,
 
 
 
 
 
671
  play_result_video,
672
  ]
673
 
 
475
  flow_shift=6.0,
476
  frame_multiplier=16,
477
  safe_mode=False,
478
+ # original 3
479
  lora1_preset="(None)",
480
  lora1_high_scale=1.0,
481
  lora1_low_scale=1.0,
 
485
  lora3_preset="(None)",
486
  lora3_high_scale=1.0,
487
  lora3_low_scale=1.0,
488
+ # my 5
489
+ my1_repo="", my1_high="(None)", my1_hs=1.0, my1_low="(None)", my1_ls=1.0,
490
+ my2_repo="", my2_high="(None)", my2_hs=1.0, my2_low="(None)", my2_ls=1.0,
491
+ my3_repo="", my3_high="(None)", my3_hs=1.0, my3_low="(None)", my3_ls=1.0,
492
+ my4_repo="", my4_high="(None)", my4_hs=1.0, my4_low="(None)", my4_ls=1.0,
493
+ my5_repo="", my5_high="(None)", my5_hs=1.0, my5_low="(None)", my5_ls=1.0,
494
  video_component=True,
495
  progress=gr.Progress(track_tqdm=True),
496
  ):
 
509
  {"preset": lora1_preset, "high_scale": lora1_high_scale, "low_scale": lora1_low_scale},
510
  {"preset": lora2_preset, "high_scale": lora2_high_scale, "low_scale": lora2_low_scale},
511
  {"preset": lora3_preset, "high_scale": lora3_high_scale, "low_scale": lora3_low_scale},
512
+ {"repo": my1_repo, "file_high": my1_high, "file_low": my1_low, "high_scale": my1_hs, "low_scale": my1_ls},
513
+ {"repo": my2_repo, "file_high": my2_high, "file_low": my2_low, "high_scale": my2_hs, "low_scale": my2_ls},
514
+ {"repo": my3_repo, "file_high": my3_high, "file_low": my3_low, "high_scale": my3_hs, "low_scale": my3_ls},
515
+ {"repo": my4_repo, "file_high": my4_high, "file_low": my4_low, "high_scale": my4_hs, "low_scale": my4_ls},
516
+ {"repo": my5_repo, "file_high": my5_high, "file_low": my5_low, "high_scale": my5_hs, "low_scale": my5_ls},
 
 
517
  ]
518
 
519
  video_path, task_n = run_inference(
 
540
  return (video_path if video_component else None), video_path, current_seed
541
 
542
 
543
+ def _load_repo_files(repo_link):
544
+ files = lora_loader.list_loras_from_repo(repo_link)
545
+ return (
546
+ gr.update(choices=files, value="(None)"),
547
+ gr.update(choices=files, value="(None)"),
548
+ )
549
+
550
+
551
  CSS = """
552
  #hidden-timestamp {
553
  opacity: 0;
 
599
  )
600
  flow_shift_slider = gr.Slider(minimum=0.5, maximum=15.0, step=0.1, value=3.0, label="Flow Shift")
601
 
602
+ gr.Markdown("### 1) Original LoRA x3 + strength")
603
  with gr.Row():
604
+ lora1_preset = gr.Dropdown(choices=LORA_CHOICES, value="(None)", label="Original LoRA 1", filterable=True)
605
  lora1_high_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
606
  lora1_low_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
607
  with gr.Row():
608
+ lora2_preset = gr.Dropdown(choices=LORA_CHOICES, value="(None)", label="Original LoRA 2", filterable=True)
609
  lora2_high_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
610
  lora2_low_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
611
  with gr.Row():
612
+ lora3_preset = gr.Dropdown(choices=LORA_CHOICES, value="(None)", label="Original LoRA 3", filterable=True)
613
  lora3_high_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
614
  lora3_low_scale = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
615
 
616
+ gr.Markdown("### 2) My LoRA x5 from HF repo + strength")
617
+ gr.Markdown("For each slot: paste repo → Load files → pick High/Low → set strength. Example: `username/my-loras`")
618
+
619
+ # --- My LoRA 1 ---
620
+ gr.Markdown("**My LoRA 1**")
621
+ with gr.Row():
622
+ my1_repo = gr.Textbox(label="Repo link", placeholder="username/repo", lines=1, scale=4)
623
+ my1_load = gr.Button("Load files", scale=1)
624
  with gr.Row():
625
+ my1_high = gr.Dropdown(choices=["(None)"], value="(None)", label="High file", filterable=True)
626
+ my1_hs = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
627
+ with gr.Row():
628
+ my1_low = gr.Dropdown(choices=["(None)"], value="(None)", label="Low file", filterable=True)
629
+ my1_ls = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
630
+ my1_load.click(fn=_load_repo_files, inputs=[my1_repo], outputs=[my1_high, my1_low])
 
631
 
632
+ # --- My LoRA 2 ---
633
+ gr.Markdown("**My LoRA 2**")
634
  with gr.Row():
635
+ my2_repo = gr.Textbox(label="Repo link", placeholder="username/repo", lines=1, scale=4)
636
+ my2_load = gr.Button("Load files", scale=1)
 
 
 
637
  with gr.Row():
638
+ my2_high = gr.Dropdown(choices=["(None)"], value="(None)", label="High file", filterable=True)
639
+ my2_hs = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
640
+ with gr.Row():
641
+ my2_low = gr.Dropdown(choices=["(None)"], value="(None)", label="Low file", filterable=True)
642
+ my2_ls = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
643
+ my2_load.click(fn=_load_repo_files, inputs=[my2_repo], outputs=[my2_high, my2_low])
644
+
645
+ # --- My LoRA 3 ---
646
+ gr.Markdown("**My LoRA 3**")
647
+ with gr.Row():
648
+ my3_repo = gr.Textbox(label="Repo link", placeholder="username/repo", lines=1, scale=4)
649
+ my3_load = gr.Button("Load files", scale=1)
650
+ with gr.Row():
651
+ my3_high = gr.Dropdown(choices=["(None)"], value="(None)", label="High file", filterable=True)
652
+ my3_hs = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
653
+ with gr.Row():
654
+ my3_low = gr.Dropdown(choices=["(None)"], value="(None)", label="Low file", filterable=True)
655
+ my3_ls = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
656
+ my3_load.click(fn=_load_repo_files, inputs=[my3_repo], outputs=[my3_high, my3_low])
657
+
658
+ # --- My LoRA 4 ---
659
+ gr.Markdown("**My LoRA 4**")
660
+ with gr.Row():
661
+ my4_repo = gr.Textbox(label="Repo link", placeholder="username/repo", lines=1, scale=4)
662
+ my4_load = gr.Button("Load files", scale=1)
663
+ with gr.Row():
664
+ my4_high = gr.Dropdown(choices=["(None)"], value="(None)", label="High file", filterable=True)
665
+ my4_hs = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
666
+ with gr.Row():
667
+ my4_low = gr.Dropdown(choices=["(None)"], value="(None)", label="Low file", filterable=True)
668
+ my4_ls = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
669
+ my4_load.click(fn=_load_repo_files, inputs=[my4_repo], outputs=[my4_high, my4_low])
670
+
671
+ # --- My LoRA 5 ---
672
+ gr.Markdown("**My LoRA 5**")
673
+ with gr.Row():
674
+ my5_repo = gr.Textbox(label="Repo link", placeholder="username/repo", lines=1, scale=4)
675
+ my5_load = gr.Button("Load files", scale=1)
676
+ with gr.Row():
677
+ my5_high = gr.Dropdown(choices=["(None)"], value="(None)", label="High file", filterable=True)
678
+ my5_hs = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="High strength")
679
+ with gr.Row():
680
+ my5_low = gr.Dropdown(choices=["(None)"], value="(None)", label="Low file", filterable=True)
681
+ my5_ls = gr.Slider(0.0, 2.0, value=1.0, step=0.05, label="Low strength")
682
+ my5_load.click(fn=_load_repo_files, inputs=[my5_repo], outputs=[my5_high, my5_low])
683
 
684
  play_result_video = gr.Checkbox(label="Display result", value=True, interactive=True)
685
 
 
700
  guidance_scale_input, guidance_scale_2_input, seed_input, randomize_seed_checkbox,
701
  quality_slider, scheduler_dropdown, flow_shift_slider, frame_multi,
702
  safe_mode_checkbox,
703
+ # original 3
704
  lora1_preset, lora1_high_scale, lora1_low_scale,
705
  lora2_preset, lora2_high_scale, lora2_low_scale,
706
  lora3_preset, lora3_high_scale, lora3_low_scale,
707
+ # my 5
708
+ my1_repo, my1_high, my1_hs, my1_low, my1_ls,
709
+ my2_repo, my2_high, my2_hs, my2_low, my2_ls,
710
+ my3_repo, my3_high, my3_hs, my3_low, my3_ls,
711
+ my4_repo, my4_high, my4_hs, my4_low, my4_ls,
712
+ my5_repo, my5_high, my5_hs, my5_low, my5_ls,
713
  play_result_video,
714
  ]
715