Kims12 commited on
Commit
fdd6630
ยท
verified ยท
1 Parent(s): 179001c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import gradio as gr
 
2
  import cv2
3
  import numpy as np
4
 
@@ -12,17 +13,24 @@ def convert_and_save(image):
12
  gray_image = convert_to_grayscale(image)
13
  output_path = "output.png"
14
  cv2.imwrite(output_path, gray_image)
15
- return gray_image, output_path
 
 
 
 
 
 
16
 
17
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
 
18
  iface = gr.Interface(
19
  fn=convert_and_save,
20
  inputs="image",
21
- outputs=["image", "file"],
22
  examples=["1.png", "2.jpg", "3.png"], # ์ƒ˜ํ”Œ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€
23
  title="์ด๋ฏธ์ง€ ํ‘๋ฐฑ ๋ณ€ํ™˜๊ธฐ",
24
  description="์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๋ฉด ํ‘๋ฐฑ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , PNG ํŒŒ์ผ์œผ๋กœ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค."
25
  )
26
 
27
  if __name__ == "__main__":
28
- iface.launch()
 
1
  import gradio as gr
2
+ from gradio_imageslider import ImageSlider
3
  import cv2
4
  import numpy as np
5
 
 
13
  gray_image = convert_to_grayscale(image)
14
  output_path = "output.png"
15
  cv2.imwrite(output_path, gray_image)
16
+
17
+ # Gradio๋Š” RGB ์ด๋ฏธ์ง€๋ฅผ ๊ธฐ๋Œ€ํ•˜๋ฏ€๋กœ ํ‘๋ฐฑ ์ด๋ฏธ์ง€๋ฅผ RGB๋กœ ๋ณ€ํ™˜
18
+ gray_rgb = cv2.cvtColor(gray_image, cv2.COLOR_GRAY2RGB)
19
+ original_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
20
+
21
+ # ๋ณ€๊ฒฝ ์ „ํ›„ ์ด๋ฏธ์ง€๋ฅผ ์Šฌ๋ผ์ด๋“œ๋กœ ๋ฐ˜ํ™˜
22
+ return [gray_rgb, original_rgb], output_path
23
 
24
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
25
+ slider = ImageSlider(label="๋ณ€ํ™˜ ์ „ํ›„ ์ด๋ฏธ์ง€")
26
  iface = gr.Interface(
27
  fn=convert_and_save,
28
  inputs="image",
29
+ outputs=[slider, "file"],
30
  examples=["1.png", "2.jpg", "3.png"], # ์ƒ˜ํ”Œ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€
31
  title="์ด๋ฏธ์ง€ ํ‘๋ฐฑ ๋ณ€ํ™˜๊ธฐ",
32
  description="์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๋ฉด ํ‘๋ฐฑ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , PNG ํŒŒ์ผ์œผ๋กœ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค."
33
  )
34
 
35
  if __name__ == "__main__":
36
+ iface.launch()