garrettbaber
commited on
Commit
•
416a17c
1
Parent(s):
35902f0
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,16 @@ import gradio as gr
|
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
|
4 |
def processInput(input):
|
|
|
5 |
model = AutoModelForSequenceClassification.from_pretrained("garrettbaber/twitter-roberta-base-fear-intensity")
|
6 |
tokenizer = AutoTokenizer.from_pretrained("garrettbaber/twitter-roberta-base-fear-intensity")
|
|
|
7 |
tokens = tokenizer(input, return_tensors="pt")
|
8 |
-
|
9 |
outputs = model(**tokens)
|
10 |
-
|
|
|
|
|
11 |
|
12 |
app = gr.Interface(fn=processInput, inputs="text", outputs="text")
|
13 |
|
|
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
|
4 |
def processInput(input):
|
5 |
+
#load model and tokenizer
|
6 |
model = AutoModelForSequenceClassification.from_pretrained("garrettbaber/twitter-roberta-base-fear-intensity")
|
7 |
tokenizer = AutoTokenizer.from_pretrained("garrettbaber/twitter-roberta-base-fear-intensity")
|
8 |
+
#get tokens
|
9 |
tokens = tokenizer(input, return_tensors="pt")
|
10 |
+
#pass tokens to model
|
11 |
outputs = model(**tokens)
|
12 |
+
#parse output
|
13 |
+
logits = outputs.get("logits")
|
14 |
+
return logits.tolist()
|
15 |
|
16 |
app = gr.Interface(fn=processInput, inputs="text", outputs="text")
|
17 |
|