Spaces:
Runtime error
Runtime error
Update apps.py
Browse files
apps.py
CHANGED
|
@@ -3,6 +3,7 @@ from esm.models.esm3 import ESM3
|
|
| 3 |
from esm.sdk.api import ESM3InferenceClient, ESMProtein, GenerationConfig
|
| 4 |
import spaces
|
| 5 |
import os
|
|
|
|
| 6 |
from gradio_molecule3d import Molecule3D
|
| 7 |
|
| 8 |
|
|
@@ -15,6 +16,14 @@ login(TOKEN)
|
|
| 15 |
# This will download the model weights and instantiate the model on your machine.
|
| 16 |
model: ESM3InferenceClient = ESM3.from_pretrained("esm3_sm_open_v1").to("cuda")
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def molecule(input_pdb):
|
| 19 |
mol = read_mol(input_pdb)
|
| 20 |
|
|
@@ -83,7 +92,7 @@ def prediction(prompt, temperature, do_structure, enable_roundtrip):
|
|
| 83 |
protein = model.generate(protein, GenerationConfig(track="structure", num_steps=8))
|
| 84 |
protein.to_pdb("./round_tripped.pdb")
|
| 85 |
html1 = molecule("./round_tripped.pdb")
|
| 86 |
-
return seq, protein.
|
| 87 |
else:
|
| 88 |
html1 = "<h3>Inverse folding and re-generation not enabled</h3>"
|
| 89 |
f = open("./round_tripped.pdb", "w")
|
|
@@ -102,4 +111,4 @@ demo = gr.Interface(fn = prediction, inputs = [gr.Textbox(label="Masked protein
|
|
| 102 |
<h3 align='center'>Support this space with a ⭐ on <a href='https://github.com/AstraBert/proteins-w-esm'>GitHub</a></h3>
|
| 103 |
<h3 align='center'>Support Evolutionary Scale's ESM with a ⭐ on <a href='https://github.com/evolutionaryscale/esm'>GitHub</a></h3>""", examples = [["___________________________________________________DQATSLRILNNGHAFNVEFDDSQDKAVLKGGPLDGTYRLIQFHFHWGSLDGQGSEHTVDKKKYAAELHLVHWNTKYGDFGKAVQQPDGLAVLGIFLKVGSAKPGLQKVVDVLDSIKTKGKSADFTNFDPRGLLPESLDYWTYPGSLTTPP___________________________________________________________", 0.7, "No", "No"], ["__________________________________________________________AGQEEYSAMRDQYMRTGEGFLCVFAINNTKSFEDIHQYREQIKRVKDSDDVPMVLVGNKCDLAARTVESRQAQDLARSYGIPYIETSAKTRQGVEDAFYTLVRE___________________________", 0.2, "Yes", "No"], ["__________KTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLH________", 0.5, "Yes", "Yes"]], cache_examples=False)
|
| 104 |
|
| 105 |
-
demo.launch()
|
|
|
|
| 3 |
from esm.sdk.api import ESM3InferenceClient, ESMProtein, GenerationConfig
|
| 4 |
import spaces
|
| 5 |
import os
|
| 6 |
+
import gradio as gr
|
| 7 |
from gradio_molecule3d import Molecule3D
|
| 8 |
|
| 9 |
|
|
|
|
| 16 |
# This will download the model weights and instantiate the model on your machine.
|
| 17 |
model: ESM3InferenceClient = ESM3.from_pretrained("esm3_sm_open_v1").to("cuda")
|
| 18 |
|
| 19 |
+
def read_mol(molpath):
|
| 20 |
+
with open(molpath, "r") as fp:
|
| 21 |
+
lines = fp.readlines()
|
| 22 |
+
mol = ""
|
| 23 |
+
for l in lines:
|
| 24 |
+
mol += l
|
| 25 |
+
return mol
|
| 26 |
+
|
| 27 |
def molecule(input_pdb):
|
| 28 |
mol = read_mol(input_pdb)
|
| 29 |
|
|
|
|
| 92 |
protein = model.generate(protein, GenerationConfig(track="structure", num_steps=8))
|
| 93 |
protein.to_pdb("./round_tripped.pdb")
|
| 94 |
html1 = molecule("./round_tripped.pdb")
|
| 95 |
+
return seq, protein.sequence, html, html1, "./generation.pdb", "./round_tripped.pdb"
|
| 96 |
else:
|
| 97 |
html1 = "<h3>Inverse folding and re-generation not enabled</h3>"
|
| 98 |
f = open("./round_tripped.pdb", "w")
|
|
|
|
| 111 |
<h3 align='center'>Support this space with a ⭐ on <a href='https://github.com/AstraBert/proteins-w-esm'>GitHub</a></h3>
|
| 112 |
<h3 align='center'>Support Evolutionary Scale's ESM with a ⭐ on <a href='https://github.com/evolutionaryscale/esm'>GitHub</a></h3>""", examples = [["___________________________________________________DQATSLRILNNGHAFNVEFDDSQDKAVLKGGPLDGTYRLIQFHFHWGSLDGQGSEHTVDKKKYAAELHLVHWNTKYGDFGKAVQQPDGLAVLGIFLKVGSAKPGLQKVVDVLDSIKTKGKSADFTNFDPRGLLPESLDYWTYPGSLTTPP___________________________________________________________", 0.7, "No", "No"], ["__________________________________________________________AGQEEYSAMRDQYMRTGEGFLCVFAINNTKSFEDIHQYREQIKRVKDSDDVPMVLVGNKCDLAARTVESRQAQDLARSYGIPYIETSAKTRQGVEDAFYTLVRE___________________________", 0.2, "Yes", "No"], ["__________KTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLH________", 0.5, "Yes", "Yes"]], cache_examples=False)
|
| 113 |
|
| 114 |
+
demo.launch()
|