Spaces:
Sleeping
Sleeping
Publish CardioSafe Gradio demo
Browse files
app.py
CHANGED
|
@@ -48,6 +48,28 @@ import gradio as gr
|
|
| 48 |
import pandas as pd
|
| 49 |
import torch
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
from inference.ensemble import load_ensemble, load_l1000_encoder, predict # noqa: E402
|
| 52 |
from inference.featurize import featurize_batch # noqa: E402
|
| 53 |
from model.chemberta_encoder import ChemBERTaEncoder # noqa: E402
|
|
|
|
| 48 |
import pandas as pd
|
| 49 |
import torch
|
| 50 |
|
| 51 |
+
|
| 52 |
+
def _ensure_torch_scatter() -> None:
|
| 53 |
+
"""MolGpKa loads `torch_scatter` at module import. The matching wheel
|
| 54 |
+
URL is torch-version-specific (PyG hosts them at data.pyg.org), so we
|
| 55 |
+
install it at boot rather than in requirements.txt."""
|
| 56 |
+
try:
|
| 57 |
+
import torch_scatter # noqa: F401
|
| 58 |
+
return
|
| 59 |
+
except ImportError:
|
| 60 |
+
pass
|
| 61 |
+
torch_ver = torch.__version__.split("+")[0]
|
| 62 |
+
wheel_index = f"https://data.pyg.org/whl/torch-{torch_ver}+cpu.html"
|
| 63 |
+
print(f" installing torch_scatter for torch=={torch_ver} from {wheel_index}")
|
| 64 |
+
subprocess.run(
|
| 65 |
+
[sys.executable, "-m", "pip", "install", "--quiet",
|
| 66 |
+
"torch_scatter", "-f", wheel_index],
|
| 67 |
+
check=True,
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
_ensure_torch_scatter()
|
| 72 |
+
|
| 73 |
from inference.ensemble import load_ensemble, load_l1000_encoder, predict # noqa: E402
|
| 74 |
from inference.featurize import featurize_batch # noqa: E402
|
| 75 |
from model.chemberta_encoder import ChemBERTaEncoder # noqa: E402
|