Download app.py from Sangwon78/example3: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/spaces/Sangwon78/example3/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sangwon78/example3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sangwon78/example3/resolve/main/app.py
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() | |