renad0 commited on
Commit
65841a1
·
verified ·
1 Parent(s): c160d51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1 +1,23 @@
1
- import gradio as gr from transformers import pipeline # Load the sentiment analysis pipeline sentiment_pipeline = pipeline("sentiment-analysis") def analyze_sentiment(text): result = sentiment_pipeline(text)[0] label = result["label"] score = result["score"] return f"Sentiment: {label}\nConfidence: {score:.2f}" # Create the Gradio interface iface = gr.Interface( fn=analyze_sentiment, inputs=gr.Textbox(placeholder="Enter text to analyze..."), outputs=gr.Textbox(), title="Sentiment Analysis App", description="Enter a sentence to determine its sentiment (positive or negative).", examples=[ ["I love this product! It's amazing!"], ["I am very disappointed with the service."] ] ) # Launch the app if __name__ == "__main__": iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr from transformers
2
+ import pipeline # Load the sentiment analysis pipeline
3
+ sentiment_pipeline = pipeline("sentiment-analysis")
4
+ def analyze_sentiment(text):
5
+ result = sentiment_pipeline(text)[0]
6
+ label = result["label"]
7
+ score = result["score"]
8
+ return f"Sentiment: {label}\nConfidence: {score:.2f}"
9
+ # Create the Gradio interface
10
+ iface = gr.Interface( fn=analyze_sentiment,
11
+ inputs=gr.Textbox(placeholder="Enter text to analyze..."),
12
+ outputs=gr.Textbox(),
13
+ title="Sentiment Analysis App",
14
+ description="Enter a sentence to determine its sentiment (positive or negative).",
15
+ examples=[
16
+ ["I love this product! It's amazing!"],
17
+ ["I am very disappointed with the service."]
18
+ ]
19
+ )
20
+ # Launch the app if __name__ == "__main__": iface.launch()
21
+ if__name__ == "__main__":
22
+ iface.launch()
23
+