Fix: lazy torch import in inference.py — page loads without torch installed
Browse files- app/utils/inference.py +7 -1
app/utils/inference.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""PETIMOT inference utilities for custom proteins."""
|
| 2 |
-
import os, sys
|
| 3 |
import numpy as np
|
| 4 |
from pathlib import Path
|
| 5 |
|
|
@@ -24,9 +24,15 @@ def run_inference(pdb_path: str, weights_path: str, config_path: str = None,
|
|
| 24 |
Returns:
|
| 25 |
dict with modes, ca_coords, seq, etc.
|
| 26 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
from petimot.infer.infer import infer
|
| 28 |
from petimot.data.pdb_utils import load_backbone_coordinates
|
| 29 |
|
|
|
|
| 30 |
if config_path is None:
|
| 31 |
config_path = os.path.join(PETIMOT_ROOT, "configs", "default.yaml")
|
| 32 |
|
|
|
|
| 1 |
"""PETIMOT inference utilities for custom proteins."""
|
| 2 |
+
import os, sys
|
| 3 |
import numpy as np
|
| 4 |
from pathlib import Path
|
| 5 |
|
|
|
|
| 24 |
Returns:
|
| 25 |
dict with modes, ca_coords, seq, etc.
|
| 26 |
"""
|
| 27 |
+
try:
|
| 28 |
+
import torch
|
| 29 |
+
except ImportError:
|
| 30 |
+
raise ImportError("PyTorch is required to run inference. Install it with: pip install torch")
|
| 31 |
+
|
| 32 |
from petimot.infer.infer import infer
|
| 33 |
from petimot.data.pdb_utils import load_backbone_coordinates
|
| 34 |
|
| 35 |
+
|
| 36 |
if config_path is None:
|
| 37 |
config_path = os.path.join(PETIMOT_ROOT, "configs", "default.yaml")
|
| 38 |
|