Spaces:
Runtime error
Runtime error
Commit
·
f32d2f3
1
Parent(s):
ac5a470
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ import moleculekit
|
|
| 21 |
print(moleculekit.__version__)
|
| 22 |
|
| 23 |
|
| 24 |
-
def update(inp, file, mode, custom_resids, clustering_threshold, distance_cutoff):
|
| 25 |
try:
|
| 26 |
filepath = file.name
|
| 27 |
except:
|
|
@@ -70,18 +70,9 @@ def update(inp, file, mode, custom_resids, clustering_threshold, distance_cutoff
|
|
| 70 |
"Error",
|
| 71 |
f"""<div class="text-center mt-4"> Something went wrong with the voxelization, reset custom residues and other input fiels and check error message <br> <br> <code>{e}</code></div>""",
|
| 72 |
)
|
| 73 |
-
|
| 74 |
voxels.to(device)
|
| 75 |
|
| 76 |
-
model = Model()
|
| 77 |
-
model.to(device)
|
| 78 |
-
model.load_state_dict(
|
| 79 |
-
torch.load(
|
| 80 |
-
"weights/metal_0.5A_v3_d0.2_16Abox.pth",
|
| 81 |
-
map_location=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
|
| 82 |
-
)
|
| 83 |
-
)
|
| 84 |
-
model.eval()
|
| 85 |
with warnings.catch_warnings():
|
| 86 |
warnings.filterwarnings("ignore")
|
| 87 |
output = model(voxels)
|
|
@@ -108,7 +99,8 @@ def update(inp, file, mode, custom_resids, clustering_threshold, distance_cutoff
|
|
| 108 |
threshold=distance_cutoff,
|
| 109 |
p=clustering_threshold,
|
| 110 |
)
|
| 111 |
-
|
|
|
|
| 112 |
return message, molecule(
|
| 113 |
filepath,
|
| 114 |
f"output/probes_{identifier}.pdb",
|
|
@@ -324,7 +316,17 @@ def set_examples(example):
|
|
| 324 |
n, code, resids = example
|
| 325 |
return [n, code, resids]
|
| 326 |
|
| 327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
metal3d = gr.Blocks()
|
| 329 |
|
| 330 |
with metal3d:
|
|
@@ -389,7 +391,7 @@ with metal3d:
|
|
| 389 |
mol = gr.HTML()
|
| 390 |
btn.click(
|
| 391 |
fn=update,
|
| 392 |
-
inputs=[inp, file, mode, custom_resids, clustering_threshold, distance_cutoff],
|
| 393 |
outputs=[out, mol],
|
| 394 |
)
|
| 395 |
|
|
|
|
| 21 |
print(moleculekit.__version__)
|
| 22 |
|
| 23 |
|
| 24 |
+
def update(inp, file, mode, custom_resids, clustering_threshold, distance_cutoff,model, device):
|
| 25 |
try:
|
| 26 |
filepath = file.name
|
| 27 |
except:
|
|
|
|
| 70 |
"Error",
|
| 71 |
f"""<div class="text-center mt-4"> Something went wrong with the voxelization, reset custom residues and other input fiels and check error message <br> <br> <code>{e}</code></div>""",
|
| 72 |
)
|
| 73 |
+
|
| 74 |
voxels.to(device)
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
with warnings.catch_warnings():
|
| 77 |
warnings.filterwarnings("ignore")
|
| 78 |
output = model(voxels)
|
|
|
|
| 99 |
threshold=distance_cutoff,
|
| 100 |
p=clustering_threshold,
|
| 101 |
)
|
| 102 |
+
del voxels
|
| 103 |
+
torch.cuda.empty_cache()
|
| 104 |
return message, molecule(
|
| 105 |
filepath,
|
| 106 |
f"output/probes_{identifier}.pdb",
|
|
|
|
| 316 |
n, code, resids = example
|
| 317 |
return [n, code, resids]
|
| 318 |
|
| 319 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 320 |
+
model = Model()
|
| 321 |
+
model.to(device)
|
| 322 |
+
model.load_state_dict(
|
| 323 |
+
torch.load(
|
| 324 |
+
"weights/metal_0.5A_v3_d0.2_16Abox.pth",
|
| 325 |
+
map_location=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
|
| 326 |
+
)
|
| 327 |
+
)
|
| 328 |
+
model.eval()
|
| 329 |
+
|
| 330 |
metal3d = gr.Blocks()
|
| 331 |
|
| 332 |
with metal3d:
|
|
|
|
| 391 |
mol = gr.HTML()
|
| 392 |
btn.click(
|
| 393 |
fn=update,
|
| 394 |
+
inputs=[inp, file, mode, custom_resids, clustering_threshold, distance_cutoff, model, device],
|
| 395 |
outputs=[out, mol],
|
| 396 |
)
|
| 397 |
|