Spaces:
Runtime error
Runtime error
Commit
·
4e33088
1
Parent(s):
236f4b8
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import gradio as gr
|
|
7 |
# set up model
|
8 |
auth_token = os.environ.get("TOKEN") or True
|
9 |
tokenizer = AutoTokenizer.from_pretrained("guidecare/feelings_and_issues", use_auth_token=auth_token )
|
10 |
-
model = AutoModelForSequenceClassification.from_pretrained("guidecare/feelings_and_issues", use_auth_token=auth_token
|
11 |
all_label_names = list(model.config.id2label.values())
|
12 |
|
13 |
|
@@ -17,6 +17,7 @@ def predict(text):
|
|
17 |
probs = [float(np.round(i, 2)) for i in probs[0]]
|
18 |
# break out issue, harm, sentiment, feeling
|
19 |
zipped_list = list(zip(all_label_names, probs))
|
|
|
20 |
issues = [(i, j) for i, j in zipped_list if i.startswith('issue')]
|
21 |
feelings = [(i, j) for i, j in zipped_list if i.startswith('feeling')]
|
22 |
harm = [(i, j) for i, j in zipped_list if i.startswith('harm')]
|
@@ -27,7 +28,6 @@ def predict(text):
|
|
27 |
# top is the combo of these
|
28 |
top = issues + feelings + harm
|
29 |
d = {i: j for i, j in top}
|
30 |
-
print(text, top)
|
31 |
return d
|
32 |
|
33 |
iface = gr.Interface(
|
@@ -37,4 +37,4 @@ iface = gr.Interface(
|
|
37 |
#examples=["This test tomorrow is really freaking me out."]
|
38 |
)
|
39 |
|
40 |
-
iface.launch()
|
|
|
7 |
# set up model
|
8 |
auth_token = os.environ.get("TOKEN") or True
|
9 |
tokenizer = AutoTokenizer.from_pretrained("guidecare/feelings_and_issues", use_auth_token=auth_token )
|
10 |
+
model = AutoModelForSequenceClassification.from_pretrained("guidecare/feelings_and_issues", use_auth_token=auth_token)
|
11 |
all_label_names = list(model.config.id2label.values())
|
12 |
|
13 |
|
|
|
17 |
probs = [float(np.round(i, 2)) for i in probs[0]]
|
18 |
# break out issue, harm, sentiment, feeling
|
19 |
zipped_list = list(zip(all_label_names, probs))
|
20 |
+
print(text, zipped_list)
|
21 |
issues = [(i, j) for i, j in zipped_list if i.startswith('issue')]
|
22 |
feelings = [(i, j) for i, j in zipped_list if i.startswith('feeling')]
|
23 |
harm = [(i, j) for i, j in zipped_list if i.startswith('harm')]
|
|
|
28 |
# top is the combo of these
|
29 |
top = issues + feelings + harm
|
30 |
d = {i: j for i, j in top}
|
|
|
31 |
return d
|
32 |
|
33 |
iface = gr.Interface(
|
|
|
37 |
#examples=["This test tomorrow is really freaking me out."]
|
38 |
)
|
39 |
|
40 |
+
iface.launch(share=True)
|