import gradio as gr | |
from transformers import pipeline | |
pipe = pipeline("text-classification", model="TheBritishLibrary/bl-books-genre") | |
def puntuacion_sentimientos (texto): | |
resultado = pipe (texto) | |
print (resultado) | |
etiqueta = resultado[0]["label"] | |
print(texto+': '+etiqueta) | |
return etiqueta | |
demo = gr.Interface(fn=puntuacion_sentimientos, inputs="text", outputs="text") | |
demo. launch () |