Sangwon78 commited on
Commit
2463a13
Β·
verified Β·
1 Parent(s): 0b698a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
app.py CHANGED
@@ -1,9 +1,9 @@
1
  import gradio as gr
2
- from PIL import Image, ImageEnhance, ImageOps
3
  import cv2
4
  import numpy as np
5
 
6
- # ν•„ν„° κΈ°λŠ₯ κ΅¬ν˜„
7
  def apply_filter(image, filter_type, intensity):
8
  img = np.array(image)
9
 
@@ -28,35 +28,39 @@ def apply_filter(image, filter_type, intensity):
28
 
29
  return Image.fromarray(img)
30
 
31
- # 파일 μ €μž₯ κΈ°λŠ₯
32
  def save_file(image, format):
33
  file_path = f"processed_image.{format.lower()}"
34
  image.save(file_path, format=format)
35
  return file_path
36
 
37
- # Gradio μΈν„°νŽ˜μ΄μŠ€ μ„€μ •
38
  def process_image(image, filter_type, intensity, file_format):
39
  filtered_image = apply_filter(image, filter_type, intensity)
40
  download_path = save_file(filtered_image, file_format)
41
  return filtered_image, download_path
42
 
43
- # UI ꡬ성
44
  with gr.Blocks() as demo:
45
- gr.Markdown("# 이미지 ν•„ν„° μ• ν”Œλ¦¬μΌ€μ΄μ…˜")
 
 
46
  with gr.Row():
47
- image_input = gr.Image(type="pil", label="이미지 μ—…λ‘œλ“œ")
48
- filter_selector = gr.Dropdown(
49
- ["Soft Glow", "Portrait Enhancer", "Warm Tone", "Cold Tone",
50
- "High-Key", "Low-Key", "Haze", "Monochrome"],
51
- label="ν•„ν„° 선택"
52
- )
53
- intensity_slider = gr.Slider(0.0, 1.0, value=0.5, label="ν•„ν„° 강도")
54
- file_format_selector = gr.Radio(["JPG", "PNG", "PDF"], label="파일 ν˜•μ‹ 선택")
55
- output_image = gr.Image(label="κ²°κ³Ό 이미지")
56
- download_button = gr.File(label="λ‹€μš΄λ‘œλ“œ")
 
 
 
57
 
58
- # λ™μž‘ μ—°κ²°
59
- submit_button = gr.Button("ν•„ν„° 적용")
60
  submit_button.click(
61
  process_image,
62
  inputs=[image_input, filter_selector, intensity_slider, file_format_selector],
 
1
  import gradio as gr
2
+ from PIL import Image
3
  import cv2
4
  import numpy as np
5
 
6
+ # ν•„ν„° 적용 ν•¨μˆ˜
7
  def apply_filter(image, filter_type, intensity):
8
  img = np.array(image)
9
 
 
28
 
29
  return Image.fromarray(img)
30
 
31
+ # 파일 μ €μž₯ ν•¨μˆ˜
32
  def save_file(image, format):
33
  file_path = f"processed_image.{format.lower()}"
34
  image.save(file_path, format=format)
35
  return file_path
36
 
37
+ # 이미지 λ³€ν™˜ ν›„ λ°˜ν™˜
38
  def process_image(image, filter_type, intensity, file_format):
39
  filtered_image = apply_filter(image, filter_type, intensity)
40
  download_path = save_file(filtered_image, file_format)
41
  return filtered_image, download_path
42
 
43
+ # Gradio UI ꡬ성
44
  with gr.Blocks() as demo:
45
+ gr.Markdown("# πŸ“· 이미지 ν•„ν„° λ³€ν™˜κΈ°")
46
+ gr.Markdown("이미지λ₯Ό μ—…λ‘œλ“œν•˜κ³  μ›ν•˜λŠ” ν•„ν„°λ₯Ό 클릭해 λ³€ν™˜ν•΄ λ³΄μ„Έμš”!")
47
+
48
  with gr.Row():
49
+ image_input = gr.Image(type="pil", label="이미지 선택")
50
+ with gr.Column():
51
+ filter_selector = gr.Dropdown(
52
+ ["Soft Glow", "Portrait Enhancer", "Warm Tone", "Cold Tone",
53
+ "High-Key", "Low-Key", "Haze", "Monochrome"],
54
+ label="ν•„ν„° 선택"
55
+ )
56
+ intensity_slider = gr.Slider(0.0, 1.0, value=0.5, label="ν•„ν„° 강도")
57
+ file_format_selector = gr.Radio(["JPG", "PNG", "PDF"], label="파일 ν˜•μ‹")
58
+ submit_button = gr.Button("λ³€ν™˜ 적용")
59
+
60
+ output_image = gr.Image(label="λ³€ν™˜λœ 이미지")
61
+ download_button = gr.File(label="λ‹€μš΄λ‘œλ“œ 링크")
62
 
63
+ # λ²„νŠΌ 클릭 μ‹œ λ™μž‘ μ—°κ²°
 
64
  submit_button.click(
65
  process_image,
66
  inputs=[image_input, filter_selector, intensity_slider, file_format_selector],