ADI2005 commited on
Commit
a5d1e72
1 Parent(s): 5db3749

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +22 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis pipeline
5
+ sentiment_pipeline = pipeline("sentiment-analysis")
6
+
7
+ # Define the function that will use the model
8
+ def analyze_sentiment(text):
9
+ result = sentiment_pipeline(text)[0]
10
+ return {"label": result['label'], "score": result['score']}
11
+
12
+ # Create the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=analyze_sentiment,
15
+ inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
16
+ outputs="json",
17
+ title="Sentiment Analysis",
18
+ description="A simple sentiment analysis web app using Hugging Face Transformers."
19
+ )
20
+
21
+ if __name__ == "__main__":
22
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio