updated app.py
Browse files
app.py
CHANGED
@@ -6,17 +6,14 @@ from transformers import BertTokenizer, BertForSequenceClassification
|
|
6 |
import os
|
7 |
|
8 |
tokenizer = BertTokenizer.from_pretrained("dmis-lab/biobert-base-cased-v1.1")
|
9 |
-
model = BertForSequenceClassification.from_pretrained("dmis-lab/biobert-base-cased-v1.1", num_labels=2
|
10 |
|
11 |
-
# freezing the layers
|
12 |
-
for param in model.parameters():
|
13 |
-
param.requires_grad = False
|
14 |
-
|
15 |
# loading the pretrained weights into the model
|
16 |
state_dict = torch.load('Bio_BERT_model.pth', map_location=torch.device('cpu'), weights_only=True)
|
17 |
model.load_state_dict(state_dict)
|
18 |
print("Weights initialized!")
|
19 |
|
|
|
20 |
device = "cpu"
|
21 |
|
22 |
def predict_drug_target_interaction(sentence):
|
|
|
6 |
import os
|
7 |
|
8 |
tokenizer = BertTokenizer.from_pretrained("dmis-lab/biobert-base-cased-v1.1")
|
9 |
+
model = BertForSequenceClassification.from_pretrained("dmis-lab/biobert-base-cased-v1.1", num_labels=2)
|
10 |
|
|
|
|
|
|
|
|
|
11 |
# loading the pretrained weights into the model
|
12 |
state_dict = torch.load('Bio_BERT_model.pth', map_location=torch.device('cpu'), weights_only=True)
|
13 |
model.load_state_dict(state_dict)
|
14 |
print("Weights initialized!")
|
15 |
|
16 |
+
model.eval()
|
17 |
device = "cpu"
|
18 |
|
19 |
def predict_drug_target_interaction(sentence):
|