Spaces:
Running
Running
| # paths.py | |
| import os | |
| def model_source(local_path: str, hub_id: str) -> str: | |
| """Resolve where to load a pretrained model from. | |
| The Dockerfile bakes these models into the image at build time, so in the | |
| container we load from disk and never touch the network. Outside the | |
| container those paths do not exist, so fall back to the Hub. | |
| This used to be a hand-set `runAsContainer` flag, which was easy to get | |
| wrong: it was left False in main.py, so the Space re-downloaded from the | |
| Hub on every boot despite having baked copies sitting on disk. | |
| """ | |
| resolved = local_path if os.path.isdir(local_path) else hub_id | |
| print(f"📦 {hub_id} -> {resolved}") | |
| return resolved | |