jpjp9292 commited on
Commit
f42ceb6
โ€ข
1 Parent(s): 12e2766

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+ import numpy as np
4
+
5
+ # ์ด๋ฏธ์ง€ ์—…์Šค์ผ€์ผ ํ•จ์ˆ˜
6
+ 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 = """
14
+ ์ด ๊ณต๊ฐ„์—์„œ๋Š” ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ์™€ ํ’ˆ์งˆ์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
15
+ โš ๏ธ ์ด๋ฏธ์ง€๋ฅผ ํ™•๋Œ€ํ•˜๋Š” ๊ฒƒ์ด ํ•ญ์ƒ ํ’ˆ์งˆ์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค!
16
+ """
17
+
18
+ # ์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ ๋ผ๋””์˜ค ๋ฒ„ํŠผ
19
+ radio_input = gr.Radio(label="์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ", choices=[2, 4, 6, 8, 10], value=2)
20
+
21
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
22
+ demo = gr.Interface(
23
+ fn=upscale_image,
24
+ inputs=[gr.Image(label="์ž…๋ ฅ ์ด๋ฏธ์ง€", type="numpy", tool="editor"), radio_input],
25
+ outputs=gr.Image(label="์—…์Šค์ผ€์ผ๋œ ์ด๋ฏธ์ง€"),
26
+ title="์ด๋ฏธ์ง€ ์—…์Šค์ผ€์ผ๋Ÿฌ",
27
+ description=DESCRIPTION
28
+ )
29
+
30
+ # ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
31
+ demo.launch(show_api=False)