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()
|