File size: 810 Bytes
bbafe1c
9f6299c
4a95be2
 
3c3f44b
4a95be2
 
 
 
304b229
 
4a95be2
 
25881a0
51564bd
 
 
25881a0
 
4a95be2
 
 
 
 
 
 
 
072fb53
26be5cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30


import gradio as gr
from transformers import pipeline
classifier=pipeline("sentiment-analysis")

# Load sentiment analysis pipeline
sentiment_pipeline = pipeline("sentiment-analysis")

text = "I absolutely love this app! It's amazing."

# Define function to use in Gradio
def analyze_sentiment(text):
    result = sentiment_pipeline(text)[0]
    label = result['label']
    score = result['score']
    return f"Sentiment: {label} (confidence: {score})"
    return result

# Create Gradio interface
demo = gr.Interface(fn=analyze_sentiment,
inputs=gr.Textbox(lines=4, placeholder="Enter text here..."),
outputs="text",
title="Sentiment Analysis App",
description="Enter text and get the sentiment prediction using a Hugging Face transformer model.")

# Launch app
if __name__ == "__main__":
    demo.launch()