File size: 398 Bytes
31a7455
5d00e2d
31a7455
656c4ee
a01581e
d688851
c7102bb
d2888a8
 
 
72eacc1
31a7455
d2888a8
31a7455
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from transformers import pipeline

def do_action(text):
    pipe = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection")
    result = pipe(text, top_k=10)

    # Reformat our result
    result = {item['label']: item['score'] for item in result}

    return result

iface = gr.Interface(fn=do_action, inputs="text", outputs="label")
iface.launch()