Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,34 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import imageio
|
| 5 |
|
| 6 |
+
# ์ ์ฅ ๊ฒฝ๋ก
|
| 7 |
+
UPLOAD_DIR = "uploads"
|
| 8 |
+
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
| 9 |
|
| 10 |
+
def save_images(image1, image2):
|
| 11 |
+
path1 = os.path.join(UPLOAD_DIR, "cut1.png")
|
| 12 |
+
path2 = os.path.join(UPLOAD_DIR, "cut2.png")
|
| 13 |
+
|
| 14 |
+
image1.save(path1)
|
| 15 |
+
image2.save(path2)
|
| 16 |
+
|
| 17 |
+
# ์ฌ๊ธฐ์๋ ์์๋ก ๋ ์ด๋ฏธ์ง ๊ทธ๋๋ก ์ด์ด๋ถ์ธ gif๋ฅผ ๋ฆฌํด
|
| 18 |
+
gif_path = os.path.join(UPLOAD_DIR, "output.gif")
|
| 19 |
+
imageio.mimsave(gif_path, [image1, image2], fps=1)
|
| 20 |
+
|
| 21 |
+
return gif_path
|
| 22 |
+
|
| 23 |
+
iface = gr.Interface(
|
| 24 |
+
fn=save_images,
|
| 25 |
+
inputs=[
|
| 26 |
+
gr.Image(label="์ปท1 ์
๋ก๋", type="pil"),
|
| 27 |
+
gr.Image(label="์ปท2 ์
๋ก๋", type="pil")
|
| 28 |
+
],
|
| 29 |
+
outputs=gr.Video(label="๊ฒฐ๊ณผ ์ ๋๋ฉ์ด์
"),
|
| 30 |
+
title="๐ ์ปท ๊ธฐ๋ฐ ์ ๋๋ฉ์ด์
์์ฑ๊ธฐ (์์)",
|
| 31 |
+
description="๋ ์ฅ์ ์ปท์ ์
๋ก๋ํ๋ฉด, ์ ๋๋ฉ์ด์
์ผ๋ก ์ด์ด์ฃผ๋ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ์ค๋๋ค."
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
iface.launch()
|