Spaces:
Runtime error
Runtime error
Update app.py
Browse files100 unmodified lines10110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813931 unmodified lines171172173174175176177178179180181182183184185186187188189190191192100 unmodified linesexport_to_video(frames, output_path, fps=8)return output_path# Image-to-video generation function#@spaces.GPU(duration=240)#def generate_video_from_image(image, prompt, duration, video_guidance_scale):# temp = int(duration * 2.4) # Convert seconds to temp value (assuming 24 FPS)# torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32## target_size = (1280, 720)# cropped_image = center_crop(image, 1280, 720)# resized_image = cropped_image.resize((1280, 720))## with torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):# frames = model.generate_i2v(# prompt=prompt,# input_image=resized_image,# num_inference_steps=[10, 10, 10],# temp=temp,# guidance_scale=7.0,# video_guidance_scale=video_guidance_scale,# output_type="pil",# save_memory=True,# )output_path = "output_video_i2v.mp4"export_to_video(frames, output_path, fps=24)return output_path# Gradio interfacewith gr.Blocks() as demo:gr.Markdown("# Pyramid Flow")gr.Markdown("Pyramid Flow is a training-efficient Autoregressive Video Generation model based on Flow Matching. It is trained only on open-source datasets within 20.7k A100 GPU hours")gr.Markdown("[[Paper](https://arxiv.org/pdf/2410.05954)], [[Model](https://huggingface.co/rain1011/pyramid-flow-sd3)], [[Code](https://github.com/jy0205/Pyramid-Flow)]")#with gr.Tab("Text-to-Video"):with gr.Row():with gr.Column():with gr.Accordion("Image to Video (optional)", open=False):31 unmodified linesinputs=[t2v_prompt, i2v_image, t2v_duration, t2v_guidance_scale, t2v_video_guidance_scale],outputs=t2v_output)#with gr.Tab("Image-to-Video"):# with gr.Row():# with gr.Column():# i2v_prompt = gr.Textbox(label="Prompt")# i2v_duration = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Duration (seconds)")# i2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=4, step=0.1, label="Video Guidance Scale")# i2v_generate_btn = gr.Button("Generate Video")# with gr.Column():# i2v_output = gr.Video(label="Generated Video")#i2v_generate_btn.click(# generate_video_from_image,# inputs=[i2v_image, i2v_prompt, i2v_duration, i2v_video_guidance_scale],# outputs=i2v_output#)demo.launch()100 unmodified lines10110210310410510610710810911011111231 unmodified lines144145146147148100 unmodified linesexport_to_video(frames, output_path, fps=8)return output_path# Gradio interfacewith gr.Blocks() as demo:gr.Markdown("# Pyramid Flow")gr.Markdown("Pyramid Flow is a training-efficient Autoregressive Video Generation model based on Flow Matching. It is trained only on open-source datasets within 20.7k A100 GPU hours")gr.Markdown("[[Paper](https://arxiv.org/pdf/2410.05954)], [[Model](https://huggingface.co/rain1011/pyramid-flow-sd3)], [[Code](https://github.com/jy0205/Pyramid-Flow)]")with gr.Row():with gr.Column():with gr.Accordion("Image to Video (optional)", open=False):31 unmodified linesinputs=[t2v_prompt, i2v_image, t2v_duration, t2v_guidance_scale, t2v_video_guidance_scale],outputs=t2v_output)demo.launch()
app.py-44