jpjp9292 commited on
Commit
bf99ee9
โ€ข
1 Parent(s): facffb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -7,7 +7,10 @@ def upscale_image(input_image, radio_input):
7
  upscale_factor = int(radio_input) # ์—…์Šค์ผ€์ผ ๋น„์œจ์„ ์ •์ˆ˜ํ˜•์œผ๋กœ ๋ณ€ํ™˜
8
  # ์ž…๋ ฅ ์ด๋ฏธ์ง€๋ฅผ ์ฃผ์–ด์ง„ ์—…์Šค์ผ€์ผ ๋น„์œจ๋กœ ํฌ๊ธฐ ๋ณ€๊ฒฝ (๋ณด๊ฐ„๋ฒ•: INTER_CUBIC)
9
  output_image = cv2.resize(input_image, None, fx=upscale_factor, fy=upscale_factor, interpolation=cv2.INTER_CUBIC)
10
- return output_image
 
 
 
11
 
12
  # ์ธํ„ฐํŽ˜์ด์Šค ์„ค๋ช…
13
  DESCRIPTION = """
@@ -15,13 +18,13 @@ DESCRIPTION = """
15
  """
16
 
17
  # ์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ ๋ผ๋””์˜ค ๋ฒ„ํŠผ
18
- radio_input = gr.Radio(label="์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ (Select Upscaling level)", choices=[2, 4, 6, 8, 10], value=2)
19
 
20
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
21
  demo = gr.Interface(
22
  fn=upscale_image,
23
  inputs=[gr.Image(label="์ž…๋ ฅ ์ด๋ฏธ์ง€ (Input Image)", type="numpy"), radio_input],
24
- outputs=gr.Image(label="์—…์Šค์ผ€์ผ๋œ ์ด๋ฏธ์ง€(Upscaled Image)"),
25
  title="Image Upscaler",
26
  description=DESCRIPTION
27
  )
 
7
  upscale_factor = int(radio_input) # ์—…์Šค์ผ€์ผ ๋น„์œจ์„ ์ •์ˆ˜ํ˜•์œผ๋กœ ๋ณ€ํ™˜
8
  # ์ž…๋ ฅ ์ด๋ฏธ์ง€๋ฅผ ์ฃผ์–ด์ง„ ์—…์Šค์ผ€์ผ ๋น„์œจ๋กœ ํฌ๊ธฐ ๋ณ€๊ฒฝ (๋ณด๊ฐ„๋ฒ•: INTER_CUBIC)
9
  output_image = cv2.resize(input_image, None, fx=upscale_factor, fy=upscale_factor, interpolation=cv2.INTER_CUBIC)
10
+ # ์—…์Šค์ผ€์ผ๋œ ์ด๋ฏธ์ง€๋ฅผ PNG ํŒŒ์ผ๋กœ ์ €์žฅ
11
+ output_file_path = "/mnt/data/upscaled_image.png"
12
+ cv2.imwrite(output_file_path, output_image)
13
+ return output_image, output_file_path
14
 
15
  # ์ธํ„ฐํŽ˜์ด์Šค ์„ค๋ช…
16
  DESCRIPTION = """
 
18
  """
19
 
20
  # ์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ ๋ผ๋””์˜ค ๋ฒ„ํŠผ
21
+ radio_input = gr.Radio(label="์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ (Select Upscaling level)", choices=[2, 4, 6, 8], value=2)
22
 
23
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
24
  demo = gr.Interface(
25
  fn=upscale_image,
26
  inputs=[gr.Image(label="์ž…๋ ฅ ์ด๋ฏธ์ง€ (Input Image)", type="numpy"), radio_input],
27
+ outputs=[gr.Image(label="์—…์Šค์ผ€์ผ๋œ ์ด๋ฏธ์ง€(Upscaled Image)"), gr.File(label="PNG ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ (Download PNG File)")],
28
  title="Image Upscaler",
29
  description=DESCRIPTION
30
  )