Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image, ImageEnhance, ImageOps, ImageFilter
|
| 3 |
-
import tempfile
|
| 4 |
|
| 5 |
def convert_to_moody_bw(image):
|
| 6 |
"""
|
|
@@ -22,22 +21,6 @@ def convert_to_moody_bw(image):
|
|
| 22 |
|
| 23 |
return bw_image
|
| 24 |
|
| 25 |
-
def convert_and_prepare_download(image):
|
| 26 |
-
"""
|
| 27 |
-
์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํํ๊ณ , JPG ํ์์ผ๋ก ๋ณํํ์ฌ ๋ค์ด๋ก๋ํ ์ ์๋๋ก ์ค๋นํฉ๋๋ค.
|
| 28 |
-
"""
|
| 29 |
-
bw_image = convert_to_moody_bw(image)
|
| 30 |
-
|
| 31 |
-
# JPG ํ์์ผ๋ก ๋ณํ
|
| 32 |
-
jpg_image = bw_image.convert("RGB")
|
| 33 |
-
|
| 34 |
-
# ์์ ํ์ผ์ ์ด๋ฏธ์ง ์ ์ฅ
|
| 35 |
-
with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as tmp_file:
|
| 36 |
-
jpg_image.save(tmp_file, format="JPEG")
|
| 37 |
-
tmp_file_path = tmp_file.name
|
| 38 |
-
|
| 39 |
-
return bw_image, tmp_file_path
|
| 40 |
-
|
| 41 |
with gr.Blocks() as demo:
|
| 42 |
gr.Markdown("## ๋ถ์๊ธฐ ์๋ ํ๋ฐฑ ์ฌ์ง ๋ณํ๊ธฐ")
|
| 43 |
|
|
@@ -46,13 +29,17 @@ with gr.Blocks() as demo:
|
|
| 46 |
input_image = gr.Image(type="pil", label="์๋ณธ ์ด๋ฏธ์ง ์
๋ก๋")
|
| 47 |
convert_button = gr.Button("๋ณํํ๊ธฐ")
|
| 48 |
with gr.Column():
|
| 49 |
-
output_image = gr.Image(
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
convert_button.click(
|
| 53 |
-
fn=
|
| 54 |
inputs=input_image,
|
| 55 |
-
outputs=
|
| 56 |
)
|
| 57 |
|
| 58 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image, ImageEnhance, ImageOps, ImageFilter
|
|
|
|
| 3 |
|
| 4 |
def convert_to_moody_bw(image):
|
| 5 |
"""
|
|
|
|
| 21 |
|
| 22 |
return bw_image
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
with gr.Blocks() as demo:
|
| 25 |
gr.Markdown("## ๋ถ์๊ธฐ ์๋ ํ๋ฐฑ ์ฌ์ง ๋ณํ๊ธฐ")
|
| 26 |
|
|
|
|
| 29 |
input_image = gr.Image(type="pil", label="์๋ณธ ์ด๋ฏธ์ง ์
๋ก๋")
|
| 30 |
convert_button = gr.Button("๋ณํํ๊ธฐ")
|
| 31 |
with gr.Column():
|
| 32 |
+
output_image = gr.Image(
|
| 33 |
+
type="pil",
|
| 34 |
+
label="๋ณํ๋ ์ด๋ฏธ์ง",
|
| 35 |
+
interactive=False,
|
| 36 |
+
download=True # ๋ค์ด๋ก๋ ๊ธฐ๋ฅ ํ์ฑํ
|
| 37 |
+
)
|
| 38 |
|
| 39 |
convert_button.click(
|
| 40 |
+
fn=convert_to_moody_bw,
|
| 41 |
inputs=input_image,
|
| 42 |
+
outputs=output_image
|
| 43 |
)
|
| 44 |
|
| 45 |
demo.launch()
|