MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / load

Function load

imperative/python/megengine/hub/hub.py:149–182  ·  view source on GitHub ↗

r"""Loads model from github or gitlab repo, with pretrained weights. Args: repo_info: a string with format ``"repo_owner/repo_name[:tag_name/:branch_name]"`` with an optional tag/branch. The default branch is ``master`` if not specified. Eg: ``"brain_sdk/MegBrain[:hub]"``

(
    repo_info: str,
    entry: str,
    *args,
    git_host: str = DEFAULT_GIT_HOST,
    use_cache: bool = True,
    commit: str = None,
    protocol: str = DEFAULT_PROTOCOL,
    **kwargs
)

Source from the content-addressed store, hash-verified

147
148
149def load(
150 repo_info: str,
151 entry: str,
152 *args,
153 git_host: str = DEFAULT_GIT_HOST,
154 use_cache: bool = True,
155 commit: str = None,
156 protocol: str = DEFAULT_PROTOCOL,
157 **kwargs
158) -> Any:
159 r"""Loads model from github or gitlab repo, with pretrained weights.
160
161 Args:
162 repo_info: a string with format ``"repo_owner/repo_name[:tag_name/:branch_name]"`` with an optional
163 tag/branch. The default branch is ``master`` if not specified. Eg: ``"brain_sdk/MegBrain[:hub]"``
164 entry: an entrypoint defined in hubconf.
165 git_host: host address of git repo. Eg: github.com
166 use_cache: whether to use locally cached code or completely re-fetch.
167 commit: commit id on github or gitlab.
168 protocol: which protocol to use to get the repo, and HTTPS protocol only supports public repo on github.
169 The value should be one of HTTPS, SSH.
170
171 Returns:
172 a single model with corresponding pretrained weights.
173 """
174 hubmodule = _init_hub(repo_info, git_host, use_cache, commit, protocol)
175
176 if not hasattr(hubmodule, entry) or not callable(getattr(hubmodule, entry)):
177 raise RuntimeError("Cannot find callable {} in hubconf.py".format(entry))
178
179 _check_dependencies(hubmodule)
180
181 module = getattr(hubmodule, entry)(*args, **kwargs)
182 return module
183
184
185def help(

Callers 2

build_and_loadFunction · 0.50
metaMethod · 0.50

Calls 3

_init_hubFunction · 0.85
_check_dependenciesFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected