Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,2 +1,27 @@
|
|
1 |
-
import
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
def convert_to_grayscale(image):
|
6 |
+
# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํ
|
7 |
+
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
8 |
+
return gray_image
|
9 |
+
|
10 |
+
def convert_and_save(image):
|
11 |
+
# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํํ๊ณ , ๋ค์ด๋ก๋ ๊ฐ๋ฅํ JPG ํ์ผ๋ก ์ ์ฅ
|
12 |
+
gray_image = convert_to_grayscale(image)
|
13 |
+
output_path = "output.jpg"
|
14 |
+
cv2.imwrite(output_path, gray_image)
|
15 |
+
return gray_image, output_path
|
16 |
+
|
17 |
+
# Gradio ์ธํฐํ์ด์ค ์ ์
|
18 |
+
iface = gr.Interface(
|
19 |
+
fn=convert_and_save,
|
20 |
+
inputs="image",
|
21 |
+
outputs=["image", "file"],
|
22 |
+
title="์ด๋ฏธ์ง ํ๋ฐฑ ๋ณํ๊ธฐ",
|
23 |
+
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด ํ๋ฐฑ์ผ๋ก ๋ณํํ๊ณ , JPG ํ์ผ๋ก ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค."
|
24 |
+
)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
iface.launch()
|