-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
48 lines (38 loc) · 1.51 KB
/
app.py
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
39
40
41
42
43
44
45
46
47
48
import gradio
import torch
from deps.AnimateDiff.animatediff.utils.util import save_videos_grid
from minimal_animatediff.animation_pipeline import create_animation_pipeline
if __name__ == "__main__":
pipeline = create_animation_pipeline()
def generate(prompt, neg_prompt, steps, width, height, frames, progress=gradio.Progress()):
torch.manual_seed(16372571278361863751)
def update(i, _, __):
progress(i / float(steps + 1), desc="Sampling")
progress(0, desc="Sampling")
sample = pipeline(
prompt,
negative_prompt=neg_prompt,
num_inference_steps=int(steps),
guidance_scale=7.5,
width=int(width),
height=int(height),
video_length=int(frames),
callback=update,
).videos
progress(steps / float(steps + 1), desc="Converting")
save_videos_grid(sample, "samples/sample.mp4")
progress(1)
return "samples/sample.mp4"
app = gradio.Interface(
fn=generate,
inputs=[
gradio.Textbox(label="Prompt"),
gradio.Textbox(label="Negative Prompt"),
gradio.Number(label="Steps", value=25, minimum=1),
gradio.Number(label="Width", value=512, minimum=1),
gradio.Number(label="Height", value=512, minimum=1),
gradio.Number(label="Frames", value=16, minimum=1),
],
outputs=gradio.Video(label="Generated Animation"),
)
app.launch(share=True, enable_queue=True)