Kims12 commited on
Commit
26ae524
โ€ข
1 Parent(s): 16f9a51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
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
- # ์ฐธ์กฐ ์ฝ”๋“œ์— ๋”ฐ๋ผ PIL์„ ์‚ฌ์šฉํ•˜์—ฌ ํ”ผ๋ถ€ ํ†ค์„ ๊ท ์ผํ•˜๊ฒŒ ํ•˜๊ณ  ์„ ๋ช…๋„๋ฅผ ์กฐ์ ˆ
17
- from PIL import Image, ImageEnhance
 
 
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 * intensity)
22
 
23
  enhancer = ImageEnhance.Color(image_pil)
24
- image_pil = enhancer.enhance(1 + 0.1 * intensity)
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