modified tokenizer
Browse files- bio_clip_recommender.py +1 -2
bio_clip_recommender.py
CHANGED
|
@@ -38,13 +38,12 @@ class ProteinEmbedder:
|
|
| 38 |
print("ProtT5 Online!")
|
| 39 |
|
| 40 |
def embed_raw_sequence(self, sequence: str):
|
| 41 |
-
"""Converts a raw string of amino acids into the 1024D vector."""
|
| 42 |
seq = re.sub(r"[UZOB]", "X", sequence.upper())
|
| 43 |
|
| 44 |
seq_spaced = " ".join(list(seq))
|
| 45 |
|
| 46 |
with torch.no_grad():
|
| 47 |
-
ids = self.tokenizer
|
| 48 |
input_ids = ids['input_ids'].to(self.device)
|
| 49 |
attention_mask = ids['attention_mask'].to(self.device)
|
| 50 |
|
|
|
|
| 38 |
print("ProtT5 Online!")
|
| 39 |
|
| 40 |
def embed_raw_sequence(self, sequence: str):
|
|
|
|
| 41 |
seq = re.sub(r"[UZOB]", "X", sequence.upper())
|
| 42 |
|
| 43 |
seq_spaced = " ".join(list(seq))
|
| 44 |
|
| 45 |
with torch.no_grad():
|
| 46 |
+
ids = self.tokenizer([seq_spaced], add_special_tokens=True, padding=True, return_tensors="pt")
|
| 47 |
input_ids = ids['input_ids'].to(self.device)
|
| 48 |
attention_mask = ids['attention_mask'].to(self.device)
|
| 49 |
|