COLIPICAIv2gen / app.py
wenmeng.zwm
update space to support I2VGEN-XL https://modelscope.cn/studios/damo/I2VGen-XL/summary
60931f6
raw
history blame
2.68 kB
import os
import gradio as gr
from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys
image_to_video_pipe = pipeline(task="image-to-video", model='damo/i2vgen-xl', revision='v1.1.3', device='cuda:0')
def upload_file(file):
return file.name
def image_to_video(image_in, text_in):
if image_in is None:
raise gr.Error('่ฏทไธŠไผ ๅ›พ็‰‡ๆˆ–็ญ‰ๅพ…ๅ›พ็‰‡ไธŠไผ ๅฎŒๆˆ')
print(image_in)
output_video_path = image_to_video_pipe(image_in, caption=text_in)[OutputKeys.OUTPUT_VIDEO]
print(output_video_path)
return output_video_path
with gr.Blocks() as demo:
gr.Markdown(
"""<center><font size=7>I2VGen-XL</center>
<left><font size=3>I2VGen-XLๅฏไปฅๆ นๆฎ็”จๆˆท่พ“ๅ…ฅ็š„้™ๆ€ๅ›พๅƒๅ’Œๆ–‡ๆœฌ็”Ÿๆˆ็›ฎๆ ‡ๆŽฅ่ฟ‘ใ€่ฏญไน‰็›ธๅŒ็š„่ง†้ข‘๏ผŒ็”Ÿๆˆ็š„่ง†้ข‘ๅ…ท้ซ˜ๆธ…(1280 * 720)ใ€ๅฎฝๅฑ(16:9)ใ€ๆ—ถๅบ่ฟž่ดฏใ€่ดจๆ„Ÿๅฅฝ็ญ‰็‰น็‚นใ€‚</left>
<left><font size=3>I2VGen-XL can generate videos with similar contents and semantics based on user input static images and text. The generated videos have characteristics such as high-definition (1280 * 720), widescreen (16:9), coherent timing, and good texture.</left>
"""
)
with gr.Box():
gr.Markdown(
"""<left><font size=3>้€‰ๆ‹ฉๅˆ้€‚็š„ๅ›พ็‰‡่ฟ›่กŒไธŠไผ ๏ผŒๅนถ่กฅๅ……ๅฏน่ง†้ข‘ๅ†…ๅฎน็š„่‹ฑๆ–‡ๆ–‡ๆœฌๆ่ฟฐ๏ผŒ็„ถๅŽ็‚นๅ‡ปโ€œ็”Ÿๆˆ่ง†้ข‘โ€ใ€‚</left>
<left><font size=3>Please choose the image to upload (we recommend the image size be 1280 * 720), provide the English text description of the video you wish to create, and then click on "Generate Video" to receive the generated video.</left>"""
)
with gr.Row():
with gr.Column():
text_in = gr.Textbox(label="ๆ–‡ๆœฌๆ่ฟฐ", lines=2, elem_id="text-in")
image_in = gr.Image(label="ๅ›พ็‰‡่พ“ๅ…ฅ", type="filepath", interactive=False, elem_id="image-in", height=300)
with gr.Row():
upload_image = gr.UploadButton("ไธŠไผ ๅ›พ็‰‡", file_types=["image"], file_count="single")
image_submit = gr.Button("็”Ÿๆˆ่ง†้ข‘๐ŸŽฌ")
with gr.Column():
video_out_1 = gr.Video(label='็”Ÿๆˆ็š„่ง†้ข‘', elem_id='video-out_1', interactive=False, height=300)
gr.Markdown("<left><font size=2>ๆณจ๏ผšๅฆ‚ๆžœ็”Ÿๆˆ็š„่ง†้ข‘ๆ— ๆณ•ๆ’ญๆ”พ๏ผŒ่ฏทๅฐ่ฏ•ๅ‡็บงๆต่งˆๅ™จๆˆ–ไฝฟ็”จchromeๆต่งˆๅ™จใ€‚</left>")
upload_image.upload(upload_file, upload_image, image_in, queue=False)
image_submit.click(fn=image_to_video, inputs=[image_in, text_in], outputs=[video_out_1])
demo.queue(status_update_rate=1, api_open=False).launch(share=False, show_error=True)