task1 / app.py
Fhad17's picture
Update app.py
ddc9405 verified
raw
history blame contribute delete
739 Bytes
#import gradio and transformers pipeline
from transformers import pipeline
from huggingface_hub import InferenceClient
import gradio as gr
# the model that we are using sentiment analysis
model = pipeline("sentiment-analysis")
#the function definetion and the reviews
def get_sentiment(input_text):
analysis = model(input_text)
sent = analysis[0]['label']
score = analysis[0]['score']
return sent, score
#interface function and necessery calles
interface = gr.Interface(fn = get_sentiment, inputs=gr.Textbox(label = "Enter the review :"), outputs = [gr.Textbox(label = "Sentiment :"), gr.Textbox(label = "Score :")], title = "Sentiment analysis protoype")
#launch of the interface
if __name__ == "__main__":
interface.launch()