menimeni123
commited on
Commit
•
e70b46d
1
Parent(s):
5237bb2
latest
Browse files
app.py
CHANGED
@@ -1,22 +1,21 @@
|
|
1 |
# app.py
|
2 |
-
import os
|
3 |
-
import joblib
|
4 |
import torch
|
5 |
-
|
|
|
6 |
from torch.nn.functional import softmax
|
7 |
|
8 |
-
# Load the tokenizer
|
9 |
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
10 |
|
11 |
-
#
|
12 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
13 |
|
14 |
-
# Load
|
15 |
model = joblib.load('model.joblib')
|
16 |
model.to(device)
|
17 |
model.eval()
|
18 |
|
19 |
-
# Class names
|
20 |
class_names = ["JAILBREAK", "INJECTION", "PHISHING", "SAFE"]
|
21 |
|
22 |
def preprocess(text):
|
|
|
1 |
# app.py
|
|
|
|
|
2 |
import torch
|
3 |
+
import joblib
|
4 |
+
from transformers import BertTokenizer
|
5 |
from torch.nn.functional import softmax
|
6 |
|
7 |
+
# Load the tokenizer
|
8 |
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
9 |
|
10 |
+
# Device configuration
|
11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
12 |
|
13 |
+
# Load your saved model
|
14 |
model = joblib.load('model.joblib')
|
15 |
model.to(device)
|
16 |
model.eval()
|
17 |
|
18 |
+
# Class names corresponding to the labels
|
19 |
class_names = ["JAILBREAK", "INJECTION", "PHISHING", "SAFE"]
|
20 |
|
21 |
def preprocess(text):
|