Adapters
cyn
AIuser2222 commited on
Commit
35b487a
1 Parent(s): f15343b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
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