Spaces:
Sleeping
Sleeping
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()
|