Spaces:
Sleeping
Sleeping
Witold Wydmański
commited on
Commit
•
3f2e816
1
Parent(s):
5cce9a4
feat: add instructions
Browse files
app.py
CHANGED
@@ -38,10 +38,40 @@ def fold_prot_locally(sequence):
|
|
38 |
pdb = convert_outputs_to_pdb(output)
|
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 |
-
|
|
|
|
38 |
pdb = convert_outputs_to_pdb(output)
|
39 |
return pdb
|
40 |
|
41 |
+
sample_code = """
|
42 |
+
## Sample usage
|
43 |
+
|
44 |
+
```python
|
45 |
+
from gradio_client import Client
|
46 |
+
|
47 |
+
client = Client("https://wwydmanski-esmfold.hf.space/")
|
48 |
+
|
49 |
+
def fold_huggingface(sequence, fname=None):
|
50 |
+
result = client.predict(
|
51 |
+
sequence, # str in 'sequence' Textbox component
|
52 |
+
api_name="/predict")
|
53 |
+
result = eval(result)[0]
|
54 |
+
if fname is None:
|
55 |
+
with tempfile.NamedTemporaryFile("w", delete=False, suffix=".pdb", prefix="esmfold_") as fp:
|
56 |
+
fp.write(result)
|
57 |
+
fp.flush()
|
58 |
+
return fp.name
|
59 |
+
else:
|
60 |
+
with open(fname, "w") as fp:
|
61 |
+
fp.write(result)
|
62 |
+
fp.flush()
|
63 |
+
return fname
|
64 |
+
|
65 |
+
pdb_fname = fold_huggingface("MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN")
|
66 |
+
|
67 |
+
```
|
68 |
+
"""
|
69 |
+
|
70 |
tokenizer = AutoTokenizer.from_pretrained("facebook/esmfold_v1")
|
71 |
model = EsmForProteinFolding.from_pretrained("facebook/esmfold_v1", low_cpu_mem_usage=True).cuda()
|
72 |
model.esm = model.esm.half()
|
73 |
torch.backends.cuda.matmul.allow_tf32 = True
|
74 |
|
75 |
+
iface = gr.Interface(fn=fold_prot_locally, inputs="text", outputs="text", article=sample_code, title="ESMFold")
|
76 |
+
|
77 |
+
iface.launch()
|