syedabdullah32 commited on
Commit
dc5ecd1
·
1 Parent(s): 54914db

Create sentimental.py

Browse files
Files changed (1) hide show
  1. sentimental.py +17 -0
sentimental.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load pre-trained model from Hugging Face
5
+ classifier = pipeline('sentiment-analysis')
6
+
7
+ def classify_text(text):
8
+ result = classifier(text)[0]
9
+ label = result['label']
10
+ score = result['score']
11
+ return f"{label} (confidence: {score:.2f})"
12
+
13
+ # Create the Gradio interface
14
+ iface = gr.Interface(fn=classify_text, inputs=["text"], outputs=["prediction"])
15
+
16
+ # Launch the Gradio app
17
+ iface.launch()