File size: 739 Bytes
ef64dc8 ddc9405 ef64dc8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#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() |