File size: 759 Bytes
f37b414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import cv2
import numpy as np
import gradio as gr

def process_image(image):
    # 이미지 처리: 흑백 변환
    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    # JPG 형식으로 저장
    output_file = "grayscale_image.jpg"
    cv2.imwrite(output_file, gray_image)
    return gray_image, output_file

# Gradio 인터페이스
interface = gr.Interface(
    fn=process_image,
    inputs=gr.Image(type="numpy"),  # 입력 이미지
    outputs=[gr.Image(type="numpy", label="Grayscale Image"), gr.File(label="Download JPG")],
    title="이미지 흑백 변환기",
    description="이미지를 업로드하면 흑백으로 변환된 결과와 JPG 다운로드 링크를 제공합니다.",
)

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