trtutils.download package¶
Module contents¶
Submodule for downloading and converting models to ONNX.
Functions¶
download()Download a model by name and save to a location.
download_model()Lower-level function for downloading and converting a model to ONNX.
get_supported_models()Return a list of supported model names.
Note:¶
All models downloaded through this module may have license restrictions. Users must ensure they comply with the model’s license terms.
- trtutils.download.download(model: str, output: Path, opset: int = 17, imgsz: int | None = None, requirements_export: Path | None = None, *, simplify: Sequence[str] | bool | None = None, make_static: bool | None = None, no_cache: bool | None = None, no_uv_cache: bool | None = None, no_warn: bool | None = None, verbose: bool | None = None) None[source]¶
Download a model from remote source and convert to ONNX.
- Parameters:
model (str) – The name of the model to download.
output (Path) – The path to save the model.
opset (int, optional) – The ONNX opset version to use.
imgsz (int, optional) – The image size to use for the model. By default, the model will use the default image size for the model.
requirements_export (Path, optional) – Export the created virtual environment’s requirements to this path using uv pip freeze.
simplify (Sequence[str] or bool, optional) – Whether and how to simplify the model after exporting. If True, uses default tools (polygraphy, onnxslim). If a sequence of tool names, runs those tools in the given order. Valid tool names: “polygraphy”, “onnxslim”, “onnxsim”. If False or None, no simplification is performed.
make_static (bool, optional) – Set any dynamic dimensions in the ONNX model to fixed values (e.g. batch size to 1). If True, all dynamic or symbolic dimensions are replaced with a static value of 1. If False or None, no modification is performed.
no_cache (bool, optional) – Whether to disable caching of downloaded weights and repos.
no_uv_cache (bool, optional) – Whether to disable caching of uv packages.
no_warn (bool, optional) – Whether to disable warnings for the model.
verbose (bool, optional) – Whether to print verbose output.
- trtutils.download.download_model(model: str, directory: Path, opset: int = 17, imgsz: int | None = None, requirements_export: Path | None = None, *, simplify: Sequence[str] | bool | None = None, make_static: bool | None = None, no_cache: bool | None = None, no_uv_cache: bool | None = None, no_warn: bool | None = None, verbose: bool | None = None) Path[source]¶
Download a model from remote source and convert to ONNX.
- Parameters:
model (str) – The name of the model to download.
directory (Path) – The directory to save the model and working files.
opset (int, optional) – The ONNX opset version to use.
imgsz (int, optional) – The image size to use for the model. By default, the model will use the default image size for the model.
requirements_export (Path, optional) – Export the created virtual environment’s requirements to this path using uv pip freeze.
simplify (Sequence[str] or bool, optional) – Whether and how to simplify the model after exporting. If True, uses default tools (polygraphy, onnxslim). If a sequence of tool names, runs those tools in the given order. Valid tool names: “polygraphy”, “onnxslim”, “onnxsim”. If False or None, no simplification is performed.
make_static (bool, optional) – Set any dynamic dimensions in the ONNX model to fixed values (e.g. batch size to 1). If True, all dynamic or symbolic dimensions are replaced with a static value of 1. If False or None, no modification is performed.
no_cache (bool, optional) – Whether to disable caching of downloaded weights and repos.
no_uv_cache (bool, optional) – Whether to disable caching of uv packages.
no_warn (bool, optional) – Whether to disable warnings for the model.
verbose (bool, optional) – Whether to print verbose output.
- Returns:
The path to the exported model inside the directory.
- Return type:
Path
- Raises:
ValueError – If the model is not supported.