File size: 777 Bytes
2bd9468
 
 
c1a4cc8
891d8e1
2bd9468
 
 
891d8e1
2bd9468
c1a4cc8
2bd9468
c1a4cc8
891d8e1
2bd9468
891d8e1
2bd9468
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from transformers import pipeline

# ์ด๋ฏธ์ง€ ์ธ์‹ ํŒŒ์ดํ”„๋ผ์ธ ๋กœ๋“œ, ๋ชจ๋ธ์„ ๋ช…์‹œ์ ์œผ๋กœ ์ง€์ •
model = pipeline("image-classification", model="google/vit-base-patch16-224")

def classify_image(image):
    predictions = model(image)
    return {prediction['label']: prediction['score'] for prediction in predictions}

# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ (shape ์ธ์ž ์—†์ด)
iface = gr.Interface(fn=classify_image,
                     inputs=gr.Image(),
                     outputs=gr.Label(num_top_classes=3),
                     title="์ด๋ฏธ์ง€ ๋ถ„๋ฅ˜๊ธฐ",
                     description="์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๋ฉด, ์‚ฌ๋ฌผ์„ ์ธ์‹ํ•˜๊ณ  ์ตœ์ƒ์œ„ 3๊ฐœ์˜ ๋ถ„๋ฅ˜ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.")

# ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
iface.launch()