Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import fasttext
|
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
import re
|
| 5 |
import string
|
|
|
|
| 6 |
|
| 7 |
def load_GlotLID():
|
| 8 |
model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model_v3.bin")
|
|
@@ -23,10 +24,11 @@ def compute(sentence):
|
|
| 23 |
sentence = preprocess_text(sentence)
|
| 24 |
|
| 25 |
# Get top 3 predictions
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
results = []
|
| 29 |
-
for label, score in zip(
|
| 30 |
label = label.split('__')[-1]
|
| 31 |
results.append(f"{label}: {score:.4f}")
|
| 32 |
|
|
|
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
import re
|
| 5 |
import string
|
| 6 |
+
import numpy as np
|
| 7 |
|
| 8 |
def load_GlotLID():
|
| 9 |
model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model_v3.bin")
|
|
|
|
| 24 |
sentence = preprocess_text(sentence)
|
| 25 |
|
| 26 |
# Get top 3 predictions
|
| 27 |
+
labels, probs = model.predict(sentence, k=3)
|
| 28 |
+
probs = np.asarray(probs)
|
| 29 |
|
| 30 |
results = []
|
| 31 |
+
for label, score in zip(labels, probs):
|
| 32 |
label = label.split('__')[-1]
|
| 33 |
results.append(f"{label}: {score:.4f}")
|
| 34 |
|