File size: 1,356 Bytes
926a21c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr
import requests

NGROK_URL = "https://f719-34-74-140-255.ngrok-free.app"  # Update this with your actual ngrok URL

def generate_and_save(prompt, negative_prompt, num_frames, guidance_scale, num_inference_steps, seed):
    data = {
        'prompt': prompt,
        'negative_prompt': negative_prompt,
        'num_frames': num_frames,
        'guidance_scale': guidance_scale,
        'num_inference_steps': num_inference_steps,
        'seed': seed
    }
    response = requests.post(f'{NGROK_URL}/generate', json=data)
    with open('output.gif', 'wb') as f:
        f.write(response.content)
    return 'output.gif'

interface = gr.Interface(
    fn=generate_and_save,
    inputs=[
        gr.Textbox(label="Prompt"),
        gr.Textbox(label="Negative Prompt"),
        gr.Slider(minimum=8, maximum=32, step=1, label="Number of Frames", value=16),
        gr.Slider(minimum=1, maximum=10, step=0.1, label="Guidance Scale", value=2.0),
        gr.Slider(minimum=1, maximum=50, step=1, label="Inference Steps", value=6),
        gr.Number(label="Seed", value=0),
    ],
    outputs=gr.Image(type="filepath", label="Generated Animation"),
    title="Text-to-Video Generation with AnimateLCM",
    description="Generate short animations from text prompts using AnimateLCM model.",
)

if __name__ == "__main__":
    interface.launch()