Commit
•
092446c
1
Parent(s):
228ef90
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ dtype = torch.float16
|
|
29 |
pipe = AnimateDiffPipeline.from_pretrained(bases[base_loaded], torch_dtype=dtype).to(device)
|
30 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
31 |
|
32 |
-
def generate_image(secret_token, prompt, base, motion, step):
|
33 |
if secret_token != SECRET_TOKEN:
|
34 |
raise gr.Error(
|
35 |
f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
@@ -57,22 +57,14 @@ def generate_image(secret_token, prompt, base, motion, step):
|
|
57 |
pipe.set_adapters(["motion"], [0.7])
|
58 |
motion_loaded = motion
|
59 |
|
60 |
-
progress((0, step))
|
61 |
-
def progress_callback(i, t, z):
|
62 |
-
progress((i+1, step))
|
63 |
-
|
64 |
output = pipe(
|
65 |
prompt=prompt,
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
width=912, # 1024,
|
70 |
-
height=512, # 576,
|
71 |
|
72 |
guidance_scale=1.0,
|
73 |
num_inference_steps=step,
|
74 |
-
callback=progress_callback,
|
75 |
-
callback_steps=1
|
76 |
)
|
77 |
|
78 |
name = str(uuid.uuid4()).replace("-", "")
|
@@ -124,6 +116,20 @@ with gr.Blocks() as demo:
|
|
124 |
value=base_loaded,
|
125 |
interactive=True
|
126 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
select_motion = gr.Dropdown(
|
128 |
label='Motion',
|
129 |
choices=[
|
@@ -156,7 +162,7 @@ with gr.Blocks() as demo:
|
|
156 |
|
157 |
submit.click(
|
158 |
fn=generate_image,
|
159 |
-
inputs=[secret_token, prompt, select_base, select_motion, select_step],
|
160 |
outputs=output_video_base64,
|
161 |
)
|
162 |
|
|
|
29 |
pipe = AnimateDiffPipeline.from_pretrained(bases[base_loaded], torch_dtype=dtype).to(device)
|
30 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
31 |
|
32 |
+
def generate_image(secret_token, prompt, base, width, height, motion, step):
|
33 |
if secret_token != SECRET_TOKEN:
|
34 |
raise gr.Error(
|
35 |
f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
|
|
57 |
pipe.set_adapters(["motion"], [0.7])
|
58 |
motion_loaded = motion
|
59 |
|
|
|
|
|
|
|
|
|
60 |
output = pipe(
|
61 |
prompt=prompt,
|
62 |
|
63 |
+
width=width,
|
64 |
+
height=height,
|
|
|
|
|
65 |
|
66 |
guidance_scale=1.0,
|
67 |
num_inference_steps=step,
|
|
|
|
|
68 |
)
|
69 |
|
70 |
name = str(uuid.uuid4()).replace("-", "")
|
|
|
116 |
value=base_loaded,
|
117 |
interactive=True
|
118 |
)
|
119 |
+
width = gr.Slider(
|
120 |
+
label='Width',
|
121 |
+
minimum=128,
|
122 |
+
maximum=2048,
|
123 |
+
step=32,
|
124 |
+
value=1024,
|
125 |
+
)
|
126 |
+
height = gr.Slider(
|
127 |
+
label='Height',
|
128 |
+
minimum=128,
|
129 |
+
maximum=2048,
|
130 |
+
step=32,
|
131 |
+
value=1024,
|
132 |
+
)
|
133 |
select_motion = gr.Dropdown(
|
134 |
label='Motion',
|
135 |
choices=[
|
|
|
162 |
|
163 |
submit.click(
|
164 |
fn=generate_image,
|
165 |
+
inputs=[secret_token, prompt, select_base, width, height, select_motion, select_step],
|
166 |
outputs=output_video_base64,
|
167 |
)
|
168 |
|