Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
def process_image(image):
|
| 6 |
+
# 이미지 처리: 흑백 변환
|
| 7 |
+
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 8 |
+
# JPG 형식으로 저장
|
| 9 |
+
output_file = "grayscale_image.jpg"
|
| 10 |
+
cv2.imwrite(output_file, gray_image)
|
| 11 |
+
return gray_image, output_file
|
| 12 |
+
|
| 13 |
+
# Gradio 인터페이스
|
| 14 |
+
interface = gr.Interface(
|
| 15 |
+
fn=process_image,
|
| 16 |
+
inputs=gr.Image(type="numpy"), # 입력 이미지
|
| 17 |
+
outputs=[gr.Image(type="numpy", label="Grayscale Image"), gr.File(label="Download JPG")],
|
| 18 |
+
title="이미지 흑백 변환기",
|
| 19 |
+
description="이미지를 업로드하면 흑백으로 변환된 결과와 JPG 다운로드 링크를 제공합니다.",
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
interface.launch()
|