Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
2 |
+
import gradio as grad
|
3 |
+
tokenizer = AutoTokenizer.from_pretrained("oigele/Fb_improved_zeroshot")
|
4 |
+
model = AutoModelForSequenceClassification.from_pretrained("oigele/Fb_improved_zeroshot")
|
5 |
+
|
6 |
+
def classify(text,label):
|
7 |
+
tkn_ids = bart_tkn.encode(text, label, return_tensors='pt')
|
8 |
+
tkn_lgts = mdl(tkn_ids)[0]
|
9 |
+
entail_contra_tkn_lgts = tkn_lgts[:,[0,2]]
|
10 |
+
probab = entail_contra_tkn_lgts.softmax(dim=1)
|
11 |
+
response = probab[:,1].item() * 100
|
12 |
+
return response
|
13 |
+
txt=grad.Textbox(lines=1, label="English", placeholder="text to be classified")
|
14 |
+
labels=grad.Textbox(lines=1, label="Label", placeholder="Input a Label")
|
15 |
+
out=grad.Textbox(lines=1, label="Probablity of label being true is")
|
16 |
+
grad.Interface(classify, inputs=[txt,labels], outputs=out).launch()
|