Kims12 commited on
Commit
c52ffb7
โ€ข
1 Parent(s): 223546c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -69,7 +69,11 @@ def convert_and_save(image, filter_type, intensity):
69
  original_image_pil = Image.fromarray(cv2.cvtColor(image_cv, cv2.COLOR_BGR2RGB))
70
  filtered_image_pil = Image.fromarray(cv2.cvtColor(filtered_image, cv2.COLOR_BGR2RGB))
71
 
72
- return original_image_pil, filtered_image_pil # ์›๋ณธ๊ณผ ํ•„ํ„ฐ ์ ์šฉ๋œ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜
 
 
 
 
73
 
74
  def get_filter_description(filter_type):
75
  descriptions = {
@@ -98,6 +102,7 @@ with gr.Blocks() as iface:
98
 
99
  with gr.Column():
100
  slider_output = ImageSlider(label="Before and After", type="pil")
 
101
 
102
  filter_input.change(fn=get_filter_description, inputs=filter_input, outputs=description_output)
103
 
@@ -105,7 +110,7 @@ with gr.Blocks() as iface:
105
  process_button.click(
106
  fn=convert_and_save,
107
  inputs=[image_input, filter_input, intensity_slider],
108
- outputs=slider_output
109
  )
110
 
111
  iface.title = "์ธ๋ฌผ ์‚ฌ์ง„์— ์ตœ์ ํ™”๋œ ํ•„ํ„ฐ"
 
69
  original_image_pil = Image.fromarray(cv2.cvtColor(image_cv, cv2.COLOR_BGR2RGB))
70
  filtered_image_pil = Image.fromarray(cv2.cvtColor(filtered_image, cv2.COLOR_BGR2RGB))
71
 
72
+ # ํ•„ํ„ฐ ์ ์šฉ๋œ ์ด๋ฏธ์ง€๋ฅผ JPG๋กœ ์ €์žฅ
73
+ output_path = "filtered_image.jpg"
74
+ filtered_image_pil.save(output_path)
75
+
76
+ return original_image_pil, filtered_image_pil, output_path # ์›๋ณธ, ํ•„ํ„ฐ ์ ์šฉ๋œ ์ด๋ฏธ์ง€์™€ ํŒŒ์ผ ๊ฒฝ๋กœ ๋ฐ˜ํ™˜
77
 
78
  def get_filter_description(filter_type):
79
  descriptions = {
 
102
 
103
  with gr.Column():
104
  slider_output = ImageSlider(label="Before and After", type="pil")
105
+ download_link = gr.File(label="Download Filtered Image")
106
 
107
  filter_input.change(fn=get_filter_description, inputs=filter_input, outputs=description_output)
108
 
 
110
  process_button.click(
111
  fn=convert_and_save,
112
  inputs=[image_input, filter_input, intensity_slider],
113
+ outputs=[slider_output, download_link]
114
  )
115
 
116
  iface.title = "์ธ๋ฌผ ์‚ฌ์ง„์— ์ตœ์ ํ™”๋œ ํ•„ํ„ฐ"