Spaces:
Sleeping
Sleeping
File size: 1,421 Bytes
145ad7d f78f277 ec5aa0b 69279bb c78b25e 69279bb 1c363e3 69279bb c9a21a0 69279bb 25abb2d 69279bb 145ad7d 89ea00c 69279bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import gradio as gr
import imageio
import numpy as np
from PIL import Image
def resize_image(image, target_width, target_height):
"""
์ด๋ฏธ์ง๋ฅผ ์ง์ ๋ ํฌ๊ธฐ๋ก ์กฐ์ ํฉ๋๋ค.
"""
image_pil = Image.fromarray(image).resize((target_width, target_height), Image.ANTIALIAS)
return np.array(image_pil)
def create_video(images):
"""
์ฃผ์ด์ง ์ด๋ฏธ์ง ๋ฆฌ์คํธ๋ก๋ถํฐ ๋น๋์ค๋ฅผ ์์ฑํฉ๋๋ค.
๋ชจ๋ ์ด๋ฏธ์ง๋ ๋น๋์ค์ ์ถ๊ฐ๋๊ธฐ ์ ์ ๋์ผํ ํฌ๊ธฐ๋ก ์กฐ์ ๋ฉ๋๋ค.
"""
target_width = 1920
target_height = 1080
with imageio.get_writer('output_video.mp4', fps=2) as video:
for img in images:
img_resized = resize_image(img, target_width, target_height)
video.append_data(img_resized)
return 'output_video.mp4'
def process_images(image_files):
"""
์
๋ก๋๋ ์ด๋ฏธ์ง ํ์ผ๋ค์ ์ฒ๋ฆฌํ์ฌ ๋น๋์ค๋ฅผ ์์ฑํฉ๋๋ค.
"""
images = [imageio.v3.imread(image_file) for image_file in image_files]
video_file = create_video(images)
return video_file
# Gradio ์ธํฐํ์ด์ค ์ ์
iface = gr.Interface(
fn=process_images,
inputs=gr.File(label="Upload Images", type="file", multiple_files=True), # ์์ ๋ ๋ถ๋ถ
outputs="file",
title="Image to Video Converter",
description="Upload multiple images to create a video."
)
# Gradio ์ฑ ์คํ
iface.launch() |