Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
f7d4d47
1
Parent(s):
e2530d1
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,12 +19,13 @@ pipe = StableVideoDiffusionPipeline.from_pretrained(
|
|
| 19 |
)
|
| 20 |
pipe.to("cuda")
|
| 21 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
|
|
|
| 22 |
|
| 23 |
max_64_bit_int = 2**63 - 1
|
| 24 |
|
| 25 |
def sample(
|
| 26 |
image: Image,
|
| 27 |
-
seed: Optional[int] =
|
| 28 |
randomize_seed: bool = True,
|
| 29 |
motion_bucket_id: int = 127,
|
| 30 |
fps_id: int = 6,
|
|
@@ -33,7 +34,6 @@ def sample(
|
|
| 33 |
decoding_t: int = 3, # Number of frames decoded at a time! This eats most VRAM. Reduce if necessary.
|
| 34 |
device: str = "cuda",
|
| 35 |
output_folder: str = "outputs",
|
| 36 |
-
#progress=gr.Progress(track_tqdm=True)
|
| 37 |
):
|
| 38 |
if image.mode == "RGBA":
|
| 39 |
image = image.convert("RGB")
|
|
@@ -85,7 +85,7 @@ def resize_image(image, output_size=(1024, 576)):
|
|
| 85 |
|
| 86 |
with gr.Blocks() as demo:
|
| 87 |
gr.Markdown('''# Community demo for Stable Video Diffusion - Img2Vid - XT ([model](https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt), [paper](https://stability.ai/research/stable-video-diffusion-scaling-latent-video-diffusion-models-to-large-datasets))
|
| 88 |
-
#### Research release ([_non-commercial_](https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt/blob/main/LICENSE)): generate `4s` vid from a single image at (`25 frames` at `6 fps`).
|
| 89 |
''')
|
| 90 |
with gr.Row():
|
| 91 |
with gr.Column():
|
|
@@ -100,7 +100,25 @@ with gr.Blocks() as demo:
|
|
| 100 |
|
| 101 |
image.upload(fn=resize_image, inputs=image, outputs=image, queue=False)
|
| 102 |
generate_btn.click(fn=sample, inputs=[image, seed, randomize_seed, motion_bucket_id, fps_id], outputs=[video, seed], api_name="video")
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
if __name__ == "__main__":
|
| 105 |
demo.queue(max_size=20)
|
| 106 |
demo.launch(share=True)
|
|
|
|
| 19 |
)
|
| 20 |
pipe.to("cuda")
|
| 21 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
| 22 |
+
pipe.vae = torch.compile(pipe.vae, mode="reduce-overhead", fullgraph=True)
|
| 23 |
|
| 24 |
max_64_bit_int = 2**63 - 1
|
| 25 |
|
| 26 |
def sample(
|
| 27 |
image: Image,
|
| 28 |
+
seed: Optional[int] = 42,
|
| 29 |
randomize_seed: bool = True,
|
| 30 |
motion_bucket_id: int = 127,
|
| 31 |
fps_id: int = 6,
|
|
|
|
| 34 |
decoding_t: int = 3, # Number of frames decoded at a time! This eats most VRAM. Reduce if necessary.
|
| 35 |
device: str = "cuda",
|
| 36 |
output_folder: str = "outputs",
|
|
|
|
| 37 |
):
|
| 38 |
if image.mode == "RGBA":
|
| 39 |
image = image.convert("RGB")
|
|
|
|
| 85 |
|
| 86 |
with gr.Blocks() as demo:
|
| 87 |
gr.Markdown('''# Community demo for Stable Video Diffusion - Img2Vid - XT ([model](https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt), [paper](https://stability.ai/research/stable-video-diffusion-scaling-latent-video-diffusion-models-to-large-datasets))
|
| 88 |
+
#### Research release ([_non-commercial_](https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt/blob/main/LICENSE)): generate `4s` vid from a single image at (`25 frames` at `6 fps`). Generation takes ~60s in an A100. [Join the waitlist for Stability's upcoming web experience](https://stability.ai/contact).
|
| 89 |
''')
|
| 90 |
with gr.Row():
|
| 91 |
with gr.Column():
|
|
|
|
| 100 |
|
| 101 |
image.upload(fn=resize_image, inputs=image, outputs=image, queue=False)
|
| 102 |
generate_btn.click(fn=sample, inputs=[image, seed, randomize_seed, motion_bucket_id, fps_id], outputs=[video, seed], api_name="video")
|
| 103 |
+
gr.Examples(
|
| 104 |
+
examples=[
|
| 105 |
+
"images/blink_meme.png",
|
| 106 |
+
"images/confused2_meme.png",
|
| 107 |
+
"images/confused_meme.png",
|
| 108 |
+
"images/disaster_meme.png",
|
| 109 |
+
"images/distracted_meme.png",
|
| 110 |
+
"images/hide_meme.png",
|
| 111 |
+
"images/nazare_meme.png",
|
| 112 |
+
"images/success_meme.png",
|
| 113 |
+
"images/willy_meme.png",
|
| 114 |
+
"images/wink_meme.png"
|
| 115 |
+
],
|
| 116 |
+
inputs=image,
|
| 117 |
+
outputs=[video, seed],
|
| 118 |
+
fn=sample,
|
| 119 |
+
cache_examples=True,
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
if __name__ == "__main__":
|
| 123 |
demo.queue(max_size=20)
|
| 124 |
demo.launch(share=True)
|