SamanthaStorm commited on
Commit
865bd23
·
verified ·
1 Parent(s): 7b8d52b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load SST sentiment model (adjust model name if different)
5
+ sst_classifier = pipeline(
6
+ "text-classification",
7
+ model="SamanthaStorm/tether-sst", # replace with your actual SST model name
8
+ top_k=None,
9
+ truncation=True
10
+ )
11
+
12
+ def classify_sentiment(text):
13
+ result = sst_classifier(text)[0]
14
+ label = result["label"]
15
+ score = round(result["score"] * 100, 2)
16
+
17
+ if label == "LABEL_0":
18
+ return f"Supportive ({score}%)"
19
+ elif label == "LABEL_1":
20
+ return f"Undermining ({score}%)"
21
+ else:
22
+ return f"Unknown label ({label})"
23
+
24
+ iface = gr.Interface(
25
+ fn=classify_sentiment,
26
+ inputs=gr.Textbox(lines=4, placeholder="Paste message here..."),
27
+ outputs="text",
28
+ title="Tether SST Sentiment Analyzer",
29
+ description="Classifies language as Supportive or Undermining based on tone and intent. Part of the Tether project."
30
+ )
31
+
32
+ iface.launch()