# import gradio as gr # from transformers import pipeline # classifier = pipeline('text-classification', model='el-filatova/clasificador-tweet-sentiment') # def predict(text): # return classifier(text) # iface = gr.Interface(fn=predict, inputs=[gr.Textbox(value="ah, what a pang of aching sharp surprise")], outputs="text") # iface.launch() import gradio as gr from transformers import pipeline classifier = pipeline('text-classification', model='el-filatova/clasificador-tweet-sentiment') def predict(text): prediction = classifier(text) score = int(round(prediction[0]['score'] * 100)) if prediction[0]['label'] == "LABEL_0": output = f"This tweet carries a negative sentiment with a confidence level of {score}%." elif prediction[0]['label'] == "LABEL_1": output = f"This tweet carries a neutral sentiment with a confidence level of {score}%." else: output = f"This tweet carries a positive sentiment with a confidence level of {score}%." return output iface = gr.Interface(fn=predict, inputs=[gr.Textbox(value="The feedback received was generally constructive with some areas for improvement highlighted.")], outputs="text") iface.launch(share=True)