import gradio as gr from generate import generate def infer(prompt, steps, guidance, frames): gif_path = generate(prompt, num_frames=frames, steps=steps, guidance=guidance) return gif_path with gr.Blocks() as demo: gr.Markdown("# 🌀 AnimateDiff Generator\nEnter a text prompt and get an animated GIF.") with gr.Row(): with gr.Column(): prompt = gr.Textbox(label="Prompt", placeholder="Describe your animation...") steps = gr.Slider(10, 100, value=25, step=1, label="Inference Steps") guidance = gr.Slider(1, 15, value=7.5, step=0.5, label="Guidance Scale") frames = gr.Slider(8, 32, value=16, step=1, label="Number of Frames") btn = gr.Button("Generate") with gr.Column(): output = gr.Video(label="Generated Animation") btn.click(fn=infer, inputs=[prompt, steps, guidance, frames], outputs=output) if __name__ == "__main__": demo.launch()