ajeetkumar01 commited on
Commit
6be941c
1 Parent(s): c749efb

added the app.py files

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Function to perform sentiment analysis
5
+ def sentiment_classifier(text):
6
+ try:
7
+ sentiment_classifier = pipeline("sentiment-analysis")
8
+ sentiment_response = sentiment_classifier(text)
9
+ label = sentiment_response[0]['label']
10
+ score = sentiment_response[0]['score']
11
+ return label, score
12
+ except Exception as e:
13
+ return str(e)
14
+
15
+ # Create Gradio interface
16
+ input_text = gr.Textbox(lines=10, label="Input Text", placeholder="Enter text for sentiment analysis...")
17
+ output_label = gr.Textbox(label="Sentiment Label", placeholder="Sentiment label will appear here...")
18
+ output_score = gr.Textbox(label="Sentiment Score", placeholder="Sentiment score will appear here...")
19
+
20
+ # Author information
21
+ author = "Ajeetkumar Ukande"
22
+
23
+ # Create Gradio interface
24
+ interface = gr.Interface(sentiment_classifier, inputs=input_text, outputs=[output_label, output_score],
25
+ title="<div style='color: #336699; font-size: 24px; font-weight: bold; border: 2px solid #336699; padding: 10px; border-radius: 10px;'>Sentiment Analysis</div>",
26
+ description=f"""<div style='color: #666666; font-family: Arial, sans-serif;'>
27
+ <p style='margin-top: 10px;'>Enter some text for sentiment analysis.</p>
28
+ <p>Developed by <span style='color: #336699; font-weight: bold;'>{author}</span>.</p>
29
+ </div>""",
30
+ theme="default" # Change theme to default
31
+ )
32
+
33
+ # Deploy the interface to Hugging Face Spaces
34
+ interface.launch(debug=True)
35
+