onnx.hub¶
- class onnx.hub.ModelInfo(raw_model_info: Dict[str, Any])¶
A class to represent a model’s property and metadata in the ONNX Hub. It extracts model name, path, sha, tags, etc. from the passed in raw_model_info dict.
- model¶
The name of the model.
- model_path¶
The path to the model, relative to the model zoo (https://github.com/onnx/models/) repo root.
- metadata¶
Additional metadata of the model, such as the size of the model, IO ports, etc.
- model_sha¶
The SHA256 digest of the model file.
- tags¶
A set of tags associated with the model.
- opset¶
The opset version of the model.
- Parameters
raw_model_info – A JSON dict containing the model info.
- onnx.hub.list_models(repo: str = 'onnx/models:main', model: Optional[str] = None, tags: Optional[List[str]] = None) List[onnx.hub.ModelInfo] ¶
Gets the list of model info consistent with a given name and tags
- Parameters
repo – The location of the model repo in format “user/repo[:branch]”. If no branch is found will default to “main”
model – The name of the model to search for. If None, will return all models with matching tags.
tags – A list of tags to filter models by. If None, will return all models with matching name.
- onnx.hub.get_model_info(model: str, repo: str = 'onnx/models:main', opset: Optional[int] = None) onnx.hub.ModelInfo ¶
Gets the model info matching the given name and opset.
- Parameters
model – The name of the onnx model in the manifest. This field is case-sensitive
repo – The location of the model repo in format “user/repo[:branch]”. If no branch is found will default to “main”
opset – The opset of the model to get. The default of None will return the model with largest opset.
- onnx.hub.load(model: str, repo: str = 'onnx/models:main', opset: Optional[int] = None, force_reload: bool = False, silent: bool = False) Optional[onnx.onnx_ml_pb2.ModelProto] ¶
Downloads a model by name from the onnx model hub
- Parameters
model – The name of the onnx model in the manifest. This field is case-sensitive
repo – The location of the model repo in format “user/repo[:branch]”. If no branch is found will default to “main”
opset – The opset of the model to download. The default of None automatically chooses the largest opset
force_reload – Whether to force the model to re-download even if its already found in the cache
silent – Whether to suppress the warning message if the repo is not trusted.