Spaces:
Runtime error
Runtime error
File size: 741 Bytes
4938fc2 |
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 29 30 31 32 33 34 |
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()
|