Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,10 @@ def convert_to_grayscale(image):
|
|
7 |
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
8 |
return gray_image
|
9 |
|
10 |
-
def apply_filter(image, filter_type):
|
|
|
|
|
|
|
11 |
if filter_type == "Soft Glow":
|
12 |
# Soft Glow ํจ๊ณผ
|
13 |
gaussian = cv2.GaussianBlur(image, (15, 15), 0)
|
@@ -41,23 +44,25 @@ def apply_filter(image, filter_type):
|
|
41 |
# ํํฐ๋ฅผ ์ ์ฉํ์ง ์์
|
42 |
return image
|
43 |
|
44 |
-
def convert_and_save(image, filter_type):
|
45 |
-
# ์ ํํ
|
46 |
-
filtered_image = apply_filter(image, filter_type)
|
47 |
-
# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํ
|
48 |
-
gray_image = convert_to_grayscale(filtered_image)
|
49 |
# ์ด๋ฏธ์ง๋ฅผ ์ ์ฅ
|
50 |
output_path = "output.jpg"
|
51 |
-
cv2.imwrite(output_path,
|
52 |
-
return
|
53 |
|
54 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
55 |
iface = gr.Interface(
|
56 |
fn=convert_and_save,
|
57 |
-
inputs=[
|
|
|
|
|
|
|
|
|
58 |
outputs=["image", "file"],
|
59 |
-
title="์ด๋ฏธ์ง ํ๋ฐฑ ๋ณํ๊ธฐ",
|
60 |
-
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๊ณ
|
61 |
)
|
62 |
|
63 |
iface.launch()
|
|
|
7 |
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
8 |
return gray_image
|
9 |
|
10 |
+
def apply_filter(image, filter_type, grayscale):
|
11 |
+
if grayscale:
|
12 |
+
image = convert_to_grayscale(image)
|
13 |
+
|
14 |
if filter_type == "Soft Glow":
|
15 |
# Soft Glow ํจ๊ณผ
|
16 |
gaussian = cv2.GaussianBlur(image, (15, 15), 0)
|
|
|
44 |
# ํํฐ๋ฅผ ์ ์ฉํ์ง ์์
|
45 |
return image
|
46 |
|
47 |
+
def convert_and_save(image, filter_type, grayscale):
|
48 |
+
# ์ ํํ ํํฐ์ ํ๋ฐฑ ๋ณํ ์ฌ๋ถ๋ฅผ ์ด๋ฏธ์ง์ ์ ์ฉ
|
49 |
+
filtered_image = apply_filter(image, filter_type, grayscale)
|
|
|
|
|
50 |
# ์ด๋ฏธ์ง๋ฅผ ์ ์ฅ
|
51 |
output_path = "output.jpg"
|
52 |
+
cv2.imwrite(output_path, filtered_image)
|
53 |
+
return filtered_image, output_path
|
54 |
|
55 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
56 |
iface = gr.Interface(
|
57 |
fn=convert_and_save,
|
58 |
+
inputs=[
|
59 |
+
"image",
|
60 |
+
gr.Radio(["None", "Soft Glow", "Portrait Enhancer", "Warm Tone", "Cold Tone", "High-Key", "Low-Key", "Haze"], label="ํํฐ ์ ํ"),
|
61 |
+
gr.Checkbox(label="ํ๋ฐฑ ๋ณํ")
|
62 |
+
],
|
63 |
outputs=["image", "file"],
|
64 |
+
title="์ด๋ฏธ์ง ํํฐ ๋ฐ ํ๋ฐฑ ๋ณํ๊ธฐ",
|
65 |
+
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๊ณ ํํฐ์ ํ๋ฐฑ ๋ณํ ์ฌ๋ถ๋ฅผ ์ ํํ๋ฉด, ๋ณํ๋ ์ด๋ฏธ์ง๋ฅผ JPG ํ์ผ๋ก ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค."
|
66 |
)
|
67 |
|
68 |
iface.launch()
|