Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -146,7 +146,7 @@ pipeline.to(dtype=torch.float16).to(gpu)
|
|
146 |
# --- Frame Streaming Video Generation Handler ---
|
147 |
@torch.no_grad()
|
148 |
@spaces.GPU
|
149 |
-
def video_generation_handler(prompt, seed, fps):
|
150 |
"""
|
151 |
Generator function that yields RGB frames for display in gr.Image.
|
152 |
Includes timing delays for smooth playback.
|
@@ -332,17 +332,17 @@ with gr.Blocks(title="Self-Forcing Frame Streaming Demo") as demo:
|
|
332 |
label="Prompt",
|
333 |
placeholder="A stylish woman walks down a Tokyo street...",
|
334 |
lines=4,
|
335 |
-
value=""
|
336 |
)
|
337 |
gr.Examples(
|
338 |
examples=[
|
339 |
"A close-up shot of a ceramic teacup slowly pouring water into a glass mug. The water flows smoothly from the spout of the teacup into the mug, creating gentle ripples as it fills up. Both cups have detailed textures, with the teacup having a matte finish and the glass mug showcasing clear transparency. The background is a blurred kitchen countertop, adding context without distracting from the central action. The pouring motion is fluid and natural, emphasizing the interaction between the two cups.",
|
340 |
-
"A playful capybara is seen playing an electronic guitar, strumming the strings with its front paws. The raccoon has distinctive black facial markings and a bushy tail. It sits comfortably on a small stool, its body slightly tilted as it focuses intently on the instrument. The setting is a cozy, dimly lit room with vintage posters on the walls, adding a retro vibe. The raccoon's expressive eyes convey a sense of joy and concentration. Medium close-up shot, focusing on the raccoon's face and hands interacting with the guitar.
|
341 |
-
",
|
342 |
-
"A dynamic over-the-shoulder perspective of a chef meticulously plating a dish in a bustling kitchen. The chef, a middle-aged man with a neatly trimmed beard and focused expression, deftly arranges ingredients on a pristine white plate. His hands move with precision, each gesture deliberate and practiced. The background shows a crowded kitchen with steaming pots, whirring blenders, and the clatter of utensils. Bright lights highlight the scene, casting shadows across the busy workspace. The camera angle captures the chef's detailed work from behind, emphasizing his skill and dedication.
|
343 |
-
",
|
344 |
],
|
345 |
-
inputs=[prompt]
|
|
|
|
|
|
|
346 |
)
|
347 |
|
348 |
with gr.Row():
|
@@ -353,6 +353,7 @@ with gr.Blocks(title="Self-Forcing Frame Streaming Demo") as demo:
|
|
353 |
maximum=30,
|
354 |
value=args.fps,
|
355 |
step=1,
|
|
|
356 |
info="Frames per second for playback"
|
357 |
)
|
358 |
|
|
|
146 |
# --- Frame Streaming Video Generation Handler ---
|
147 |
@torch.no_grad()
|
148 |
@spaces.GPU
|
149 |
+
def video_generation_handler(prompt, seed=42, fps=15):
|
150 |
"""
|
151 |
Generator function that yields RGB frames for display in gr.Image.
|
152 |
Includes timing delays for smooth playback.
|
|
|
332 |
label="Prompt",
|
333 |
placeholder="A stylish woman walks down a Tokyo street...",
|
334 |
lines=4,
|
|
|
335 |
)
|
336 |
gr.Examples(
|
337 |
examples=[
|
338 |
"A close-up shot of a ceramic teacup slowly pouring water into a glass mug. The water flows smoothly from the spout of the teacup into the mug, creating gentle ripples as it fills up. Both cups have detailed textures, with the teacup having a matte finish and the glass mug showcasing clear transparency. The background is a blurred kitchen countertop, adding context without distracting from the central action. The pouring motion is fluid and natural, emphasizing the interaction between the two cups.",
|
339 |
+
"A playful capybara is seen playing an electronic guitar, strumming the strings with its front paws. The raccoon has distinctive black facial markings and a bushy tail. It sits comfortably on a small stool, its body slightly tilted as it focuses intently on the instrument. The setting is a cozy, dimly lit room with vintage posters on the walls, adding a retro vibe. The raccoon's expressive eyes convey a sense of joy and concentration. Medium close-up shot, focusing on the raccoon's face and hands interacting with the guitar.",
|
340 |
+
"A dynamic over-the-shoulder perspective of a chef meticulously plating a dish in a bustling kitchen. The chef, a middle-aged man with a neatly trimmed beard and focused expression, deftly arranges ingredients on a pristine white plate. His hands move with precision, each gesture deliberate and practiced. The background shows a crowded kitchen with steaming pots, whirring blenders, and the clatter of utensils. Bright lights highlight the scene, casting shadows across the busy workspace. The camera angle captures the chef's detailed work from behind, emphasizing his skill and dedication.",
|
|
|
|
|
341 |
],
|
342 |
+
inputs=[prompt],
|
343 |
+
fn=video_generation_handler,
|
344 |
+
outputs=[frame_display, final_video, status_html],
|
345 |
+
cache_examples="lazy"
|
346 |
)
|
347 |
|
348 |
with gr.Row():
|
|
|
353 |
maximum=30,
|
354 |
value=args.fps,
|
355 |
step=1,
|
356 |
+
visible=False,
|
357 |
info="Frames per second for playback"
|
358 |
)
|
359 |
|