Commit
•
e2e3dc6
1
Parent(s):
fcb20a6
Upload README.md
Browse files
README.md
CHANGED
@@ -34,9 +34,7 @@ from transformers import AutoModel
|
|
34 |
import torch
|
35 |
|
36 |
|
37 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
38 |
|
39 |
-
print(f"Using {device} device")
|
40 |
def pad_inner_lists_to_length(outer_list,target_length=16):
|
41 |
for inner_list in outer_list:
|
42 |
padding_length = target_length - len(inner_list)
|
@@ -45,22 +43,20 @@ def pad_inner_lists_to_length(outer_list,target_length=16):
|
|
45 |
return outer_list
|
46 |
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
model.to(device)
|
54 |
-
peptide_examples = ['EDSAIVTPSR','SVWEPAKAKYVFR']
|
55 |
-
peptide_encoding = tokenizer(peptide_examples)['input_ids']
|
56 |
-
peptide_encoding = pad_inner_lists_to_length(peptide_encoding)
|
57 |
-
print(peptide_encoding)
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
print(outputs)
|
63 |
-
print(representations)
|
64 |
```
|
65 |
And here is how to use TransHLA_II model to predict the peptide whether epitope:
|
66 |
|
|
|
34 |
import torch
|
35 |
|
36 |
|
|
|
37 |
|
|
|
38 |
def pad_inner_lists_to_length(outer_list,target_length=16):
|
39 |
for inner_list in outer_list:
|
40 |
padding_length = target_length - len(inner_list)
|
|
|
43 |
return outer_list
|
44 |
|
45 |
|
46 |
+
if __name__ = "__main__":
|
47 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
48 |
+
print(f"Using {device} device")
|
49 |
+
tokenizer = AutoTokenizer.from_pretrained("facebook/esm2_t33_650M_UR50D")
|
50 |
+
model = AutoModel.from_pretrained("SkywalkerLu/TransHLA_I", trust_remote_code=True)
|
51 |
+
model.to(device)
|
52 |
+
peptide_examples = ['EDSAIVTPSR','SVWEPAKAKYVFR']
|
53 |
+
peptide_encoding = tokenizer(peptide_examples)['input_ids']
|
54 |
+
peptide_encoding = pad_inner_lists_to_length(peptide_encoding)
|
55 |
+
print(peptide_encoding)
|
56 |
+
peptide_encoding = torch.tensor(peptide_encoding)
|
57 |
+
outputs,representations = model(peptide_encoding.to(device))
|
58 |
+
print(outputs)
|
59 |
+
print(representations)
|
|
|
|
|
60 |
```
|
61 |
And here is how to use TransHLA_II model to predict the peptide whether epitope:
|
62 |
|