|
import gradio as gr |
|
|
|
from transformers import pipeline |
|
classifier = pipeline('text-classification', model='nlmaldonadog/clasificador-rotten-tomatoes-xlnet-base-cased') |
|
|
|
def predict(text): |
|
prediction = classifier(text) |
|
score = int(round(prediction[0]['score'] * 100)) |
|
|
|
if prediction[0]['label'] == "LABEL_0": |
|
output = f"Negative sentiment with a confidence level of {score}%." |
|
else: |
|
output = f"Positive sentiment with a confidence level of {score}%." |
|
return output |
|
|
|
iface = gr.Interface(fn=predict, inputs=[gr.Textbox(placeholder='Escribe aquí...')], outputs="text") |
|
iface.launch(share=True) |