Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,22 +9,32 @@ def upscale_image(input_image, radio_input):
|
|
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 |
์ด๋ฏธ์ง์ ํฌ๊ธฐ์ ํ์ง์ ํฅ์์์ผ ๋ณด์ธ์! (you can increase the size and quality of your images)
|
15 |
"""
|
16 |
|
17 |
# ์
์ค์ผ์ผ ๋ ๋ฒจ ์ ํ ๋ผ๋์ค ๋ฒํผ
|
18 |
-
radio_input = gr.Radio(label="์
์ค์ผ์ผ
|
19 |
|
20 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
21 |
demo = gr.Interface(
|
22 |
-
fn=
|
23 |
inputs=[gr.Image(label="์
๋ ฅ ์ด๋ฏธ์ง (Input Image)", type="numpy"), radio_input],
|
24 |
-
outputs=gr.
|
25 |
title="Image Upscaler",
|
26 |
description=DESCRIPTION
|
27 |
)
|
28 |
|
29 |
# ์ธํฐํ์ด์ค ์คํ
|
30 |
-
demo.launch(show_api=False)
|
|
|
9 |
output_image = cv2.resize(input_image, None, fx=upscale_factor, fy=upscale_factor, interpolation=cv2.INTER_CUBIC)
|
10 |
return output_image
|
11 |
|
12 |
+
# ์
์ค์ผ์ผ ์ด๋ฏธ์ง๋ฅผ PNG๋ก ์ ์ฅํ๋ ํจ์
|
13 |
+
def save_image_as_png(input_image, radio_input):
|
14 |
+
upscale_factor = int(radio_input) # ์
์ค์ผ์ผ ๋น์จ์ ์ ์ํ์ผ๋ก ๋ณํ
|
15 |
+
# ์
๋ ฅ ์ด๋ฏธ์ง๋ฅผ ์ฃผ์ด์ง ์
์ค์ผ์ผ ๋น์จ๋ก ํฌ๊ธฐ ๋ณ๊ฒฝ (๋ณด๊ฐ๋ฒ: INTER_CUBIC)
|
16 |
+
output_image = cv2.resize(input_image, None, fx=upscale_factor, fy=upscale_factor, interpolation=cv2.INTER_CUBIC)
|
17 |
+
# ์ด๋ฏธ์ง๋ฅผ PNG ํ์์ผ๋ก ์ ์ฅ
|
18 |
+
output_filename = "upscaled_image.png"
|
19 |
+
cv2.imwrite(output_filename, output_image)
|
20 |
+
return output_filename
|
21 |
+
|
22 |
# ์ธํฐํ์ด์ค ์ค๋ช
|
23 |
DESCRIPTION = """
|
24 |
์ด๋ฏธ์ง์ ํฌ๊ธฐ์ ํ์ง์ ํฅ์์์ผ ๋ณด์ธ์! (you can increase the size and quality of your images)
|
25 |
"""
|
26 |
|
27 |
# ์
์ค์ผ์ผ ๋ ๋ฒจ ์ ํ ๋ผ๋์ค ๋ฒํผ
|
28 |
+
radio_input = gr.Radio(label="์
์ค์ผ์ผ ๋ ๋ฒจ ์ ํ (Select Upscaling level)", choices=[2, 4, 6, 8, 10], value=2)
|
29 |
|
30 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
31 |
demo = gr.Interface(
|
32 |
+
fn=save_image_as_png,
|
33 |
inputs=[gr.Image(label="์
๋ ฅ ์ด๋ฏธ์ง (Input Image)", type="numpy"), radio_input],
|
34 |
+
outputs=gr.File(label="์
์ค์ผ์ผ๋ ์ด๋ฏธ์ง ๋ค์ด๋ก๋ (Download Upscaled Image)"),
|
35 |
title="Image Upscaler",
|
36 |
description=DESCRIPTION
|
37 |
)
|
38 |
|
39 |
# ์ธํฐํ์ด์ค ์คํ
|
40 |
+
demo.launch(show_api=False)
|