MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / download

Function download

monai/bundle/scripts.py:446–625  ·  view source on GitHub ↗

download bundle from the specified source or url. The bundle should be a zip file and it will be extracted after downloading. This function refers to: https://pytorch.org/docs/stable/_modules/torch/hub.html Typical usage examples: .. code-block:: bash # Execute th

(
    name: str | None = None,
    version: str | None = None,
    bundle_dir: PathLike | None = None,
    source: str = DEFAULT_DOWNLOAD_SOURCE,
    repo: str | None = None,
    url: str | None = None,
    remove_prefix: str | None = "monai_",
    progress: bool = True,
    args_file: str | None = None,
)

Source from the content-addressed store, hash-verified

444
445
446def download(
447 name: str | None = None,
448 version: str | None = None,
449 bundle_dir: PathLike | None = None,
450 source: str = DEFAULT_DOWNLOAD_SOURCE,
451 repo: str | None = None,
452 url: str | None = None,
453 remove_prefix: str | None = "monai_",
454 progress: bool = True,
455 args_file: str | None = None,
456) -> None:
457 """
458 download bundle from the specified source or url. The bundle should be a zip file and it
459 will be extracted after downloading.
460 This function refers to:
461 https://pytorch.org/docs/stable/_modules/torch/hub.html
462
463 Typical usage examples:
464
465 .. code-block:: bash
466
467 # Execute this module as a CLI entry, and download bundle from the model-zoo repo:
468 python -m monai.bundle download --name <bundle_name> --version "0.1.0" --bundle_dir "./"
469
470 # Execute this module as a CLI entry, and download bundle from specified github repo:
471 python -m monai.bundle download --name <bundle_name> --source "github" --repo "repo_owner/repo_name/release_tag"
472
473 # Execute this module as a CLI entry, and download bundle from ngc with latest version:
474 python -m monai.bundle download --name <bundle_name> --source "ngc" --bundle_dir "./"
475
476 # Execute this module as a CLI entry, and download bundle from monaihosting with latest version:
477 python -m monai.bundle download --name <bundle_name> --source "monaihosting" --bundle_dir "./"
478
479 # Execute this module as a CLI entry, and download bundle from Hugging Face Hub:
480 python -m monai.bundle download --name "bundle_name" --source "huggingface_hub" --repo "repo_owner/repo_name"
481
482 # Execute this module as a CLI entry, and download bundle via URL:
483 python -m monai.bundle download --name <bundle_name> --url <url>
484
485 # Execute this module as a CLI entry, and download bundle from ngc_private with latest version:
486 python -m monai.bundle download --name <bundle_name> --source "ngc_private" --bundle_dir "./" --repo "org/org_name"
487
488 # Set default args of `run` in a JSON / YAML file, help to record and simplify the command line.
489 # Other args still can override the default args at runtime.
490 # The content of the JSON / YAML file is a dictionary. For example:
491 # {"name": "spleen", "bundle_dir": "download", "source": ""}
492 # then do the following command for downloading:
493 python -m monai.bundle download --args_file "args.json" --source "github"
494
495 Args:
496 name: bundle name. If `None` and `url` is `None`, it must be provided in `args_file`.
497 for example:
498 "spleen_ct_segmentation", "prostate_mri_anatomy" in model-zoo:
499 https://github.com/Project-MONAI/model-zoo/releases/tag/hosting_storage_v1.
500 "monai_brats_mri_segmentation" in ngc:
501 https://catalog.ngc.nvidia.com/models?filters=&orderBy=scoreDESC&query=monai.
502 version: version name of the target bundle to download, like: "0.1.0". If `None`, will download
503 the latest version (or the last commit to the `main` branch in the case of Hugging Face Hub).

Callers 5

test_dataset_trackingMethod · 0.90
test_download_ngcMethod · 0.90
loadFunction · 0.85

Calls 15

_basenameFunction · 0.90
download_urlFunction · 0.90
extractallFunction · 0.90
update_kwargsFunction · 0.85
_log_input_summaryFunction · 0.85
_pop_argsFunction · 0.85
_process_bundle_dirFunction · 0.85
_get_ngc_tokenFunction · 0.85
_download_from_githubFunction · 0.85

Tested by 4

test_dataset_trackingMethod · 0.72
test_download_ngcMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…