Spaces:
Sleeping
Sleeping
| import os | |
| import gradio as gr | |
| from config import DEFAULT_REGION, FIXED_WIDTH, FIXED_HEIGHT, FIXED_FPS, FIXED_DURATION | |
| from handlers.video_generation_type import generate_single_shot, refresh_listing | |
| with gr.Blocks(title="Nova Reel β Text β Video (Single-shot)") as demo: | |
| gr.Markdown( | |
| f"# π¬DEval Nova Reel 1:0 β Text/Image β Video\n" | |
| f"**Single-shot only.** Fixed **{FIXED_WIDTH}Γ{FIXED_HEIGHT} @ {FIXED_FPS} fps**, duration **{FIXED_DURATION}s**.\n" | |
| "Starts an async job, polls until completion, then downloads `output.mp4` from your S3 path." | |
| ) | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| prompt = gr.Textbox( | |
| label="Prompt", | |
| placeholder="Closeup of a cute old steampunk robot riding a horse. Camera zoom in.", | |
| lines=4, | |
| ) | |
| reference_image = gr.Image( | |
| label="Optional reference image (PNG/JPEG, ideally 1280Γ720)", | |
| type="filepath", | |
| ) | |
| with gr.Column(scale=1): | |
| s3_uri = gr.Textbox( | |
| label="S3 output base URI", | |
| value="s3://bucketvideogenerationwest", | |
| placeholder="s3://your-bucket[/optional/prefix]", | |
| ) | |
| region = gr.Textbox(label="AWS Region", value=DEFAULT_REGION) | |
| seed = gr.Textbox(label="Seed (optional)", value="", placeholder="leave blank for random") | |
| custom_name = gr.Textbox( | |
| label="Video name (optional)", | |
| placeholder="Defaults to part of the prompt", | |
| value="" | |
| ) | |
| go = gr.Button("π Generate") | |
| with gr.Row(): | |
| vid = gr.Video(label="Generated Video") | |
| status = gr.Markdown("", elem_id="status") | |
| gr.Markdown("### πΌ Videos already in this bucket/prefix") | |
| table = gr.Dataframe( | |
| headers=["Key", "Size (MB)", "Last Modified (UTC)", "S3 URI"], | |
| interactive=False, | |
| wrap=False, | |
| label="Existing .mp4 objects" | |
| ) | |
| refresh_btn = gr.Button("π Refresh list") | |
| go.click( | |
| fn=generate_single_shot, | |
| inputs=[prompt, s3_uri, seed, region, reference_image, custom_name], | |
| outputs=[vid, status, table], | |
| api_name="generate" | |
| ) | |
| refresh_btn.click( | |
| fn=refresh_listing, | |
| inputs=[s3_uri, region], | |
| outputs=[table] | |
| ) | |
| s3_uri.change( | |
| fn=refresh_listing, | |
| inputs=[s3_uri, region], | |
| outputs=[table] | |
| ) | |
| if __name__ == "__main__": | |
| auth_user = os.getenv("USER") | |
| auth_pass = os.getenv("PASS") | |
| demo.queue().launch( | |
| auth=(auth_user, auth_pass), share=True, ssr_mode=False | |
| ) |