Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,20 @@
|
|
1 |
from huggingface_hub import hf_hub_download
|
2 |
import fasttext
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
# ๋ชจ๋ธ ๋ค์ด๋ก๋
|
6 |
model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin")
|
7 |
-
|
8 |
-
# ๋ชจ๋ธ ๋ก๋
|
9 |
model = fasttext.load_model(model_path)
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
# ์์ธก ํจ์
|
12 |
def predict_language(text):
|
13 |
-
predictions = model
|
14 |
return {
|
15 |
"Predicted language": predictions[0][0],
|
16 |
"Confidence score": predictions[1][0]
|
|
|
1 |
from huggingface_hub import hf_hub_download
|
2 |
import fasttext
|
3 |
+
import numpy as np
|
4 |
import gradio as gr
|
5 |
|
6 |
# ๋ชจ๋ธ ๋ค์ด๋ก๋
|
7 |
model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin")
|
|
|
|
|
8 |
model = fasttext.load_model(model_path)
|
9 |
|
10 |
+
# ์์ ๋ predict ํจ์
|
11 |
+
def patched_predict(model, text):
|
12 |
+
labels, probs = model.predict(text)
|
13 |
+
return labels, np.asarray(probs)
|
14 |
+
|
15 |
# ์์ธก ํจ์
|
16 |
def predict_language(text):
|
17 |
+
predictions = patched_predict(model, text)
|
18 |
return {
|
19 |
"Predicted language": predictions[0][0],
|
20 |
"Confidence score": predictions[1][0]
|