dd / importing
s2337a's picture
Create importing
4839721 verified
raw
history blame
628 Bytes
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()