Spaces:
Sleeping
Sleeping
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() |