.2
Browse files
app.py
CHANGED
|
@@ -6,15 +6,27 @@ classifier = pipeline("text-classification", model="havocy28/VetBERTDx")
|
|
| 6 |
def predict(text):
|
| 7 |
if not text or not text.strip():
|
| 8 |
return "Wpisz objawy zwierzaka"
|
|
|
|
| 9 |
result = classifier(text.strip())[0]
|
| 10 |
-
|
| 11 |
score = result["score"]
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
gr.Interface(
|
| 15 |
fn=predict,
|
| 16 |
-
inputs=gr.Textbox(lines=6, label="Opis objawów", placeholder="Pies ma czerwone dziąsła, śmierdzi z pyska
|
| 17 |
-
outputs=gr.Textbox(label="Ocena ryzyka"),
|
| 18 |
title="VetBERTDx – triage weterynaryjny",
|
| 19 |
-
description="
|
| 20 |
).launch()
|
|
|
|
| 6 |
def predict(text):
|
| 7 |
if not text or not text.strip():
|
| 8 |
return "Wpisz objawy zwierzaka"
|
| 9 |
+
|
| 10 |
result = classifier(text.strip())[0]
|
| 11 |
+
raw_label = result["label"].upper()
|
| 12 |
score = result["score"]
|
| 13 |
+
|
| 14 |
+
# Mapujemy prawdziwe etykiety Twojego modelu
|
| 15 |
+
label_map = {
|
| 16 |
+
"UNKNOWN": "HIGH", # <-- to jest Twój przypadek
|
| 17 |
+
"LOW": "LOW",
|
| 18 |
+
"MEDIUM": "MEDIUM",
|
| 19 |
+
"HIGH": "HIGH"
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
final_label = label_map.get(raw_label, raw_label)
|
| 23 |
+
|
| 24 |
+
return f"{final_label} – pewność: {score:.0%}"
|
| 25 |
|
| 26 |
gr.Interface(
|
| 27 |
fn=predict,
|
| 28 |
+
inputs=gr.Textbox(lines=6, label="Opis objawów", placeholder="Pies ma czerwone dziąsła, śmierdzi z pyska..."),
|
| 29 |
+
outputs=gr.Textbox(label="Ocena ryzyka VetBERTDx"),
|
| 30 |
title="VetBERTDx – triage weterynaryjny",
|
| 31 |
+
description="Działa! Model zwrócił UNKNOWN → mapujemy na HIGH"
|
| 32 |
).launch()
|