s2337a commited on
Commit
64d929d
ยท
verified ยท
1 Parent(s): 87a0814

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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.predict(text)
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]