image-pluser-webui/tabs/Images to video/app.py

46 lines
1.3 KiB
Python
Raw Normal View History

2023-04-16 08:51:33 +03:00
import gradio as gr
from processing.bulk import images_to_video
with gr.Blocks() as app:
2023-04-16 09:55:33 +03:00
gr.Markdown("Convert images to video.")
directory = gr.Text(
2023-04-16 18:40:08 +03:00
placeholder="A directory with many images of the same size", label="Directory"
)
2023-04-16 08:51:33 +03:00
2023-04-16 09:55:33 +03:00
fps = gr.Number(label="FPS", value=30, min=0)
with gr.Accordion("Advanced settings", open=False) as acc:
video_name = gr.Text(
2023-04-16 18:40:08 +03:00
label="Video name",
placeholder="Video name e.g. video. If not specified will be generated by time",
)
video_ext = gr.Dropdown(label="Video extension", choices=["mp4"], value="mp4")
2023-04-16 09:55:33 +03:00
video_dir = gr.Text(
2023-04-16 18:40:08 +03:00
label="Video directory",
placeholder="The directory where the video will be saved. If not specified `./output/videos`",
)
2023-04-16 09:55:33 +03:00
2023-04-16 18:40:08 +03:00
img_ext = gr.Dropdown(
label="Image extension", choices=["png", "jpg"], value="png"
)
2023-04-16 09:55:33 +03:00
img_name_format = gr.Text(
2023-04-16 18:40:08 +03:00
label="Image name format",
placeholder="ffmpeg pattern e.g. %04d is (0000.png)",
value="%d",
)
2023-04-16 09:55:33 +03:00
submit = gr.Button("Submit")
2023-04-16 08:51:33 +03:00
submit.click(
fn=images_to_video,
2023-04-16 18:40:08 +03:00
inputs=[
directory,
fps,
img_ext,
img_name_format,
video_name,
video_ext,
video_dir,
],
2023-04-16 08:51:33 +03:00
)