File size: 1,124 Bytes
f165ab3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

# ๋ชจ๋ธ ๋กœ๋”ฉ (HuggingFace์˜ havocy28/VetBERT ์‚ฌ์šฉ)
tokenizer = AutoTokenizer.from_pretrained("havocy28/VetBERT")
model = AutoModelForSequenceClassification.from_pretrained("havocy28/VetBERT")

def classify_symptom(text):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
    with torch.no_grad():
        logits = model(**inputs).logits
        pred = torch.argmax(logits, dim=1).item()

    # ์˜ˆ์‹œ ๋ ˆ์ด๋ธ” ์ด๋ฆ„ (๋ชจ๋ธ์— ๋งž์ถฐ ์ˆ˜์ • ๊ฐ€๋Šฅ)
    labels = {
        0: "์ •์ƒ",
        1: "์†Œํ™”๊ธฐ ์งˆํ™˜",
        2: "ํ˜ธํก๊ธฐ ์งˆํ™˜",
        3: "ํ”ผ๋ถ€ ์งˆํ™˜",
        4: "๊ธฐํƒ€ ์ด์ƒ",
    }
    return labels.get(pred, f"์˜ˆ์ธก ๋ผ๋ฒจ: {pred}")

demo = gr.Interface(
    fn=classify_symptom,
    inputs=gr.Textbox(lines=3, placeholder="๋ฐ˜๋ ค๋™๋ฌผ ์ฆ์ƒ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."),
    outputs="text",
    title="VetBERT AI ์ˆ˜์˜์‚ฌ",
    description="๋ฐ˜๋ ค๊ฒฌ/๋ฌ˜ ์ฆ์ƒ ๋ฌธ์žฅ์„ ์ž…๋ ฅํ•˜๋ฉด AI๊ฐ€ ์˜์‹ฌ ์งˆ๋ณ‘์„ ๋ถ„๋ฅ˜ํ•ด์ค๋‹ˆ๋‹ค."
)

demo.launch()