Sync from GitHub (preserve manual model files)
Browse files
PeptideAI/StreamlitApp/utils/predict.py
CHANGED
|
@@ -44,7 +44,15 @@ def _get_env(key: str) -> Optional[str]:
|
|
| 44 |
def load_model():
|
| 45 |
# Always resolve relative to the StreamlitApp folder, not the process CWD.
|
| 46 |
streamlitapp_dir = pathlib.Path(__file__).resolve().parent.parent
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# If the model file doesn't exist, try to download it from a configured URL
|
| 50 |
if not model_path.exists():
|
|
|
|
| 44 |
def load_model():
|
| 45 |
# Always resolve relative to the StreamlitApp folder, not the process CWD.
|
| 46 |
streamlitapp_dir = pathlib.Path(__file__).resolve().parent.parent
|
| 47 |
+
repo_root = streamlitapp_dir.parent.parent
|
| 48 |
+
|
| 49 |
+
# Prefer a manually uploaded Space file at repo root: models/ampMLModel.pt
|
| 50 |
+
# (This survives Space restarts, but NOT a force-sync overwrite.)
|
| 51 |
+
candidates = [
|
| 52 |
+
repo_root / "models" / "ampMLModel.pt",
|
| 53 |
+
streamlitapp_dir / "models" / "ampMLModel.pt",
|
| 54 |
+
]
|
| 55 |
+
model_path = next((p for p in candidates if p.exists()), candidates[0])
|
| 56 |
|
| 57 |
# If the model file doesn't exist, try to download it from a configured URL
|
| 58 |
if not model_path.exists():
|
StreamlitApp/utils/predict.py
CHANGED
|
@@ -44,7 +44,13 @@ def _get_env(key: str) -> Optional[str]:
|
|
| 44 |
def load_model():
|
| 45 |
# Always resolve relative to the StreamlitApp folder, not the process CWD.
|
| 46 |
streamlitapp_dir = pathlib.Path(__file__).resolve().parent.parent
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# If the model file doesn't exist, try to download it from a configured URL
|
| 50 |
if not model_path.exists():
|
|
|
|
| 44 |
def load_model():
|
| 45 |
# Always resolve relative to the StreamlitApp folder, not the process CWD.
|
| 46 |
streamlitapp_dir = pathlib.Path(__file__).resolve().parent.parent
|
| 47 |
+
repo_root = streamlitapp_dir.parent
|
| 48 |
+
|
| 49 |
+
candidates = [
|
| 50 |
+
repo_root / "models" / "ampMLModel.pt",
|
| 51 |
+
streamlitapp_dir / "models" / "ampMLModel.pt",
|
| 52 |
+
]
|
| 53 |
+
model_path = next((p for p in candidates if p.exists()), candidates[0])
|
| 54 |
|
| 55 |
# If the model file doesn't exist, try to download it from a configured URL
|
| 56 |
if not model_path.exists():
|