Vicente Alvarez commited on
Commit
3b38a35
·
1 Parent(s): ccd3f47

Use separate input fields for 3 prompts instead of multi-line textbox

Browse files
Files changed (1) hide show
  1. app.py +25 -11
app.py CHANGED
@@ -519,7 +519,9 @@ def generate_video(
519
  def full_generation_process(
520
  first_image,
521
  last_image,
522
- prompt: str,
 
 
523
  duration: float,
524
  enhance_prompt: bool,
525
  seed: int,
@@ -534,11 +536,10 @@ def full_generation_process(
534
  ):
535
  """Main entry point: generates clips (GPU) then optionally loops with audio (CPU)."""
536
 
537
- # Parse prompts (one per line, max 3)
538
- prompts = [p.strip() for p in prompt.split('\n') if p.strip()]
539
  if not prompts:
540
  return None, seed
541
- prompts = prompts[:3] # Limit to 3 clips max
542
 
543
  print(f"Generating {len(prompts)} clip(s)")
544
 
@@ -578,12 +579,23 @@ with gr.Blocks(title="Element-8 Video", delete_cache=(3600, 7200)) as demo: # c
578
  with gr.Row():
579
  first_image = gr.Image(label="First Frame (Optional)", type="pil")
580
  last_image = gr.Image(label="Last Frame (Optional)", type="pil")
581
- prompt = gr.Textbox(
582
- label="Prompts (one per line for multiple clips)",
583
- info="Enter 1-3 prompts, one per line. Each generates a separate clip.",
584
  value="Make this image come alive with cinematic motion, smooth animation",
585
- lines=5,
586
- placeholder="Prompt 1...\nPrompt 2...\nPrompt 3...",
 
 
 
 
 
 
 
 
 
 
 
 
587
  )
588
  duration = gr.Slider(label="Duration (seconds)", minimum=1.0, maximum=10.0, value=3.0, step=0.1)
589
  audio_track = gr.Audio(label="Audio Track (Optional) - loops clips to match duration", type="filepath", sources=["upload"])
@@ -623,6 +635,8 @@ with gr.Blocks(title="Element-8 Video", delete_cache=(3600, 7200)) as demo: # c
623
  "has a strong fisheye effect, creating a circular frame around them. They "
624
  "crowd together closely, forming a symmetrical cluster while staring "
625
  "directly into the lens.",
 
 
626
  3.0,
627
  False,
628
  42,
@@ -632,7 +646,7 @@ with gr.Blocks(title="Element-8 Video", delete_cache=(3600, 7200)) as demo: # c
632
  ],
633
  ],
634
  inputs=[
635
- first_image, last_image, prompt, duration,
636
  enhance_prompt, seed, randomize_seed, height, width,
637
  ],
638
  )
@@ -658,7 +672,7 @@ with gr.Blocks(title="Element-8 Video", delete_cache=(3600, 7200)) as demo: # c
658
  generate_btn.click(
659
  fn=full_generation_process,
660
  inputs=[
661
- first_image, last_image, prompt, duration, enhance_prompt,
662
  seed, randomize_seed, height, width, negative_prompt, blur_amount, remove_music,
663
  audio_track,
664
  ],
 
519
  def full_generation_process(
520
  first_image,
521
  last_image,
522
+ prompt1: str,
523
+ prompt2: str,
524
+ prompt3: str,
525
  duration: float,
526
  enhance_prompt: bool,
527
  seed: int,
 
536
  ):
537
  """Main entry point: generates clips (GPU) then optionally loops with audio (CPU)."""
538
 
539
+ # Collect non-empty prompts
540
+ prompts = [p.strip() for p in [prompt1, prompt2, prompt3] if p and p.strip()]
541
  if not prompts:
542
  return None, seed
 
543
 
544
  print(f"Generating {len(prompts)} clip(s)")
545
 
 
579
  with gr.Row():
580
  first_image = gr.Image(label="First Frame (Optional)", type="pil")
581
  last_image = gr.Image(label="Last Frame (Optional)", type="pil")
582
+ prompt1 = gr.Textbox(
583
+ label="Prompt 1",
 
584
  value="Make this image come alive with cinematic motion, smooth animation",
585
+ lines=2,
586
+ placeholder="First prompt (required)",
587
+ )
588
+ prompt2 = gr.Textbox(
589
+ label="Prompt 2 (Optional)",
590
+ value="",
591
+ lines=2,
592
+ placeholder="Second prompt (leave empty if not needed)",
593
+ )
594
+ prompt3 = gr.Textbox(
595
+ label="Prompt 3 (Optional)",
596
+ value="",
597
+ lines=2,
598
+ placeholder="Third prompt (leave empty if not needed)",
599
  )
600
  duration = gr.Slider(label="Duration (seconds)", minimum=1.0, maximum=10.0, value=3.0, step=0.1)
601
  audio_track = gr.Audio(label="Audio Track (Optional) - loops clips to match duration", type="filepath", sources=["upload"])
 
635
  "has a strong fisheye effect, creating a circular frame around them. They "
636
  "crowd together closely, forming a symmetrical cluster while staring "
637
  "directly into the lens.",
638
+ "",
639
+ "",
640
  3.0,
641
  False,
642
  42,
 
646
  ],
647
  ],
648
  inputs=[
649
+ first_image, last_image, prompt1, prompt2, prompt3, duration,
650
  enhance_prompt, seed, randomize_seed, height, width,
651
  ],
652
  )
 
672
  generate_btn.click(
673
  fn=full_generation_process,
674
  inputs=[
675
+ first_image, last_image, prompt1, prompt2, prompt3, duration, enhance_prompt,
676
  seed, randomize_seed, height, width, negative_prompt, blur_amount, remove_music,
677
  audio_track,
678
  ],