Spaces:
Sleeping
Sleeping
File size: 540 Bytes
909b12c d5f2c23 d792e08 d5f2c23 909b12c f6fdb99 909b12c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import gradio as gr
import fasttext
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(repo_id="facebook/fasttext-language-identification", filename="model.bin")
model = fasttext.load_model(model_path)
def classify(input):
labels,values = model.predict(input, k=5)
paired = zip(labels, values)
label_dict = dict(paired)
label_dict = {k.removeprefix('__label__'): v for k, v in label_dict.items()}
return label_dict
iface = gr.Interface(fn=classify, inputs="text", outputs="label")
iface.launch() |