def list(github, force_reload=False, skip_validation=False):
r"""
- List all entrypoints available in `github` hubconf.
+ List all callable entrypoints available in the repo specified by ``github``.
Args:
github (string): a string with format "repo_owner/repo_name[:tag_name]" with an optional
- tag/branch. The default branch is `master` if not specified.
+ tag/branch. The default branch is ``master`` if not specified.
Example: 'pytorch/vision[:hub]'
force_reload (bool, optional): whether to discard the existing cache and force a fresh download.
- Default is `False`.
- skip_validation (bool, optional): whether to check package validity against github.
- Default is `False`.
+ Default is ``False``.
+ skip_validation (bool, optional): if ``False``, torchhub will check that the branch or commit
+ specified by the ``github`` argument properly belongs to the repo owner. This will make
+ requests to the GitHub API; you can specify a non-default GitHub token by setting the
+ ``GITHUB_TOKEN`` environment variable. Default is ``False``.
Returns:
- entrypoints: a list of available entrypoint names
+ list: The available callables entrypoint
Example:
>>> entrypoints = torch.hub.list('pytorch/vision', force_reload=True)
def help(github, model, force_reload=False, skip_validation=False):
r"""
- Show the docstring of entrypoint `model`.
+ Show the docstring of entrypoint ``model``.
Args:
github (string): a string with format <repo_owner/repo_name[:tag_name]> with an optional
- tag/branch. The default branch is `master` if not specified.
+ tag/branch. The default branch is ``master`` if not specified.
Example: 'pytorch/vision[:hub]'
- model (string): a string of entrypoint name defined in repo's hubconf.py
+ model (string): a string of entrypoint name defined in repo's ``hubconf.py``
force_reload (bool, optional): whether to discard the existing cache and force a fresh download.
- Default is `False`.
- skip_validation (bool, optional): whether to check package validity against github.
- Default is `False`.
+ Default is ``False``.
+ skip_validation (bool, optional): if ``False``, torchhub will check that the branch or commit
+ specified by the ``github`` argument properly belongs to the repo owner. This will make
+ requests to the GitHub API; you can specify a non-default GitHub token by setting the
+ ``GITHUB_TOKEN`` environment variable. Default is ``False``.
Example:
>>> print(torch.hub.help('pytorch/vision', 'resnet18', force_reload=True))
"""
Note: Loading a model is the typical use case, but this can also be used to
for loading other objects such as tokenizers, loss functions, etc.
- If :attr:`source` is ``'github'``, :attr:`repo_or_dir` is expected to be
+ If ``source`` is 'github', ``repo_or_dir`` is expected to be
of the form ``repo_owner/repo_name[:tag_name]`` with an optional
tag/branch. The default branch is ``master`` if not specified.
- If :attr:`source` is ``'local'``, :attr:`repo_or_dir` is expected to be a
+ If ``source`` is 'local', ``repo_or_dir`` is expected to be a
path to a local directory.
Args:
``source = 'local'``.
model (string): the name of a callable (entrypoint) defined in the
repo/dir's ``hubconf.py``.
- *args (optional): the corresponding args for callable :attr:`model`.
- source (string, optional): ``'github'`` | ``'local'``. Specifies how
- ``repo_or_dir`` is to be interpreted. Default is ``'github'``.
+ *args (optional): the corresponding args for callable ``model``.
+ source (string, optional): 'github' or 'local'. Specifies how
+ ``repo_or_dir`` is to be interpreted. Default is 'github'.
force_reload (bool, optional): whether to force a fresh download of
the github repo unconditionally. Does not have any effect if
``source = 'local'``. Default is ``False``.
local caches. Note that the message about first download cannot be
muted. Does not have any effect if ``source = 'local'``.
Default is ``True``.
- skip_validation (bool, optional): whether to check package validity against github.
- Default is `False`.
- **kwargs (optional): the corresponding kwargs for callable
- :attr:`model`.
+ skip_validation (bool, optional): if ``False``, torchhub will check that the branch or commit
+ specified by the ``github`` argument properly belongs to the repo owner. This will make
+ requests to the GitHub API; you can specify a non-default GitHub token by setting the
+ ``GITHUB_TOKEN`` environment variable. Default is ``False``.
+ **kwargs (optional): the corresponding kwargs for callable ``model``.
Returns:
- The output of the :attr:`model` callable when called with the given
+ The output of the ``model`` callable when called with the given
``*args`` and ``**kwargs``.
Example:
hubconf_dir (string): path to a local directory that contains a
``hubconf.py``.
model (string): name of an entrypoint defined in the directory's
- `hubconf.py`.
+ ``hubconf.py``.
*args (optional): the corresponding args for callable ``model``.
**kwargs (optional): the corresponding kwargs for callable ``model``.
Args:
url (string): URL of the object to download
- dst (string): Full path where object will be saved, e.g. `/tmp/temporary_file`
- hash_prefix (string, optional): If not None, the SHA256 downloaded file should start with `hash_prefix`.
+ dst (string): Full path where object will be saved, e.g. ``/tmp/temporary_file``
+ hash_prefix (string, optional): If not None, the SHA256 downloaded file should start with ``hash_prefix``.
Default: None
progress (bool, optional): whether or not to display a progress bar to stderr
Default: True
If the object is already present in `model_dir`, it's deserialized and
returned.
- The default value of `model_dir` is ``<hub_dir>/checkpoints`` where
- `hub_dir` is the directory returned by :func:`~torch.hub.get_dir`.
+ The default value of ``model_dir`` is ``<hub_dir>/checkpoints`` where
+ ``hub_dir`` is the directory returned by :func:`~torch.hub.get_dir`.
Args:
url (string): URL of the object to download
digits of the SHA256 hash of the contents of the file. The hash is used to
ensure unique names and to verify the contents of the file.
Default: False
- file_name (string, optional): name for the downloaded file. Filename from `url` will be used if not set.
+ file_name (string, optional): name for the downloaded file. Filename from ``url`` will be used if not set.
Example:
>>> state_dict = torch.hub.load_state_dict_from_url('https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth')