def load_model(cls, model_name: str, download: bool = True, with_data: bool = False, **kwargs) -> onnx.ModelProto:  # type:ignore
        """Load an ONNX model from the local cache or downloads it from Hugging Face if necessary.

        Args:
            model_name: The name of the ONNX model or operator. For Hugging Face-hosted models,
                use the format 'hf://model_name'. Valid `model_name` can be found on
                https://huggingface.co/kornia/ONNX_models.
                Or a URL to the ONNX model.
            download: If True, the model will be downloaded from Hugging Face if it's not already in the local cache.
            cache_dir: The directory where the model should be cached.
                Defaults to None, which will use a default `{kornia_config.hub_onnx_dir}` directory.
            with_data: If True, the model will be loaded with its `.onnx_data` weights.
            **kwargs: Additional arguments to pass to the download method, if needed.

        Returns:
            onnx.ModelProto: The loaded ONNX model.

        """
        if model_name.startswith("hf://"):
            model_name = model_name[len("hf://") :]
            url = f"https://huggingface.co/kornia/ONNX_models/resolve/main/{model_name}.onnx"
            cache_dir = kwargs.get("cache_dir", None) or os.path.join(
                kornia_config.hub_onnx_dir, model_name.split("/")[0]
            )
            kwargs.update({"cache_dir": cache_dir})
            file_path = cls.download_to_cache(
                url, model_name.split("/")[1], download=download, suffix=".onnx", **kwargs
            )
            if with_data:
                url_data = f"https://huggingface.co/kornia/ONNX_models/resolve/main/{model_name}.onnx_data"
                cls.download_to_cache(
                    url_data, model_name.split("/")[1], download=download, suffix=".onnx_data", **kwargs
                )
            return onnx.load(file_path)  # type:ignore

        elif model_name.startswith("http://") or model_name.startswith("https://"):
            cache_dir = kwargs.get("cache_dir", None) or kornia_config.hub_onnx_dir
            kwargs.update({"cache_dir": cache_dir})
            file_path = cls.download_to_cache(
                model_name,
                os.path.split(model_name)[-1],
                download=download,
                suffix=".onnx",
                **kwargs,
            )
            if with_data:
                url_data = model_name[:-5] + ".onnx_data"
                cls.download_to_cache(
                    url_data,
                    os.path.split(model_name)[-1][:-5] + ".onnx_data",
                    download=download,
                    suffix=".onnx_data",
                    **kwargs,
                )
            return onnx.load(file_path)  # type:ignore

        elif os.path.exists(model_name):
            return onnx.load(model_name)  # type:ignore

        raise ValueError(f"File {model_name} not found")
Load an ONNX model from the local cache or downloads it from Hugging Face if necessary.

        Args:
            model_name: The name of the ONNX model or operator. For Hugging Face-hosted models,
                use the format 'hf://model_name'. Valid `model_name` can be found on
                https://huggingface.co/kornia/ONNX_models.
                Or a URL to the ONNX model.
            download: If True, the model will be downloaded from Hugging Face if it's not already in the local cache.
            cache_dir: The directory where the model should be cached.
                Defaults to None, which will use a default `{kornia_config.hub_onnx_dir}` directory.
            with_data: If True, the model will be loaded with its `.onnx_data` weights.
            **kwargs: Additional arguments to pass to the download method, if needed.

        Returns:
            onnx.ModelProto: The loaded ONNX model.

        
kornia/onnx/utils.py