File size: 1,295 Bytes
f42ceb6
 
 
 
 
 
 
 
 
bf99ee9
 
 
164755a
f42ceb6
 
 
facffb3
f42ceb6
 
 
f6f13ee
f42ceb6
 
 
 
facffb3
164755a
1a2dc2a
f42ceb6
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import cv2
import numpy as np

# ์ด๋ฏธ์ง€ ์—…์Šค์ผ€์ผ ํ•จ์ˆ˜
def upscale_image(input_image, radio_input):
    upscale_factor = int(radio_input)  # ์—…์Šค์ผ€์ผ ๋น„์œจ์„ ์ •์ˆ˜ํ˜•์œผ๋กœ ๋ณ€ํ™˜
    # ์ž…๋ ฅ ์ด๋ฏธ์ง€๋ฅผ ์ฃผ์–ด์ง„ ์—…์Šค์ผ€์ผ ๋น„์œจ๋กœ ํฌ๊ธฐ ๋ณ€๊ฒฝ (๋ณด๊ฐ„๋ฒ•: INTER_CUBIC)
    output_image = cv2.resize(input_image, None, fx=upscale_factor, fy=upscale_factor, interpolation=cv2.INTER_CUBIC)
    # ์—…์Šค์ผ€์ผ๋œ ์ด๋ฏธ์ง€๋ฅผ PNG ํŒŒ์ผ๋กœ ์ €์žฅ
    output_file_path = "/mnt/data/upscaled_image.png"
    cv2.imwrite(output_file_path, output_image)
    return output_file_path

# ์ธํ„ฐํŽ˜์ด์Šค ์„ค๋ช…
DESCRIPTION = """
์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ์™€ ํ’ˆ์งˆ์„ ํ–ฅ์ƒ์‹œ์ผœ ๋ณด์„ธ์š”! (you can increase the size and quality of your images)
"""

# ์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ ๋ผ๋””์˜ค ๋ฒ„ํŠผ
radio_input = gr.Radio(label="์—…์Šค์ผ€์ผ ๋ ˆ๋ฒจ ์„ ํƒ (Select Upscaling level)", choices=[2, 4, 6, 8, 10], value=2)

# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
demo = gr.Interface(
    fn=upscale_image,
    inputs=[gr.Image(label="์ž…๋ ฅ ์ด๋ฏธ์ง€ (Input Image)", type="numpy"), radio_input],
    outputs=gr.File(label="PNG ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ (Download PNG File)"),
    title="Image Upscaler",
    description=DESCRIPTION
)

# ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
demo.launch(show_api=False)