Spaces:
Runtime error
Runtime error
File size: 923 Bytes
2bd9468 9902a40 2bd9468 9902a40 891d8e1 2bd9468 9902a40 13ed850 9902a40 891d8e1 2bd9468 13ed850 2bd9468 13ed850 891d8e1 2bd9468 3ec95cb 2bd9468 3382a71 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline
from PIL import Image
# ์ด๋ฏธ์ง ์ธ์ ํ์ดํ๋ผ์ธ ๋ก๋
model = pipeline("image-classification", model="google/vit-base-patch16-224")
def classify_image(uploaded_image):
# ์ด์ uploaded_image๋ ์๋์ผ๋ก PIL.Image ๊ฐ์ฒด์
๋๋ค.
predictions = model(uploaded_image)
return {prediction['label']: prediction['score'] for prediction in predictions}
# Gradio ์ธํฐํ์ด์ค ์์ฑ, type="pil"๋ก ์ค์ ํ์ฌ ์๋์ผ๋ก PIL.Image ๊ฐ์ฒด๋ก ๋ณํ๋๋๋ก ํจ
iface = gr.Interface(fn=classify_image,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=3),
title="์ด๋ฏธ์ง ๋ถ๋ฅ๊ธฐ",
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด, ์ฌ๋ฌผ์ ์ธ์ํ๊ณ ์ต์์ 3๊ฐ์ ๋ถ๋ฅ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.")
# ์ธํฐํ์ด์ค ์คํ
iface.launch()
|