Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -33,3 +33,15 @@ else:
|
|
33 |
|
34 |
tokenizer = AutoTokenizer.from_pretrained(tokenizerPath)
|
35 |
model = AutoModelForSequenceClassification.from_pretrained(modelPath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
tokenizer = AutoTokenizer.from_pretrained(tokenizerPath)
|
35 |
model = AutoModelForSequenceClassification.from_pretrained(modelPath)
|
36 |
+
|
37 |
+
tokens = tokenizer.tokenize(input_text)
|
38 |
+
token_ids = tokenizer.convert_tokens_to_ids(tokens)
|
39 |
+
input_ids = tokenizer(input_text)
|
40 |
+
|
41 |
+
batch = tokenizer(X_train, padding=True, truncation=True, max_length=512, return_tensors="pt")
|
42 |
+
|
43 |
+
with torch.no_grad():
|
44 |
+
outputs = model(**batch)
|
45 |
+
predictions = TF.softmax(outputs.logits, dim=1)
|
46 |
+
labels = torch.argmax(predictions, dim=1)
|
47 |
+
labels = [model.config.id2label[label_id] for label_id in labels.tolist()]
|