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 |
|
5 |
def apply_filter(image, filter_type, intensity):
|
6 |
# ๊ฐ๋๋ฅผ 0.0์์ 1.0 ์ฌ์ด๋ก ์ ๊ทํ
|
@@ -13,15 +14,17 @@ def apply_filter(image, filter_type, intensity):
|
|
13 |
soft_glow = cv2.addWeighted(image, 1 - normalized_intensity, gaussian, normalized_intensity, 0)
|
14 |
return soft_glow
|
15 |
elif filter_type == "Portrait Enhancer":
|
16 |
-
#
|
17 |
-
|
|
|
|
|
18 |
image_pil = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
19 |
|
20 |
enhancer = ImageEnhance.Sharpness(image_pil)
|
21 |
-
image_pil = enhancer.enhance(1 + 0.1 *
|
22 |
|
23 |
enhancer = ImageEnhance.Color(image_pil)
|
24 |
-
image_pil = enhancer.enhance(1 + 0.1 *
|
25 |
|
26 |
enhanced_image = cv2.cvtColor(np.array(image_pil), cv2.COLOR_RGB2BGR)
|
27 |
return enhanced_image
|
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
import numpy as np
|
4 |
+
from PIL import Image, ImageEnhance
|
5 |
|
6 |
def apply_filter(image, filter_type, intensity):
|
7 |
# ๊ฐ๋๋ฅผ 0.0์์ 1.0 ์ฌ์ด๋ก ์ ๊ทํ
|
|
|
14 |
soft_glow = cv2.addWeighted(image, 1 - normalized_intensity, gaussian, normalized_intensity, 0)
|
15 |
return soft_glow
|
16 |
elif filter_type == "Portrait Enhancer":
|
17 |
+
# ๊ธฐ๋ณธ 30% ๊ฐ๋์์ ์์ํ์ฌ ์ต๋ 100% ๊ฐ๋๊น์ง ์กฐ์
|
18 |
+
base_intensity = 0.3
|
19 |
+
adjusted_intensity = base_intensity + (normalized_intensity * (1 - base_intensity))
|
20 |
+
|
21 |
image_pil = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
22 |
|
23 |
enhancer = ImageEnhance.Sharpness(image_pil)
|
24 |
+
image_pil = enhancer.enhance(1 + 0.1 * adjusted_intensity)
|
25 |
|
26 |
enhancer = ImageEnhance.Color(image_pil)
|
27 |
+
image_pil = enhancer.enhance(1 + 0.1 * adjusted_intensity)
|
28 |
|
29 |
enhanced_image = cv2.cvtColor(np.array(image_pil), cv2.COLOR_RGB2BGR)
|
30 |
return enhanced_image
|