Skip to content

Commit 68f1ddd

Browse files
committed
abstract CDN URL
1 parent e0bb33a commit 68f1ddd

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

.claude/settings.local.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(du -sh:*)",
5+
"Bash(du:*)"
6+
],
7+
"deny": [],
8+
"ask": []
9+
}
10+
}

docs/onnx.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ All of the machine learning models are hosted on GitHub as LFS files. The two m
77
however need those files downloaded to the local machine prior to running inference. These models are
88
hosted on a separate CDN for convenient access and can be fetched by running the following functions:
99

10+
.. note::
11+
12+
The model download URL can be configured via the ``SCOUTBOT_MODEL_URL`` environment variable.
13+
This allows organizations to host models on their own infrastructure. For example:
14+
15+
.. code-block:: bash
16+
17+
export SCOUTBOT_MODEL_URL="https://your-cdn.example.com/models"
18+
19+
Similarly, test data URLs can be configured via ``SCOUTBOT_DATA_URL``.
20+
1021
- :meth:`scoutbot.wic.fetch`
1122
- :meth:`scoutbot.loc.fetch`
1223

scoutbot/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
# nms_thresh=agg_nms_thresh, # Optional override of config
5050
)
5151
'''
52+
import os
5253
import cv2
5354
from os.path import exists
5455

@@ -60,6 +61,14 @@
6061
log = utils.init_logging()
6162
QUIET = not utils.VERBOSE
6263

64+
# Base URLs for downloading models and data (can be overridden via environment variables)
65+
MODEL_BASE_URL = os.getenv(
66+
'SCOUTBOT_MODEL_URL', 'https://wildbookiarepository.azureedge.net/models'
67+
).rstrip('/')
68+
DATA_BASE_URL = os.getenv(
69+
'SCOUTBOT_DATA_URL', 'https://wildbookiarepository.azureedge.net/data'
70+
).rstrip('/')
71+
6372

6473
from scoutbot import agg, loc, tile, wic, tile_batched # NOQA
6574
from scoutbot.loc import CONFIGS as LOC_CONFIGS # NOQA
@@ -491,7 +500,7 @@ def example():
491500
)
492501

493502
img_filepath = pooch.retrieve(
494-
url=f'https://wildbookiarepository.azureedge.net/data/{TEST_IMAGE}',
503+
url=f'{DATA_BASE_URL}/{TEST_IMAGE}',
495504
known_hash=TEST_IMAGE_HASH,
496505
progressbar=True,
497506
)

scoutbot/loc/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import tqdm
2222
import utool as ut
2323

24-
from scoutbot import QUIET, log
24+
from scoutbot import MODEL_BASE_URL, QUIET, log
2525
from scoutbot.loc.transforms import (
2626
Compose,
2727
GetBoundingBoxes,
@@ -172,7 +172,7 @@ def fetch(pull=False, config=DEFAULT_CONFIG):
172172
onnx_model = model_path
173173
else:
174174
onnx_model = pooch.retrieve(
175-
url=f'https://wildbookiarepository.azureedge.net/models/{model_name}',
175+
url=f'{MODEL_BASE_URL}/{model_name}',
176176
known_hash=model_hash,
177177
progressbar=not QUIET,
178178
)

scoutbot/wic/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import torch
1919
import tqdm
2020

21-
from scoutbot import QUIET, log
21+
from scoutbot import MODEL_BASE_URL, QUIET, log
2222
from scoutbot.wic.dataloader import ( # NOQA
2323
BATCH_SIZE,
2424
INPUT_SIZE,
@@ -82,7 +82,7 @@ def fetch(pull=False, config=DEFAULT_CONFIG):
8282
onnx_model = model_path
8383
else:
8484
onnx_model = pooch.retrieve(
85-
url=f'https://wildbookiarepository.azureedge.net/models/{model_name}',
85+
url=f'{MODEL_BASE_URL}/{model_name}',
8686
known_hash=model_hash,
8787
progressbar=not QUIET,
8888
)

0 commit comments

Comments
 (0)