Update app.py
#2
by
salomonsky
- opened
app.py
CHANGED
|
@@ -5,20 +5,8 @@ from diffusers.utils import load_image
|
|
| 5 |
import spaces
|
| 6 |
from panna.pipeline import PipelineSVDUpscale
|
| 7 |
|
| 8 |
-
|
| 9 |
model = PipelineSVDUpscale(upscaler="instruct_ir")
|
| 10 |
-
example_files = []
|
| 11 |
-
root_url = "https://huggingface.co/spaces/multimodalart/stable-video-diffusion/resolve/main/images"
|
| 12 |
-
examples = ["disaster_meme.png", "distracted_meme.png", "hide_meme.png", "success_meme.png", "willy_meme.png", "wink_meme.png"]
|
| 13 |
-
for example in examples:
|
| 14 |
-
load_image(f"{root_url}/{example}").save(example)
|
| 15 |
-
tmp_output_dir = "outputs"
|
| 16 |
-
os.makedirs(tmp_output_dir, exist_ok=True)
|
| 17 |
-
title = ("# [Stable Video Diffusion](ttps://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt) with [InstructIR as Upscaler](https://huggingface.co/spaces/marcosv/InstructIR)\n"
|
| 18 |
-
"The demo is part of [panna](https://github.com/asahi417/panna) project.")
|
| 19 |
-
|
| 20 |
|
| 21 |
-
@spaces.GPU(duration=120)
|
| 22 |
def infer(init_image, upscaler_prompt, num_frames, motion_bucket_id, noise_aug_strength, decode_chunk_size, fps, seed):
|
| 23 |
base_count = len(glob(os.path.join(tmp_output_dir, "*.mp4")))
|
| 24 |
video_path = os.path.join(tmp_output_dir, f"{base_count:06d}.mp4")
|
|
@@ -35,7 +23,6 @@ def infer(init_image, upscaler_prompt, num_frames, motion_bucket_id, noise_aug_s
|
|
| 35 |
)
|
| 36 |
return video_path
|
| 37 |
|
| 38 |
-
|
| 39 |
with gr.Blocks() as demo:
|
| 40 |
gr.Markdown(title)
|
| 41 |
with gr.Row():
|
|
@@ -56,5 +43,5 @@ with gr.Blocks() as demo:
|
|
| 56 |
inputs=[image, upscaler_prompt, num_frames, motion_bucket_id, noise_aug_strength, decode_chunk_size, fps, seed],
|
| 57 |
outputs=[video]
|
| 58 |
)
|
| 59 |
-
gr.Examples(
|
| 60 |
-
demo.launch(
|
|
|
|
| 5 |
import spaces
|
| 6 |
from panna.pipeline import PipelineSVDUpscale
|
| 7 |
|
|
|
|
| 8 |
model = PipelineSVDUpscale(upscaler="instruct_ir")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
| 10 |
def infer(init_image, upscaler_prompt, num_frames, motion_bucket_id, noise_aug_strength, decode_chunk_size, fps, seed):
|
| 11 |
base_count = len(glob(os.path.join(tmp_output_dir, "*.mp4")))
|
| 12 |
video_path = os.path.join(tmp_output_dir, f"{base_count:06d}.mp4")
|
|
|
|
| 23 |
)
|
| 24 |
return video_path
|
| 25 |
|
|
|
|
| 26 |
with gr.Blocks() as demo:
|
| 27 |
gr.Markdown(title)
|
| 28 |
with gr.Row():
|
|
|
|
| 43 |
inputs=[image, upscaler_prompt, num_frames, motion_bucket_id, noise_aug_strength, decode_chunk_size, fps, seed],
|
| 44 |
outputs=[video]
|
| 45 |
)
|
| 46 |
+
gr.Examples(inputs=image)
|
| 47 |
+
demo.launch()
|