Update app.py
Browse files
app.py
CHANGED
@@ -2,16 +2,11 @@ import gradio as gr
|
|
2 |
import cv2
|
3 |
import numpy as np
|
4 |
|
5 |
-
def
|
6 |
-
|
7 |
-
|
8 |
-
|
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)
|
17 |
soft_glow = cv2.addWeighted(image, 0.5, gaussian, 0.5, 0)
|
@@ -44,9 +39,14 @@ def apply_filter(image, filter_type, grayscale):
|
|
44 |
# ํํฐ๋ฅผ ์ ์ฉํ์ง ์์
|
45 |
return image
|
46 |
|
47 |
-
def
|
48 |
-
#
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
# ์ด๋ฏธ์ง๋ฅผ ์ ์ฅ
|
51 |
output_path = "output.jpg"
|
52 |
cv2.imwrite(output_path, filtered_image)
|
@@ -57,12 +57,14 @@ iface = gr.Interface(
|
|
57 |
fn=convert_and_save,
|
58 |
inputs=[
|
59 |
"image",
|
60 |
-
gr.Radio(
|
61 |
-
|
|
|
|
|
62 |
],
|
63 |
outputs=["image", "file"],
|
64 |
title="์ด๋ฏธ์ง ํํฐ ๋ฐ ํ๋ฐฑ ๋ณํ๊ธฐ",
|
65 |
-
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๊ณ
|
66 |
)
|
67 |
|
68 |
iface.launch()
|
|
|
2 |
import cv2
|
3 |
import numpy as np
|
4 |
|
5 |
+
def apply_filter(image, filter_type):
|
6 |
+
if filter_type == "Grayscale":
|
7 |
+
# ํ๋ฐฑ ๋ณํ
|
8 |
+
return convert_to_grayscale(image)
|
9 |
+
elif filter_type == "Soft Glow":
|
|
|
|
|
|
|
|
|
|
|
10 |
# Soft Glow ํจ๊ณผ
|
11 |
gaussian = cv2.GaussianBlur(image, (15, 15), 0)
|
12 |
soft_glow = cv2.addWeighted(image, 0.5, gaussian, 0.5, 0)
|
|
|
39 |
# ํํฐ๋ฅผ ์ ์ฉํ์ง ์์
|
40 |
return image
|
41 |
|
42 |
+
def convert_to_grayscale(image):
|
43 |
+
# ์ด๋ฏธ์ง๋ฅผ ํ๋ฐฑ์ผ๋ก ๋ณํ
|
44 |
+
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
45 |
+
return gray_image
|
46 |
+
|
47 |
+
def convert_and_save(image, filter_type):
|
48 |
+
# ์ ํํ ํํฐ๋ฅผ ์ด๋ฏธ์ง์ ์ ์ฉ
|
49 |
+
filtered_image = apply_filter(image, filter_type)
|
50 |
# ์ด๋ฏธ์ง๋ฅผ ์ ์ฅ
|
51 |
output_path = "output.jpg"
|
52 |
cv2.imwrite(output_path, filtered_image)
|
|
|
57 |
fn=convert_and_save,
|
58 |
inputs=[
|
59 |
"image",
|
60 |
+
gr.Radio(
|
61 |
+
["None", "Grayscale", "Soft Glow", "Portrait Enhancer", "Warm Tone", "Cold Tone", "High-Key", "Low-Key", "Haze"],
|
62 |
+
label="ํํฐ ์ ํ"
|
63 |
+
)
|
64 |
],
|
65 |
outputs=["image", "file"],
|
66 |
title="์ด๋ฏธ์ง ํํฐ ๋ฐ ํ๋ฐฑ ๋ณํ๊ธฐ",
|
67 |
+
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๊ณ ํํฐ(๋๋ ํ๋ฐฑ ๋ณํ)๋ฅผ ์ ํํ๋ฉด, ๋ณํ๋ ์ด๋ฏธ์ง๋ฅผ JPG ํ์ผ๋ก ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค."
|
68 |
)
|
69 |
|
70 |
iface.launch()
|