linoyts HF Staff commited on
Commit
a418dac
·
verified ·
1 Parent(s): ddb0915

audio folded into single prompt; inpaint example None->placeholder mask

Browse files
Files changed (1) hide show
  1. app.py +11 -19
app.py CHANGED
@@ -44,11 +44,8 @@ pipe.set_adapters("refsheet", LORA_SCALE)
44
 
45
 
46
  # --- Helpers ----------------------------------------------------------------
47
- def _build_prompt(sheet, action, audio):
48
- p = f"Reference sheet: {sheet.strip()}\n\nGenerated video: {action.strip()}"
49
- if audio.strip():
50
- p += f" Audio: {audio.strip()}."
51
- return p
52
 
53
 
54
  def _export(video_np, audio, path):
@@ -64,7 +61,7 @@ def _duration(*args, **kwargs):
64
 
65
  # --- Inference --------------------------------------------------------------
66
  @spaces.GPU(duration=_duration)
67
- def generate(image, sheet, action, audio, lora_scale, seed, randomize,
68
  progress=gr.Progress(track_tqdm=True)):
69
  if image is None:
70
  raise gr.Error("Please upload a reference sheet image.")
@@ -80,7 +77,7 @@ def generate(image, sheet, action, audio, lora_scale, seed, randomize,
80
  sheet_img = image.convert("RGB").resize((WIDTH, HEIGHT), Image.LANCZOS)
81
  ref = [sheet_img] * NUM_FRAMES
82
  pipe.set_adapters("refsheet", float(lora_scale))
83
- prompt = _build_prompt(sheet, action, audio)
84
 
85
  def _cb(p, i, t, kw):
86
  progress((i + 1) / NUM_STEPS, desc=f"Generating — step {i + 1}/{NUM_STEPS}")
@@ -117,10 +114,8 @@ with gr.Blocks(title="LTX-2.3 Reference Sheet (Fast / Distilled)") as demo:
117
  image_in = gr.Image(type="pil", label="Reference sheet (one clean panel per element, black background)")
118
  sheet = gr.Textbox(label="Reference sheet description", lines=3,
119
  placeholder="a young woman with red hair in a green jacket (face close-up + turnaround); a brass pocket watch; a cobblestone alley at night")
120
- action = gr.Textbox(label="Generated video (the action / shot)", lines=2,
121
- placeholder="the woman walks down the alley and checks the pocket watch, slow dolly-in")
122
- audio = gr.Textbox(label="Sound / speech (optional)", lines=1,
123
- placeholder="footsteps on cobblestone, a soft voice saying 'almost time', distant city hum")
124
  with gr.Accordion("Settings", open=False):
125
  lora_scale = gr.Slider(0.8, 1.8, value=1.4, step=0.05, label="LoRA strength")
126
  randomize = gr.Checkbox(True, label="Randomize seed")
@@ -130,28 +125,25 @@ with gr.Blocks(title="LTX-2.3 Reference Sheet (Fast / Distilled)") as demo:
130
  video_out = gr.Video(label="Generated video")
131
  used_seed = gr.Number(label="Seed used", interactive=False)
132
 
133
- run.click(generate, inputs=[image_in, sheet, action, audio, lora_scale, seed, randomize],
134
  outputs=[video_out, used_seed])
135
 
136
  gr.Examples(
137
  examples=[
138
  ["examples/sheet_camping.jpg",
139
  "a young child in a yellow raincoat beside a golden retriever dog (large left panel); a cluster of small orange camping tents in a green field (top right); misty green mountains over a calm lake (bottom right)",
140
- "the child and the golden retriever walk together across the grassy field toward the tents at dawn, gentle handheld camera, soft morning light",
141
- "happy dog panting and a soft bark, a child giggling, birdsong and a gentle breeze",
142
  1.4, 42, False],
143
  ["examples/sheet_astronaut.jpg",
144
  "an astronaut in a white spacesuit holding the helmet under one arm (large left panel); a vast misty mountain landscape over still water (right panel)",
145
- "the astronaut walks slowly across the misty shoreline, looking around in wonder, slow cinematic dolly-in",
146
- "crunching footsteps on wet gravel, low wind, soft breathing and a whispered 'incredible'",
147
  1.4, 42, False],
148
  ["examples/sheet_woman_horse.jpg",
149
  "a smiling young woman with curly dark hair in a light top (large left panel); a dappled grey horse standing on grass (top right); a green misty mountain meadow (bottom right)",
150
- "the woman walks up to the grey horse in the meadow and gently strokes its neck, smiling, soft daylight",
151
- "a woman's warm voice saying 'hey there, good boy', a soft horse nicker, light wind and birdsong",
152
  1.4, 42, False],
153
  ],
154
- inputs=[image_in, sheet, action, audio, lora_scale, seed, randomize],
155
  outputs=[video_out, used_seed], fn=generate, cache_examples=True, cache_mode="lazy",
156
  )
157
 
 
44
 
45
 
46
  # --- Helpers ----------------------------------------------------------------
47
+ def _build_prompt(sheet, action):
48
+ return f"Reference sheet: {sheet.strip()}\n\nGenerated video: {action.strip()}"
 
 
 
49
 
50
 
51
  def _export(video_np, audio, path):
 
61
 
62
  # --- Inference --------------------------------------------------------------
63
  @spaces.GPU(duration=_duration)
64
+ def generate(image, sheet, action, lora_scale, seed, randomize,
65
  progress=gr.Progress(track_tqdm=True)):
66
  if image is None:
67
  raise gr.Error("Please upload a reference sheet image.")
 
77
  sheet_img = image.convert("RGB").resize((WIDTH, HEIGHT), Image.LANCZOS)
78
  ref = [sheet_img] * NUM_FRAMES
79
  pipe.set_adapters("refsheet", float(lora_scale))
80
+ prompt = _build_prompt(sheet, action)
81
 
82
  def _cb(p, i, t, kw):
83
  progress((i + 1) / NUM_STEPS, desc=f"Generating — step {i + 1}/{NUM_STEPS}")
 
114
  image_in = gr.Image(type="pil", label="Reference sheet (one clean panel per element, black background)")
115
  sheet = gr.Textbox(label="Reference sheet description", lines=3,
116
  placeholder="a young woman with red hair in a green jacket (face close-up + turnaround); a brass pocket watch; a cobblestone alley at night")
117
+ action = gr.Textbox(label="Generated video the action / shot, plus any speech & sounds", lines=3,
118
+ placeholder="the woman walks down the alley and checks the pocket watch, slow dolly-in; footsteps on cobblestone, a soft voice saying 'almost time', distant city hum")
 
 
119
  with gr.Accordion("Settings", open=False):
120
  lora_scale = gr.Slider(0.8, 1.8, value=1.4, step=0.05, label="LoRA strength")
121
  randomize = gr.Checkbox(True, label="Randomize seed")
 
125
  video_out = gr.Video(label="Generated video")
126
  used_seed = gr.Number(label="Seed used", interactive=False)
127
 
128
+ run.click(generate, inputs=[image_in, sheet, action, lora_scale, seed, randomize],
129
  outputs=[video_out, used_seed])
130
 
131
  gr.Examples(
132
  examples=[
133
  ["examples/sheet_camping.jpg",
134
  "a young child in a yellow raincoat beside a golden retriever dog (large left panel); a cluster of small orange camping tents in a green field (top right); misty green mountains over a calm lake (bottom right)",
135
+ "the child and the golden retriever walk together across the grassy field toward the tents at dawn, gentle handheld camera, soft morning light; happy dog panting and a soft bark, a child giggling, birdsong and a gentle breeze",
 
136
  1.4, 42, False],
137
  ["examples/sheet_astronaut.jpg",
138
  "an astronaut in a white spacesuit holding the helmet under one arm (large left panel); a vast misty mountain landscape over still water (right panel)",
139
+ "the astronaut walks slowly across the misty shoreline, looking around in wonder, slow cinematic dolly-in; crunching footsteps on wet gravel, low wind, soft breathing and a whispered 'incredible'",
 
140
  1.4, 42, False],
141
  ["examples/sheet_woman_horse.jpg",
142
  "a smiling young woman with curly dark hair in a light top (large left panel); a dappled grey horse standing on grass (top right); a green misty mountain meadow (bottom right)",
143
+ "the woman walks up to the grey horse in the meadow and gently strokes its neck, smiling, soft daylight; a woman's warm voice saying 'hey there, good boy', a soft horse nicker, light wind and birdsong",
 
144
  1.4, 42, False],
145
  ],
146
+ inputs=[image_in, sheet, action, lora_scale, seed, randomize],
147
  outputs=[video_out, used_seed], fn=generate, cache_examples=True, cache_mode="lazy",
148
  )
149