Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,34 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# ์คํ
|
| 24 |
if __name__ == "__main__":
|
| 25 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
|
| 4 |
+
def convert_to_grayscale(image):
|
| 5 |
+
# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํ
|
| 6 |
+
gray_image = image.convert("L")
|
| 7 |
+
return gray_image
|
| 8 |
|
| 9 |
+
# Gradio UI ๊ตฌ์ฑ
|
| 10 |
+
with gr.Blocks() as app:
|
| 11 |
+
gr.Markdown("# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํ")
|
| 12 |
+
|
| 13 |
+
with gr.Row():
|
| 14 |
+
input_image = gr.Image(label="์๋ณธ ์ด๋ฏธ์ง", type="pil")
|
| 15 |
+
output_image = gr.Image(label="ํ๋ฐฑ ์ด๋ฏธ์ง", type="pil")
|
| 16 |
+
|
| 17 |
+
convert_button = gr.Button("๋ณํํ๊ธฐ")
|
| 18 |
+
download_button = gr.Button("JPG๋ก ๋ค์ด๋ก๋")
|
| 19 |
+
|
| 20 |
+
convert_button.click(
|
| 21 |
+
fn=convert_to_grayscale,
|
| 22 |
+
inputs=input_image,
|
| 23 |
+
outputs=output_image
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
download_button.click(
|
| 27 |
+
fn=lambda img: img.save("converted_image.jpg", "JPEG") or "converted_image.jpg",
|
| 28 |
+
inputs=output_image,
|
| 29 |
+
outputs=gr.File(label="JPG ํ์ผ ๋ค์ด๋ก๋")
|
| 30 |
+
)
|
| 31 |
|
| 32 |
# ์คํ
|
| 33 |
if __name__ == "__main__":
|
| 34 |
+
app.launch()
|