File size: 628 Bytes
4839721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from huggingface_hub import hf_hub_download
import fasttext
import gradio as gr

# ๋ชจ๋ธ ๋‹ค์šด๋กœ๋“œ
model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin")

# ๋ชจ๋ธ ๋กœ๋“œ
model = fasttext.load_model(model_path)

# ์˜ˆ์ธก ํ•จ์ˆ˜
def predict_language(text):
    predictions = model.predict(text)
    return {
        "Predicted language": predictions[0][0],
        "Confidence score": predictions[1][0]
    }

# Gradio ์ธํ„ฐํŽ˜์ด์Šค
interface = gr.Interface(
    fn=predict_language,
    inputs=gr.Textbox(label="Input Text"),
    outputs="json",
    title="Language Predictor"
)

interface.launch()