Spaces:
Sleeping
Sleeping
wwydmanski
commited on
Commit
•
5cce9a4
1
Parent(s):
9605c17
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,9 @@ from transformers import AutoTokenizer, EsmForProteinFolding
|
|
3 |
from transformers.models.esm.openfold_utils.protein import to_pdb, Protein as OFProtein
|
4 |
from transformers.models.esm.openfold_utils.feats import atom14_to_atom37
|
5 |
import torch
|
|
|
|
|
|
|
6 |
|
7 |
def convert_outputs_to_pdb(outputs):
|
8 |
final_atom_positions = atom14_to_atom37(outputs["positions"][-1], outputs)
|
@@ -27,7 +30,7 @@ def convert_outputs_to_pdb(outputs):
|
|
27 |
return pdbs
|
28 |
|
29 |
def fold_prot_locally(sequence):
|
30 |
-
|
31 |
tokenized_input = tokenizer([sequence], return_tensors="pt", add_special_tokens=False)['input_ids'].cuda()
|
32 |
|
33 |
with torch.no_grad():
|
@@ -36,7 +39,9 @@ def fold_prot_locally(sequence):
|
|
36 |
return pdb
|
37 |
|
38 |
tokenizer = AutoTokenizer.from_pretrained("facebook/esmfold_v1")
|
39 |
-
model = EsmForProteinFolding.from_pretrained("facebook/esmfold_v1", low_cpu_mem_usage=True).cuda()
|
|
|
|
|
40 |
|
41 |
iface = gr.Interface(fn=fold_prot_locally, inputs="text", outputs="text")
|
42 |
iface.launch()
|
|
|
3 |
from transformers.models.esm.openfold_utils.protein import to_pdb, Protein as OFProtein
|
4 |
from transformers.models.esm.openfold_utils.feats import atom14_to_atom37
|
5 |
import torch
|
6 |
+
from logging import getLogger
|
7 |
+
|
8 |
+
logger = getLogger(__name__)
|
9 |
|
10 |
def convert_outputs_to_pdb(outputs):
|
11 |
final_atom_positions = atom14_to_atom37(outputs["positions"][-1], outputs)
|
|
|
30 |
return pdbs
|
31 |
|
32 |
def fold_prot_locally(sequence):
|
33 |
+
logger.info("Folding: " + sequence)
|
34 |
tokenized_input = tokenizer([sequence], return_tensors="pt", add_special_tokens=False)['input_ids'].cuda()
|
35 |
|
36 |
with torch.no_grad():
|
|
|
39 |
return pdb
|
40 |
|
41 |
tokenizer = AutoTokenizer.from_pretrained("facebook/esmfold_v1")
|
42 |
+
model = EsmForProteinFolding.from_pretrained("facebook/esmfold_v1", low_cpu_mem_usage=True).cuda()
|
43 |
+
model.esm = model.esm.half()
|
44 |
+
torch.backends.cuda.matmul.allow_tf32 = True
|
45 |
|
46 |
iface = gr.Interface(fn=fold_prot_locally, inputs="text", outputs="text")
|
47 |
iface.launch()
|