Spaces:
Runtime error
Runtime error
Commit
·
d74be1e
1
Parent(s):
880def8
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
2 |
+
from scipy.special import expit
|
3 |
+
import numpy as np
|
4 |
+
import pickle
|
5 |
+
import os
|
6 |
+
import pandas as pd
|
7 |
+
|
8 |
+
# set up model
|
9 |
+
auth_token = os.environ.get("TOKEN") or True
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained("guidecare/feelings_and_issues", use_auth_token=auth_token )
|
11 |
+
model = AutoModelForSequenceClassification.from_pretrained("guidecare/feelings_and_issues", use_auth_token=auth_token )
|
12 |
+
all_label_names = list(model.config.id2label.values())
|
13 |
+
|
14 |
+
|
15 |
+
def probs(texts):
|
16 |
+
probs = expit(model(**tokenizer(texts, return_tensors="pt", padding=True)).logits.detach().numpy())
|
17 |
+
return list(zip(all_label_names, probs))
|
18 |
+
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=predict,
|
21 |
+
inputs='What is going on with you',
|
22 |
+
outputs='Our predictions',
|
23 |
+
examples=[["This test tomorrow is really freaking me out."]]
|
24 |
+
)
|
25 |
+
|
26 |
+
iface.launch()
|