Jasieg commited on
Commit
22db7ab
·
verified ·
1 Parent(s): 25e7f34
Files changed (1) hide show
  1. app.py +17 -5
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
- label = result["label"].upper()
11
  score = result["score"]
12
- return f"{label} – pewność: {score:.0%}"
 
 
 
 
 
 
 
 
 
 
 
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 i nie chce jeść..."),
17
- outputs=gr.Textbox(label="Ocena ryzyka"),
18
  title="VetBERTDx – triage weterynaryjny",
19
- description="Im więcej szczegółów, tym lepsza ocena"
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()