Spaces:
Running
Running
| import gradio as gr | |
| import os | |
| from PIL import Image | |
| import imageio | |
| # ์ ์ฅ ๊ฒฝ๋ก | |
| UPLOAD_DIR = "uploads" | |
| os.makedirs(UPLOAD_DIR, exist_ok=True) | |
| def save_images(image1, image2): | |
| path1 = os.path.join(UPLOAD_DIR, "cut1.png") | |
| path2 = os.path.join(UPLOAD_DIR, "cut2.png") | |
| image1.save(path1) | |
| image2.save(path2) | |
| # ์ฌ๊ธฐ์๋ ์์๋ก ๋ ์ด๋ฏธ์ง ๊ทธ๋๋ก ์ด์ด๋ถ์ธ gif๋ฅผ ๋ฆฌํด | |
| gif_path = os.path.join(UPLOAD_DIR, "output.gif") | |
| imageio.mimsave(gif_path, [image1, image2], fps=1) | |
| return gif_path | |
| iface = gr.Interface( | |
| fn=save_images, | |
| inputs=[ | |
| gr.Image(label="์ปท1 ์ ๋ก๋", type="pil"), | |
| gr.Image(label="์ปท2 ์ ๋ก๋", type="pil") | |
| ], | |
| outputs=gr.Video(label="๊ฒฐ๊ณผ ์ ๋๋ฉ์ด์ "), | |
| title="๐ ์ปท ๊ธฐ๋ฐ ์ ๋๋ฉ์ด์ ์์ฑ๊ธฐ (์์)", | |
| description="๋ ์ฅ์ ์ปท์ ์ ๋ก๋ํ๋ฉด, ์ ๋๋ฉ์ด์ ์ผ๋ก ์ด์ด์ฃผ๋ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ์ค๋๋ค." | |
| ) | |
| iface.launch() | |