testing-ai / app.py
SpawnedShoyo's picture
Create app.py
567ae87 verified
# Import necessary libraries
import gradio as gr
from transformers import pipeline
# Load the model using Transformers pipeline
classifier = pipeline("sentiment-analysis")
# Define the function to make predictions
def predict_sentiment(text):
result = classifier(text)[0]
return f'Text: {text}\nSentiment: {result["label"]} with confidence {result["score"]}'
# Create a Gradio interface
iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text")
# Launch the Gradio interface
iface.launch()