Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
model_id = "juliensimon/xlm-v-base-language-id" | |
p = pipeline("text-classification", model=model_id) | |
def process(text, top_k=5): | |
pred = p(text, top_k=top_k) | |
scores = {x["label"]: x["score"] for x in pred} | |
print(scores) | |
return scores | |
# Gradio inputs | |
input_text = gr.Text(label="Enter text") | |
# Gradio outputs | |
labels = gr.Label(label="Languages", num_top_classes=5) | |
description = "This Space lets you perform language identification on the 102 languages present in the google/fleurs dataset." | |
iface = gr.Interface( | |
description=description, | |
fn=process, | |
inputs=input_text, | |
outputs=labels, | |
examples=[], | |
allow_flagging="never", | |
) | |
iface.launch() | |