Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,20 +3,14 @@ import cv2
|
|
3 |
import numpy as np
|
4 |
|
5 |
# ์ด๋ฏธ์ง ์
์ค์ผ์ผ ํจ์
|
6 |
-
def upscale_image(input_image,
|
7 |
-
upscale_factor = int(
|
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 |
-
# ์
์ค์ผ์ผ ์ด๋ฏธ์ง๋ฅผ 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,
|
20 |
return output_filename
|
21 |
|
22 |
# ์ธํฐํ์ด์ค ์ค๋ช
|
@@ -29,7 +23,7 @@ radio_input = gr.Radio(label="์
์ค์ผ์ผ ๋ ๋ฒจ ์ ํ (Select Upscaling level
|
|
29 |
|
30 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
31 |
demo = gr.Interface(
|
32 |
-
fn=
|
33 |
inputs=[gr.Image(label="์
๋ ฅ ์ด๋ฏธ์ง (Input Image)", type="numpy"), radio_input],
|
34 |
outputs=gr.File(label="์
์ค์ผ์ผ๋ ์ด๋ฏธ์ง ๋ค์ด๋ก๋ (Download Upscaled Image)"),
|
35 |
title="Image Upscaler",
|
|
|
3 |
import numpy as np
|
4 |
|
5 |
# ์ด๋ฏธ์ง ์
์ค์ผ์ผ ํจ์
|
6 |
+
def upscale_image(input_image, upscale_factor):
|
7 |
+
upscale_factor = int(upscale_factor) # ์
์ค์ผ์ผ ๋น์จ์ ์ ์ํ์ผ๋ก ๋ณํ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_image_bgr = cv2.cvtColor(output_image, cv2.COLOR_RGB2BGR) # RGB์์ BGR๋ก ๋ณํ
|
12 |
output_filename = "upscaled_image.png"
|
13 |
+
cv2.imwrite(output_filename, output_image_bgr)
|
14 |
return output_filename
|
15 |
|
16 |
# ์ธํฐํ์ด์ค ์ค๋ช
|
|
|
23 |
|
24 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
25 |
demo = gr.Interface(
|
26 |
+
fn=upscale_image,
|
27 |
inputs=[gr.Image(label="์
๋ ฅ ์ด๋ฏธ์ง (Input Image)", type="numpy"), radio_input],
|
28 |
outputs=gr.File(label="์
์ค์ผ์ผ๋ ์ด๋ฏธ์ง ๋ค์ด๋ก๋ (Download Upscaled Image)"),
|
29 |
title="Image Upscaler",
|