example3 / app.py
Sangwon78's picture
Update app.py
f37b414 verified
Raw History Blame Contribute Delete
759 Bytes
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()