File size: 888 Bytes
ea56e72
 
cfdd604
ea56e72
ec17889
ea56e72
 
 
 
 
3946ab3
ea56e72
3946ab3
ea56e72
 
 
 
 
 
 
 
3946ab3
ea56e72
3946ab3
ea56e72
 
 
3946ab3
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
import gradio as gr
import cv2
import numpy as np

def convert_to_grayscale(image):
    # ์ด๋ฏธ์ง€๋ฅผ ํ‘๋ฐฑ์œผ๋กœ ๋ณ€ํ™˜
    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    return gray_image

def convert_and_save(image):
    # ์ด๋ฏธ์ง€๋ฅผ ํ‘๋ฐฑ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , ๋‹ค์šด๋กœ๋“œ ๊ฐ€๋Šฅํ•œ PNG ํŒŒ์ผ๋กœ ์ €์žฅ
    gray_image = convert_to_grayscale(image)
    output_path = "output.png"
    cv2.imwrite(output_path, gray_image)
    return gray_image, output_path

# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
iface = gr.Interface(
    fn=convert_and_save,
    inputs="image",
    outputs=["image", "file"],
    examples=["1.png", "2.jpg", "3.png"],  # ์ƒ˜ํ”Œ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€
    title="์ด๋ฏธ์ง€ ํ‘๋ฐฑ ๋ณ€ํ™˜๊ธฐ",
    description="์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๋ฉด ํ‘๋ฐฑ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , PNG ํŒŒ์ผ์œผ๋กœ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค."
)

if __name__ == "__main__":
    iface.launch()