|
import gradio as gr |
|
|
|
from modelscope.pipelines import pipeline |
|
from modelscope.outputs import OutputKeys |
|
|
|
pipe = pipeline(task='image-to-video', model='damo/Image-to-Video', model_revision='v1.1.0') |
|
|
|
def infer (image_in): |
|
|
|
|
|
IMG_PATH = image_in |
|
output_video_path = pipe(IMG_PATH, output_video='output.mp4')[OutputKeys.OUTPUT_VIDEO] |
|
print(output_video_path) |
|
|
|
return output_video_path |
|
|
|
|
|
with gr.Blocks() as demo: |
|
with gr.Column(elem_id="col-container"): |
|
gr.Markdown(""" |
|
<p> |
|
You are currently viewing a micro-service API meant to be used by robots.<br/> |
|
For the human UI, please check out the <a href="https://huggingface.co/spaces/fffiloni/MS-Image2Video">original Space by Sylvain Filoni</a>. |
|
</p> |
|
|
|
""") |
|
|
|
image_in = gr.Image( |
|
label = "Source Image", |
|
source = "upload", |
|
type = "filepath", |
|
elem_id = "image-in" |
|
) |
|
with gr.Row(): |
|
|
|
submit_btn = gr.Button( |
|
"Submit" |
|
) |
|
|
|
video_out = gr.Video( |
|
label = "Video Result", |
|
elem_id = "video-out" |
|
) |
|
|
|
with gr.Row(): |
|
|
|
|
|
|
|
submit_btn.click( |
|
fn = infer, |
|
inputs = [ |
|
image_in |
|
], |
|
outputs = [ |
|
video_out, |
|
] |
|
) |
|
|
|
demo.queue(max_size=6).launch() |