-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
59 lines (42 loc) · 1.71 KB
/
__init__.py
File metadata and controls
59 lines (42 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import logging
import os
from huggingface_hub import snapshot_download
# Import constants from zoo.py to ensure consistency
from .zoo import OPERATIONS, IsaacModel
logger = logging.getLogger(__name__)
def download_model(model_name, model_path):
"""Downloads the model.
Args:
model_name: the name of the model to download, as declared by the
``base_name`` and optional ``version`` fields of the manifest
model_path: the absolute filename or directory to which to download the
model, as declared by the ``base_filename`` field of the manifest
"""
snapshot_download(repo_id=model_name, local_dir=model_path)
def load_model(model_name, model_path, **kwargs):
"""Loads the model.
Args:
model_path: the absolute filename or directory to which the model was
donwloaded, as declared by the ``base_filename`` field of the
manifest
**kwargs: optional keyword arguments that configure how the model
is loaded
Returns:
a :class:`fiftyone.core.models.Model`
"""
if not model_path or not os.path.isdir(model_path):
raise ValueError(
f"Invalid model_path: '{model_path}'. Please ensure the model has been downloaded "
"using fiftyone.zoo.download_zoo_model(...)"
)
logger.info(f"Loading Isaac-0.1 model from {model_path}")
# Create and return the model - operations specified at apply time
return IsaacModel(model_path=model_path, **kwargs)
def resolve_input(ctx):
"""Defines properties to collect the model's custom parameters.
Args:
ctx: an ExecutionContext
Returns:
a fiftyone.operators.types.Property
"""
pass