Commit
·
45f3f73
1
Parent(s):
6126b73
Update app.py
Browse files
app.py
CHANGED
@@ -29,11 +29,11 @@ pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
|
29 |
max_64_bit_int = 2**63 - 1
|
30 |
|
31 |
def generate_video(
|
|
|
32 |
image: Image,
|
33 |
seed: int,
|
34 |
motion_bucket_id: int = 127,
|
35 |
fps_id: int = 6,
|
36 |
-
secret_token: str = "",
|
37 |
version: str = "svd_xt",
|
38 |
cond_aug: float = 0.02,
|
39 |
decoding_t: int = 3, # Number of frames decoded at a time! This eats most VRAM. Reduce if necessary.
|
@@ -103,35 +103,31 @@ def resize_image(image, output_size=(1024, 576)):
|
|
103 |
return cropped_image
|
104 |
|
105 |
with gr.Blocks() as demo:
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
seed = gr.Slider(label="Seed", value=42, randomize=False, minimum=0, maximum=max_64_bit_int, step=1)
|
126 |
-
motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
|
127 |
-
fps_id = gr.Slider(label="Frames per second", info="The length of your video in seconds will be 25/fps", value=6, minimum=5, maximum=30)
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
demo.queue(max_size=20).launch()
|
|
|
29 |
max_64_bit_int = 2**63 - 1
|
30 |
|
31 |
def generate_video(
|
32 |
+
secret_token: str,
|
33 |
image: Image,
|
34 |
seed: int,
|
35 |
motion_bucket_id: int = 127,
|
36 |
fps_id: int = 6,
|
|
|
37 |
version: str = "svd_xt",
|
38 |
cond_aug: float = 0.02,
|
39 |
decoding_t: int = 3, # Number of frames decoded at a time! This eats most VRAM. Reduce if necessary.
|
|
|
103 |
return cropped_image
|
104 |
|
105 |
with gr.Blocks() as demo:
|
106 |
+
secret_token = gr.Text(
|
107 |
+
label='Secret Token',
|
108 |
+
max_lines=1,
|
109 |
+
placeholder='Enter your secret token',
|
110 |
+
)
|
111 |
+
gr.HTML("""
|
112 |
+
<div style="z-index: 100; position: fixed; top: 0px; right: 0px; left: 0px; bottom: 0px; width: 100%; height: 100%; background: white; display: flex; align-items: center; justify-content: center; color: black;">
|
113 |
+
<div style="text-align: center; color: black;">
|
114 |
+
<p style="color: black;">This space is a REST API to programmatically generate MP4 videos.</p>
|
115 |
+
<p style="color: black;">Interested in using it? Look no further than the <a href="https://huggingface.co/spaces/multimodalart/stable-video-diffusion" target="_blank">original space</a>!</p>
|
116 |
+
</div>
|
117 |
+
</div>"""
|
118 |
+
)
|
119 |
+
image = gr.Image(label="Upload your image", type="pil")
|
120 |
+
generate_btn = gr.Button("Generate")
|
121 |
+
base64_out = gr.Textbox(label="Base64 Video")
|
122 |
+
seed = gr.Slider(label="Seed", value=42, randomize=False, minimum=0, maximum=max_64_bit_int, step=1)
|
123 |
+
motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
|
124 |
+
fps_id = gr.Slider(label="Frames per second", info="The length of your video in seconds will be 25/fps", value=6, minimum=5, maximum=30)
|
|
|
|
|
|
|
125 |
|
126 |
+
generate_btn.click(
|
127 |
+
fn=generate_video,
|
128 |
+
inputs=[secret_token, image, seed, motion_bucket_id, fps_id],
|
129 |
+
outputs=base64_out,
|
130 |
+
api_name="run"
|
131 |
+
)
|
132 |
+
|
133 |
+
demo.queue(max_size=20).launch()
|
|