AIuser2222
commited on
Commit
•
35b487a
1
Parent(s):
f15343b
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
2 |
+
import torch
|
3 |
+
|
4 |
+
def predict(text):
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("username/model_name")
|
6 |
+
model = AutoModelForSequenceClassification.from_pretrained("username/model_name")
|
7 |
+
|
8 |
+
inputs = tokenizer(text, return_tensors="pt")
|
9 |
+
with torch.no_grad():
|
10 |
+
logits = model(**inputs).logits
|
11 |
+
predicted_class_id = logits.argmax().item()
|
12 |
+
return predicted_class_id
|