Spaces:
Sleeping
Sleeping
umsee
commited on
Commit
·
7c087cb
1
Parent(s):
4b6cffd
made the rudimentary app.py with gradio interface
Browse files
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline, AutoModelForSequenceClassification,AutoTokenizer
|
3 |
+
|
4 |
+
model = AutoModelForSequenceClassification.from_pretrained('albert')
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained('albert')
|
6 |
+
|
7 |
+
classifier = pipeline('sentiment-analysis',model=model,tokenizer=tokenizer,top_k=None)
|
8 |
+
|
9 |
+
def classify(statement):
|
10 |
+
preds = classifier(statement)
|
11 |
+
return{i['labels']:float(i['score']) for i in preds[0]}
|
12 |
+
|
13 |
+
demo = gr.Interface(fn=classify,inputs='text',outputs=gr.Label())
|
14 |
+
demo.launch()
|