Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
import numpy as np
|
|
|
4 |
from gradio_imageslider import ImageSlider
|
5 |
|
6 |
def convert_to_grayscale(image):
|
@@ -11,16 +12,21 @@ def convert_to_grayscale(image):
|
|
11 |
return gray_image_bgr
|
12 |
|
13 |
def convert_and_save(image):
|
14 |
-
# ์๋ณธ ์ด๋ฏธ์ง๋ฅผ
|
15 |
-
original_image = image.
|
|
|
16 |
# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํ
|
17 |
gray_image = convert_to_grayscale(image)
|
|
|
|
|
18 |
# ์ถ๋ ฅ ํ์ผ ๊ฒฝ๋ก ์ค์
|
19 |
output_path = "output.jpg"
|
20 |
# ํ๋ฐฑ ์ด๋ฏธ์ง ์ ์ฅ
|
21 |
-
cv2.
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
|
25 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
26 |
with gr.Blocks() as demo:
|
@@ -32,7 +38,7 @@ with gr.Blocks() as demo:
|
|
32 |
file_output = gr.File(label="๋ค์ด๋ก๋ ๊ฐ๋ฅํ JPG ํ์ผ")
|
33 |
|
34 |
with gr.Row():
|
35 |
-
slider_output = ImageSlider(label="๋ณ๊ฒฝ ์ ํ ๋น๊ต"
|
36 |
|
37 |
# ๋ฒํผ์ ๋๋ ์ ๋ ํจ์ ์คํ
|
38 |
upload_btn = gr.Button("๋ณํํ๊ธฐ")
|
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
from gradio_imageslider import ImageSlider
|
6 |
|
7 |
def convert_to_grayscale(image):
|
|
|
12 |
return gray_image_bgr
|
13 |
|
14 |
def convert_and_save(image):
|
15 |
+
# ์๋ณธ ์ด๋ฏธ์ง๋ฅผ ๋ณต์ฌํ์ฌ PIL ํ์์ผ๋ก ๋ณํ
|
16 |
+
original_image = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
17 |
+
|
18 |
# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํ
|
19 |
gray_image = convert_to_grayscale(image)
|
20 |
+
gray_image_pil = Image.fromarray(cv2.cvtColor(gray_image, cv2.COLOR_BGR2RGB))
|
21 |
+
|
22 |
# ์ถ๋ ฅ ํ์ผ ๊ฒฝ๋ก ์ค์
|
23 |
output_path = "output.jpg"
|
24 |
# ํ๋ฐฑ ์ด๋ฏธ์ง ์ ์ฅ
|
25 |
+
gray_image_bgr = cv2.cvtColor(gray_image_pil, cv2.COLOR_RGB2BGR)
|
26 |
+
cv2.imwrite(output_path, gray_image_bgr)
|
27 |
+
|
28 |
+
# ์ฌ๋ผ์ด๋์ ์ฌ์ฉํ ๋ ์ด๋ฏธ์ง ๋ฐํ (PIL ํ์)
|
29 |
+
return (original_image, gray_image_pil), output_path
|
30 |
|
31 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
32 |
with gr.Blocks() as demo:
|
|
|
38 |
file_output = gr.File(label="๋ค์ด๋ก๋ ๊ฐ๋ฅํ JPG ํ์ผ")
|
39 |
|
40 |
with gr.Row():
|
41 |
+
slider_output = ImageSlider(label="๋ณ๊ฒฝ ์ ํ ๋น๊ต")
|
42 |
|
43 |
# ๋ฒํผ์ ๋๋ ์ ๋ ํจ์ ์คํ
|
44 |
upload_btn = gr.Button("๋ณํํ๊ธฐ")
|