Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
-
from diffusers import
|
4 |
-
from diffusers.schedulers import DPMSolverMultistepScheduler
|
5 |
from diffusers.utils import export_to_gif, load_image
|
6 |
|
7 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -11,8 +10,8 @@ def generate_video(prompt, negative_prompt, num_inference_steps, conditioning_fr
|
|
11 |
controlnet = SparseControlNetModel.from_pretrained("guoyww/animatediff-sparsectrl-scribble", torch_dtype=torch.float16).to(device)
|
12 |
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtype=torch.float16).to(device)
|
13 |
|
14 |
-
pipe =
|
15 |
-
"SG161222/
|
16 |
motion_adapter=motion_adapter,
|
17 |
controlnet=controlnet,
|
18 |
vae=vae,
|
@@ -59,10 +58,10 @@ def generate_simple_video(prompt):
|
|
59 |
|
60 |
frames = pipe(
|
61 |
prompt,
|
62 |
-
num_frames=
|
63 |
-
num_inference_steps=
|
64 |
-
guidance_scale=
|
65 |
-
decode_chunk_size=1,
|
66 |
).frames[0]
|
67 |
|
68 |
export_to_gif(frames, "simple_output.gif")
|
@@ -73,7 +72,7 @@ demo1 = gr.Interface(
|
|
73 |
inputs=[
|
74 |
gr.Textbox(label="Prompt", value="an aerial view of a cyberpunk city, night time, neon lights, masterpiece, high quality"),
|
75 |
gr.Textbox(label="Negative Prompt", value="low quality, worst quality, letterboxed"),
|
76 |
-
gr.Slider(label="Number of Inference Steps", minimum=1, maximum=
|
77 |
gr.Textbox(label="Conditioning Frame Indices", value="[0, 8, 15]"),
|
78 |
gr.Slider(label="ControlNet Conditioning Scale", minimum=0.1, maximum=2.0, step=0.1, value=1.0)
|
79 |
],
|
@@ -92,5 +91,6 @@ demo2 = gr.Interface(
|
|
92 |
|
93 |
demo = gr.TabbedInterface([demo1, demo2], ["Advanced Video Generation", "Simple Video Generation"])
|
94 |
|
|
|
95 |
demo.launch()
|
96 |
#demo.launch(server_name="0.0.0.0", server_port=7910)
|
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
+
from diffusers import AnimateDiffPipeline, MotionAdapter, DPMSolverMultistepScheduler, AutoencoderKL, EulerAncestralDiscreteScheduler
|
|
|
4 |
from diffusers.utils import export_to_gif, load_image
|
5 |
|
6 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
10 |
controlnet = SparseControlNetModel.from_pretrained("guoyww/animatediff-sparsectrl-scribble", torch_dtype=torch.float16).to(device)
|
11 |
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtype=torch.float16).to(device)
|
12 |
|
13 |
+
pipe = AnimateDiffPipeline.from_pretrained(
|
14 |
+
"SG161222/Realistic_Vision_V6.0_B1_noVAE",
|
15 |
motion_adapter=motion_adapter,
|
16 |
controlnet=controlnet,
|
17 |
vae=vae,
|
|
|
58 |
|
59 |
frames = pipe(
|
60 |
prompt,
|
61 |
+
num_frames=128, # Increased for smoother video
|
62 |
+
num_inference_steps=100, # Increased for higher quality
|
63 |
+
guidance_scale=15.0, # Increased for stronger guidance
|
64 |
+
decode_chunk_size=1,
|
65 |
).frames[0]
|
66 |
|
67 |
export_to_gif(frames, "simple_output.gif")
|
|
|
72 |
inputs=[
|
73 |
gr.Textbox(label="Prompt", value="an aerial view of a cyberpunk city, night time, neon lights, masterpiece, high quality"),
|
74 |
gr.Textbox(label="Negative Prompt", value="low quality, worst quality, letterboxed"),
|
75 |
+
gr.Slider(label="Number of Inference Steps", minimum=1, maximum=200, step=1, value=100), # Increased default value
|
76 |
gr.Textbox(label="Conditioning Frame Indices", value="[0, 8, 15]"),
|
77 |
gr.Slider(label="ControlNet Conditioning Scale", minimum=0.1, maximum=2.0, step=0.1, value=1.0)
|
78 |
],
|
|
|
91 |
|
92 |
demo = gr.TabbedInterface([demo1, demo2], ["Advanced Video Generation", "Simple Video Generation"])
|
93 |
|
94 |
+
|
95 |
demo.launch()
|
96 |
#demo.launch(server_name="0.0.0.0", server_port=7910)
|