Spaces:
Runtime error
Runtime error
File size: 841 Bytes
182a4ef 2cb5d06 4793ccb f2c7fbd f429d37 182a4ef 4793ccb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from transformers import pipeline
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
repo_id = "luisvarona/clasificador-trek"
classifier = pipeline("text-classification", model="luisvarona/clasificador-trek")
# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(str):
dic_label_score = classifier(str)[0]
label = dic_label_score['label']
score = dic_label_score['score']
dicc = {'LABEL_0': 'ABBR', 'LABEL_1': 'ENTY', 'LABEL_2': 'DESC', 'LABEL_3': 'HUM', 'LABEL_4': 'LOC', 'LABEL_5': 'NUM'}
label = dicc[label]
return label # + ', con score ' + str(score)) #No se por qué no funciona todo...
# Creamos la interfaz y la lanzamos.
gr.Interface(fn=predict, inputs="textbox", outputs="textbox", examples=['How old are you?','What time is it?']).launch(share=True)
|