+
    åûj^  ã                  ó|  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t
^ RIHtHtHt ^ RIHtHtHt ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIHt ^ R	IHt . R!Ot]P>                  ! ] 4      t!Rt"R R lt#R R lt$R R lt%R R lt&R R lt'R R lt(R R lt) ! R R
]4      t*R R lt+R"R R llt,R R  lt-R# )#aD  Load ONNX models and configs without a session, and edit a ``ModelProto`` in place.

Which function or class to use:

- An ``onnx.ModelProto`` from a local file, a URL or an ``hf://`` name, a JSON config from a local file or an
  HTTP(S) URL, or the file paths of the Hugging Face repository: :class:`ONNXLoader`.
- The ``source``, ``version`` and other metadata entries of a model: :func:`add_metadata`.
- The input and output names of a model, such as the ``"input"`` and ``"output"`` that
  :class:`~kornia.onnx.sequential.ONNXSequential` connects: :func:`io_name_conversion`.
)ÚannotationsN)ÚAnyÚOptionalÚUnion)ÚquoteÚurlsplitÚ
urlunsplit)Úurlopen)Úkornia_config)Únumpy)Úonnx)ÚCachedDownloaderÚ
ONNXLoaderz!$&'()+,;=@[]~c               ó    € V ^8„  d   QhRRRR/# )é   ÚurlÚstrÚreturn© )Úformats   "ÚMC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\onnx\utils.pyÚ__annotate__r   ;   s   € ÷ #.ñ #.˜ð #. ñ #.ó    c           	     óH  € \        V 4      pVP                  P                  R4      Ev r#VR
9   d   \        V : R24      hVP                  pV'       g   \        V : R24      hRV9   d   RV R2pVP
                  e   V RVP
                   2p\        P                  ! RRP                  V4      ,           4      pVP                  \        V\        R7      .pYeP                  R4       Uu. uF  qw'       g   K  \        V\        R7      NK  	  up,          pVP                  '       dc   VP                  \        R4      \        P                  ! VP                  P!                  4       4      P#                  4       R	,          ,           4       RP                  . VOVN4      # u upi )a„  Return the name, relative to the cache directory, that :class:`ONNXLoader` caches ``url`` under.

The name is ``<scheme>/<host>[%3A<port>]/<directories of the URL's path>[/%3F<hash>]/<file name>``, under an
explicit ``cache_dir`` as under the default directory. Two URLs share a file only when they differ in nothing but
credentials, the fragment, ``.``, ``..`` or empty directories (resolved as RFC 3986 resolves them, which most
servers follow), or a ``.onnx`` / ``.json`` extension that one of them lacks. The scheme keeps a file fetched over
``http`` from being served for ``https``, and keeps URLs apart from the ``hf://`` folders in the same directory. A
query can name the file (``?id=...``, ``?ref=...``), so a URL with one is stored in a directory named after the
query's hash; the query itself is not part of any name, since ``?`` cannot be in a file name on Windows. The host
(an IPv6 address in its brackets) and the directories are percent-encoded (see ``_SAFE_DIRECTORY_CHARACTERS``),
and so are the ``:`` before the port and the ``?`` before the query's hash, which no host or directory of a URL
can become, as ``%`` itself is encoded: ``%3A8080`` is never a host and ``%3F<hash>`` never a directory of the
path. The file name is kept as it is, because a model refers to its ``.onnx_data`` weights by name.

Raises:
    ValueError: If the URL has no host, or its path does not end in a file name.
Ú/z/ does not end in a file name to cache it under.z has no host to cache it under.Ú:Ú[Ú])ÚsafeÚ?:Né   N)Ú Ú.z..)r   ÚpathÚsplitÚ
ValueErrorÚhostnameÚportÚ	posixpathÚnormpathÚjoinÚschemer   Ú_SAFE_DIRECTORY_CHARACTERSÚqueryÚappendÚhashlibÚsha256ÚencodeÚ	hexdigest)r   ÚpartsÚdirectoriesÚ	file_nameÚhostÚ	directoryÚ
componentsÚcs   &       r   Ú_url_cache_namer:   ;   sZ  € ô$ �S‹M€EØ#Ÿj™j×.Ñ.¨sÓ3Ñ€[Ø�OÔ#Ü˜C™7Ð"QÐRÓSÐSØ�>‰>€DßÜ˜C™7Ð"AÐBÓCÐCØ
ˆd„{Ø�4�&˜ˆ{ˆØ‡z�zÒØ��q˜Ÿ™˜Ð%ˆä×"Ò" 3¨¯©°+Ó)>Õ#>Ó?€IØ—,‘,¤ dÔ1KÔ LÐM€JØÇoÁoÐVYÔFZÓ`ÑFZÀÓ^_Ô<”5˜Ô!;×<ÑFZÑ`Õ`€JØ‡{‡{€{Ø×Ñœ% ›*¤w§~¢~°e·k±k×6HÑ6HÓ6JÓ'K×'UÑ'UÓ'WÐX[Õ'\Õ\Ô]Ø�8‰8Ð,�jÐ, )Ð,Ó-Ð-ùò as   Ã*	FÃ8Fc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úmethodr   Úkwargsúdict[str, Any]r   ÚNoner   )r   s   "r   r   r   a   s&   € ÷ Vñ V˜Cð V¨ð V¸Dñ Vr   c                óH   € V F  pVR8w  g   K  \        V  RV: 24      h	  R# )zÙRaise Python's ``TypeError`` for any keyword of ``method`` but ``cache_dir``, whichever branch it takes.

A local model, or a config URL that is not HTTP(S), never reaches ``download_to_cache``, which would raise it.
Ú	cache_dirz&() got an unexpected keyword argument N)Ú	TypeError)r<   r=   Úkeys   && r   Ú_check_keywordsrD   a   s-   € ó
 ˆØ�+ÖÜ˜v˜hÐ&LÈSÉGÐTÓUÐUó r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r<   r   Úvaluer   r   r   )r   s   "r   r   r   k   s&   € ÷ 
bñ 
b�sð 
b 3ð 
b¨3ñ 
br   c                ó"  € \        V\        P                  4      '       d   \        P                  ! V4      MTp\        V\        4      '       d   V# \        V\
        4      '       d   RMRp\        V  R\        V4      P                   RV 24      h)zúReturn the text of ``value``, a ``str`` or an :class:`os.PathLike` naming a ``str`` path.

Anything else raises ``TypeError``. ``bytes`` are not a path here: ONNX Runtime reads ``bytes`` as a serialized
model, so the message names the call for that.
z@ For a serialized model, pass onnx.load_model_from_string(data).r!   z$ takes a str or an os.PathLike, got r"   )	Ú
isinstanceÚosÚPathLikeÚfspathr   ÚbytesrB   ÚtypeÚ__name__)r<   rF   ÚtextÚhints   &&  r   Ú
_path_textrQ   k   sx   € ô  *¨%´·±×=Ò=Œ2�9Š9�UÔÀ5€DÜ�$œ×ÒØˆÜQ[Ð\`Ôbg×QhÒQhÑMÐnp€DÜ
�v�hÐBÄ4ÈÃ;×CWÑCWÐBXÐXYÐZ^ÐY_Ð`Ó
aÐar   c               ó    € V ^8„  d   QhRRRR/# )r   Únamer   r   r   )r   s   "r   r   r   x   s   € ÷ Vñ V˜#ð V #ñ Vr   c                ón   € V P                  R4      '       d   V R\        R4      )  R,           # T R,           # )zjReturn the name of the ``.onnx_data`` weights stored beside the model ``name``, with or without ``.onnx``.ú.onnxNú
.onnx_data)ÚendswithÚlen)rS   s   &r   Ú_onnx_data_namerY   x   s2   € à%)§]¡]°7×%;Ò%;ˆD�”C˜“L�=Ð!ÈÕUÐUÀÈÕUÐUr   c               ó    € V ^8„  d   QhRRRR/# )r   Ú	file_pathr   r   r   )r   s   "r   r   r   }   s   € ÷ ñ  ð ¨ñ r   c                ó   € RV  R2# )zCReturn what to do when the cached file ``file_path`` does not load.zIf the cached file `zi` is damaged, or was replaced by hand, pass force_download=True to download it again, or delete the file.r   )r[   s   &r   Ú_cached_file_hintr]   }   s   € ð ˜y˜kð *(ð 	(ðr   c               ó    € V ^8„  d   QhRRRR/# )r   r[   r   r   úonnx.ModelProtor   )r   s   "r   r   r   …   s   € ÷ ñ  ð ¨ñ r   c                ó¢   €  \         P                  ! V 4      #   \         d    h \         d!   pTP	                  \        T 4      4       h Rp?ii ; i)a)  Load the ONNX model cached at ``file_path``; the error for a file that does not load names the way out.

The error is raised as it is, so a caller that catches ``google.protobuf.message.DecodeError`` still does; the
hint is a note on it (:meth:`BaseException.add_note`), which a traceback prints.
N)r   ÚloadÚMemoryErrorÚ	ExceptionÚadd_noter]   )r[   Úexcs   & r   Ú_load_cached_onnxrf   …   sF   € ðÜ�yŠy˜Ó#Ð#øÜô ØÜô Ø�‰Ô& yÓ1Ô2Øûðús   ‚ ˜A­A®A	Á	Ac               ó    € V ^8„  d   QhRRRR/# )r   r[   r   r   r   r   )r   s   "r   r   r   ”   s   € ÷ ñ  ð ¨ñ r   c                ó  €  \        V R4      ;_uu_ 4       p\        P                  ! V4      uuRRR4       #   + '       g   i     R# ; i  \        P                  \        3 d!   pTP                  \        T 4      4       h Rp?ii ; i)a  Load the JSON cached at ``file_path``; the error for a file that does not parse names the way out.

The error is raised as it is, so a caller that catches ``json.JSONDecodeError`` still does; the hint is a note on
it (:meth:`BaseException.add_note`), which a traceback prints.
ÚrbN)ÚopenÚjsonra   ÚJSONDecodeErrorÚUnicodeDecodeErrorrd   r]   )r[   Úfre   s   &  r   Ú_load_cached_jsonro   ”   s`   € ðÜ�)˜T×"Ô" aÜ—9’9˜Q“<÷ #×"×"Ó"ûä× Ñ Ô"4Ð5ô Ø�‰Ô& yÓ1Ô2Øûðús1   ‚A –7¬
A ·A	ÁA ÁA ÁBÁ&BÂBc                  ó    € ] tR t^¢tRt]RRR/R R lll4       t]RRR/R R lll4       t]R R	 l4       t	]R
 R l4       t
]R R l4       tRtR# )r   aÿ  Load an ONNX model as a ``ModelProto`` or a JSON config as a ``dict``, without a session.

``model = ONNXLoader.load_model(name)`` takes a local file path, an HTTP(S) URL, or an ``hf://<folder>/<name>``
name of the `kornia/ONNX_models <https://huggingface.co/kornia/ONNX_models>`_ repository and returns the
``onnx.ModelProto``; ``config = ONNXLoader.load_config(url)`` returns a JSON file as a ``dict``. A download is
cached, and later calls use the cached file as it is unless ``force_download=True``. :meth:`list_operators` and
:meth:`list_models` print the repository's file paths; an ``hf://`` name is ``hf://`` and the path without
``.onnx``.

See Also:
    - :class:`~kornia.onnx.download.CachedDownloader`: the parent class, which caches any HTTP(S) file under a
      name the caller gives, without loading it.
    - :class:`~kornia.onnx.module.ONNXModule`: a model loaded the same way and run by an ONNX Runtime session.

Example:
    .. code-block:: python

        from kornia.onnx.utils import ONNXLoader

        # downloaded on the first call into .kornia_hub/onnx_models/operators/
        model = ONNXLoader.load_model("hf://operators/kornia.color.gray.GrayscaleToRgb")
        # the same file from the cache; download=False raises ValueError if it is not cached
        model = ONNXLoader.load_model("hf://operators/kornia.color.gray.GrayscaleToRgb", download=False)
        # a local file, by its path
        model = ONNXLoader.load_model(".kornia_hub/onnx_models/operators/kornia.color.gray.GrayscaleToRgb.onnx")

Úforce_downloadFc          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   r   úUnion[str, os.PathLike]ÚdownloadÚboolrq   r=   r   r   r>   r   )r   s   "r   r   ÚONNXLoader.__annotate__À   s4   € ÷ .
ñ .
Ø)ð.
Ø59ð.
ØUYð.
Ømpð.
à	ñ.
r   c          	     ór  € \        RV4       \        V\        P                  4      p\	        RV4      pV'       gd   VP                  R4      '       dM   VP                  R4      ;'       g    RVR&   V P                  ! V\        V4      3RVRRRV/VB p\        V4      # \        P                  P                  V4      p\        P                  P                  V4      '       d6   \        VR4      ;_uu_ 4       p\        P                  ! V4      uuRRR4       # \!        R	V R
24      h  + '       g   i     L; i)a®  Load JSON config from the specified URL or local file.

A config that is in the cache is used as it is, however old: pass ``force_download=True`` to fetch it again.

Args:
    url: The HTTP(S) URL of the preprocessor config to load, or the path of a local JSON file, which is read
        as it is: a ``str``, or an :class:`os.PathLike`, which always names a local file. A local path may
        start with ``~``.
    download: If True, the config will be downloaded if it's not already in the local cache. A local file
        is read either way.
    force_download: If True, fetch an HTTP(S) config again and replace the cached file, even when it is
        cached. Needs ``download=True``. It has no effect on a local file. Defaults to False.
    kwargs: Keyword arguments of ``CachedDownloader.download_to_cache``. Only ``cache_dir`` applies: the root
        the config is stored under, at ``<scheme>/<host>/<directories of the URL's path>/<file name>``, with a
        ``%3F<hash>`` directory before the file name when the URL has a query, as for ``load_model``. ``None``
        or ``""`` means ``kornia_config.hub_cache_dir``. Any other keyword raises ``TypeError``, whatever
        ``url`` is.

Returns:
    dict[str, Any]: The loaded preprocessor config.

Raises:
    RuntimeError: If ``url`` is neither an HTTP(S) URL nor an existing local file.
    TypeError: If ``url`` is not a ``str`` or an :class:`os.PathLike`; ``bytes`` raise it too.

zONNXLoader.load_configrA   Nrt   Úsuffixz.jsonrq   ri   Ú`z`` is neither an HTTP(S) URL nor an existing local file: ONNXLoader.load_config reads only those.)zhttp:zhttps:)rD   rH   rI   rJ   rQ   Ú
startswithÚgetÚdownload_to_cacher:   ro   r#   Ú
expanduserÚisfilerj   rk   ra   ÚRuntimeError)	Úclsr   rt   rq   r=   Úlocalr[   r#   rn   s	   &&&$,    r   Úload_configÚONNXLoader.load_config¿   s  € ô< 	Ð0°&Ô9Ü˜3¤§¡Ó,ˆÜÐ1°3Ó7ˆß˜Ÿ™Ð(;×<Ò<Ø"(§*¡*¨[Ó"9×"AÐ"A¸TˆF�;ÑØ×-Ò-Ø”_ SÓ)ñØ4<ðØELðØ]kðØouñˆIô % YÓ/Ð/ä�w‰w×!Ñ! #Ó&ˆÜ�7‰7�>‰>˜$×ÒÜ�d˜D×!Ô! QÜ—y’y “|÷ "Ò!ô Ø�ˆuÐtÐuó
ð 	
÷ "×!ús   Ã6D&Ä&D6	c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   Ú
model_namers   rt   ru   Ú	with_datarq   r   r_   r   )r   s   "r   r   rv   ñ   sC   € ÷ ]9ñ ]9à+ð]9ð ð]9ð ð	]9ð ð]9ð 
ñ]9r   c          	     óz  € \        RV4       \        V\        P                  4      p\	        RV4      pV'       g¼   VP                  R4      '       d¥   V\        R4      R pRV R2pVP                  R4      '       d   VP                  R4      ^,          pM\        P                  VR&   TpV P                  ! Wx3RVR	RR
V/VB p	V'       d    RV R2p
V P                  ! W¨3RVR	RR
V/VB  \        V	4      # V'       g×   VP                  R4      '       dÀ   \        V4      pVP                  R4      ;'       g    \        P                  VR&   V P                  ! W3RVR	RR
V/VB p	V'       d]   \        V4      p\        VP!                  \#        VP$                  4      R7      4      p
V P                  ! V
\#        V4      3RVR	RR
V/VB  \        V	4      # \        P$                  P'                  V4      p\        P$                  P)                  V4      '       d   \*        P,                  ! V4      # \/        RV R24      h)aH  Load an ONNX model as an ``onnx.ModelProto`` from a local file, a URL or an ``hf://`` name.

A model that is in the cache is used as it is, however old, and a cached file that does not load fails every
time: pass ``force_download=True`` to fetch it again, or delete the file.

Args:
    model_name: A local file path, an HTTP(S) URL, or an ``hf://<folder>/<name>`` name of the
        `kornia/ONNX_models <https://huggingface.co/kornia/ONNX_models>`_ repository. A ``str`` can be any
        of those; an :class:`os.PathLike` always names a local file. A local path may start with ``~``.
    download: If True, the model will be downloaded from Hugging Face if it's not already in the local cache.
    cache_dir: The root of the cache. An ``hf://`` model is stored under it at the path of its name after
        the folder (``<cache_dir>/a/b.onnx`` for ``hf://models/a/b``): the kornia/ONNX_models names are fully
        qualified (``kornia.color.gray.RgbToGrayscale``), so the folders never share a name. A URL is stored at
        ``<cache_dir>/<scheme>/<host>/<directories of the URL's path>/<file name>``, with a ``%3F<hash>``
        directory before the file name when the URL has a query, so that two URLs share a file only when they
        differ in nothing but credentials, the fragment, ``.``, ``..`` or empty directories, or an ``.onnx``
        extension that one of them lacks. Defaults to None (``""`` too): an ``hf://`` model goes to
        ``<kornia_config.hub_onnx_dir>/<folder>/``, and a URL under ``kornia_config.hub_onnx_dir``.
        Limitations: on Windows, a URL whose file name is not a valid file name there, or whose cache path
        is longer than ``MAX_PATH`` (260 characters) while long paths are disabled, cannot be cached, and
        neither can a directory with a reserved name (``con``); on a case-insensitive file system, URLs that
        differ only in letter case share a file.
    with_data: If True, the model will be loaded with its `.onnx_data` weights, stored beside the model.
    force_download: If True, fetch the model, and its `.onnx_data` weights with ``with_data``, again and
        replace the cached files, even when they are cached. A file is replaced only once its download is
        complete, so a download that fails leaves the cached one as it was. The model is replaced before the
        weights are fetched: if the weights then fail to download, the cache holds the new model with the old
        weights, so call again with ``force_download=True`` before loading it. Needs ``download=True``. It has
        no effect on a model given as a path to a local file, which is never downloaded. Defaults to False.
    **kwargs: Only ``cache_dir``; any other keyword raises ``TypeError``, whatever ``model_name`` is.

Returns:
    onnx.ModelProto: The loaded ONNX model.

Raises:
    TypeError: If ``model_name`` is not a ``str`` or an :class:`os.PathLike`; ``bytes`` raise it too.
    ValueError: If a local file does not exist, or ``download=False`` and the model is not cached; the
        ValueErrors of :meth:`~kornia.onnx.download.CachedDownloader.download_to_cache` as well.

zONNXLoader.load_modelzhf://Nz7https://huggingface.co/kornia/ONNX_models/resolve/main/rU   rA   r   rt   rx   rq   rV   )r#   zFile z
 not found)zhttp://zhttps://)rD   rH   rI   rJ   rQ   rz   rX   r{   Ú	partitionr
   Úhub_onnx_dirr|   rf   r:   r   r   Ú_replacerY   r#   r}   Úexistsr   ra   r%   )r€   r…   rt   r†   rq   r=   r�   r   rS   r[   Úurl_datar3   r#   s   &&&&$,       r   Ú
load_modelÚONNXLoader.load_modelð   sU  € ôd 	Ð/°Ô8Ü˜:¤r§{¡{Ó3ˆÜÐ 7¸ÓDˆ
ß˜×.Ñ.¨w×7Ò7Ø#¤C¨£L NÐ3ˆJØKÈJÈ<ÐW\Ð]ˆCØ�z‰z˜+×&Ò&Ø!×+Ñ+¨CÓ0°Õ3‘ä&3×&@Ñ&@��{Ñ#Ø!�Ø×-Ò-ØñØ$,ðØ5<ðØM[ðØ_eñˆI÷ ØTÐU_ÐT`Ð`jÐk�Ø×%Ò%ØñØ-5ðØ>JðØ[iðØmsòô % YÓ/Ð/ç˜×.Ñ.Ð/F×GÒGÜ" :Ó.ˆDØ"(§*¡*¨[Ó"9×"WÐ"W¼]×=WÑ=WˆF�;ÑØ×-Ò-ØñØ+3ðØ<CðØTbðØflñˆI÷ Ü  Ó,�Ü% e§n¡n¼/È%Ï*É*Ó:U nÓ&VÓW�Ø×%Ò%ØÜ# DÓ)ñð &ðð (ð	ð
 $2ðð òô % YÓ/Ð/ä�w‰w×!Ñ! *Ó-ˆÜ�7‰7�>‰>˜$×ÒÜ—9’9˜T“?Ð"ä˜5  ¨JÐ7Ó8Ð8r   c               ó    € V ^8„  d   QhRRRR/# )r   Úfolderr   r   zlist[dict[str, Any]]r   )r   s   "r   r   rv   Q  s   € ÷ Vñ V Sð VÐ-Añ Vr   c                ó>  € RV  2p \        V^
R7      ;_uu_ 4       p\        P                  ! VP                  4       4      uuRRR4       #   + '       g   i     R# ; i  \        P
                  P                   d   p\        RTP                   24      ThRp?ii ; i)z¬Fetch the contents of the Hugging Face repository using the Hugging Face API.

Returns:
    A list of all files in the repository as dictionaries containing file details.

z?https://huggingface.co/api/models/kornia/ONNX_models/tree/main/)ÚtimeoutNz%Failed to fetch repository contents: )	r	   rk   ÚloadsÚreadÚurllibÚerrorÚ	HTTPErrorr%   Úcode)r�   r   ÚresponseÚes   &   r   Ú_fetch_repo_contentsÚONNXLoader._fetch_repo_contentsP  s}   € ð PÐPVÈxÐXˆð	Vä˜ b×)Õ)¨XÜ—z’z (§-¡-£/Ó2÷ *×)×)Ó)ûä�|‰|×%Ñ%ô 	VÜÐDÀQÇVÁVÀHÐMÓNÐTUÐUûð	Vús4   ‡A œ$AÁ 
A ÁA	ÁA ÁA ÁBÁ>BÂBc               ó   € V ^8„  d   QhRR/# ©r   r   r?   r   )r   s   "r   r   rv   b  s   € ÷ ñ ˜tñ r   c                óŒ   € V P                  R4      pV Uu. uF  q"R,          NK  	  pp\        P                  ! V4       R# u upi )ziPrint, without returning them, the file paths in the ``operators`` folder of the Hugging Face repository.Ú	operatorsr#   N©r›   ÚpprintÚpp)r€   Úrepo_contentsÚfiler    s   &   r   Úlist_operatorsÚONNXLoader.list_operatorsa  s?   € ð ×0Ñ0°Ó=ˆñ /<Ó<©m d˜&—\�\©mˆ	Ð<ä�	Š	�)Öùò =ó   –Ac               ó   € V ^8„  d   QhRR/# rž   r   )r   s   "r   r   rv   l  s   € ÷ ñ ˜Dñ r   c                óŒ   € V P                  R4      pV Uu. uF  q"R,          NK  	  pp\        P                  ! V4       R# u upi )zfPrint, without returning them, the file paths in the ``models`` folder of the Hugging Face repository.Úmodelsr#   Nr¡   )r€   r¤   r¥   r«   s   &   r   Úlist_modelsÚONNXLoader.list_modelsk  s?   € ð ×0Ñ0°Ó:ˆñ ,9Ó9©= 4�v—,�,©=ˆÐ9ä�	Š	�&Öùò :r¨   r   N)T)TF)rN   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úclassmethodr‚   r�   Ústaticmethodr›   r¦   r¬   Ú__static_attributes__r   r   r   r   r   ¢   s„   † ñð8 ñ.
Ø\a÷.
ó ð.
ð` ñ]9ð  %÷]9ó ð]9ð~ ôVó ðVð  ôó ðð ôó ôr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Ú
onnx_modelr_   Úio_name_mappingzdict[str, str]r   r   )r   s   "r   r   r   v  s&   € ÷ .ñ .Øð.à#ð.ð ñ.r   c                ó  € \        \        V P                  P                  4      4       FZ  pV P                  P                  V,          P                  pW19   g   K2  W,          V P                  P                  V,          n        K\  	  \        \        V P                  P
                  4      4       FZ  pV P                  P
                  V,          P                  pWA9   g   K2  W,          V P                  P
                  V,          n        K\  	  \        \        V P                  P                  4      4       EFP  p\        \        V P                  P                  V,          P                  4      4       Fi  pV P                  P                  V,          P                  V,          pWa9   g   K9  W,          V P                  P                  V,          P                  V&   Kk  	  \        \        V P                  P                  V,          P
                  4      4       Fi  pV P                  P                  V,          P
                  V,          pWq9   g   K9  W,          V P                  P                  V,          P
                  V&   Kk  	  EKS  	  V # )aH  Rename the inputs and outputs of an ONNX model in place, as ``io_name_mapping`` maps them.

``model = io_name_conversion(model, {"pixel_values": "input", "predicted_depth": "output"})`` renames the graph
inputs and outputs and the node inputs and outputs named in the mapping. The mapping above gives the names
:class:`~kornia.onnx.sequential.ONNXSequential` connects without ``io_maps``.
Initializers, ``value_info`` and subgraphs (``If`` branches, ``Loop`` bodies) are not renamed, so do not map an
initializer's name.

Args:
    onnx_model: The ONNX model to rename.
    io_name_mapping: A dictionary mapping the original input and output names to the new ones.

Returns:
    The same ``onnx_model`` object, renamed.

See Also:
    - :class:`~kornia.onnx.sequential.ONNXSequential`: its ``io_maps`` connect any names, without renaming.

)ÚrangerX   ÚgraphÚinputrS   ÚoutputÚnode)r¶   r·   ÚiÚin_nameÚout_nameÚjÚnode_in_nameÚnode_out_names   &&      r   Úio_name_conversionrÄ   v  sÚ  € ô0 ”3�z×'Ñ'×-Ñ-Ó.Ö/ˆØ×"Ñ"×(Ñ(¨Õ+×0Ñ0ˆØÖ%Ø-<Õ-EˆJ×Ñ×"Ñ" 1Õ%Ö*ñ 0ô
 ”3�z×'Ñ'×.Ñ.Ó/Ö0ˆØ×#Ñ#×*Ñ*¨1Õ-×2Ñ2ˆØÖ&Ø.=Õ.GˆJ×Ñ×#Ñ# AÕ&Ö+ñ 1ô ”3�z×'Ñ'×,Ñ,Ó-×.ˆÜ”s˜:×+Ñ+×0Ñ0°Õ3×9Ñ9Ó:Ö;ˆAØ%×+Ñ+×0Ñ0°Õ3×9Ñ9¸!Õ<ˆLØÖ.Ø4CÕ4Q�
× Ñ ×%Ñ% aÕ(×.Ñ.¨qÓ1ñ <ô
 ”s˜:×+Ñ+×0Ñ0°Õ3×:Ñ:Ó;Ö<ˆAØ&×,Ñ,×1Ñ1°!Õ4×;Ñ;¸AÕ>ˆMØÖ/Ø5DÕ5S�
× Ñ ×%Ñ% aÕ(×/Ñ/°Ó2ô =ñ /ð Ðr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r¶   r_   Úadditional_metadatazOptional[list[tuple[str, str]]]r   r   )r   s   "r   r   r   §  s&   € ÷ &ñ &Øð&à8ð&ð ñ&r   c                ój  € Vf   . pV P                    Uu/ uF  q"P                  VP                  bK  	  ppRR\        P                  3.VO F  w  rE\        V4      W4&   K  	  V P                   R VP                  4        F+  w  rEV P                   P                  4       pWBn        WRn        K-  	  V # u upi )a›  Write ``source``, ``version`` and other metadata entries into an ONNX model, in place.

``model = add_metadata(model, [("key", "value")])`` sets ``source`` to ``"kornia"``, ``version`` to
``kornia.__version__``, then each given pair. A key that is already present in the model (or earlier in the
list) is overwritten rather than repeated, so a given ``("source", ...)`` replaces ``"kornia"``. Duplicate keys
already in the model are merged into one entry with the last value.

Args:
    onnx_model: The ONNX model to add metadata to.
    additional_metadata: A list of ``(key, value)`` tuples to add. Values are stored as strings, ``str(value)``.

Returns:
    ``onnx_model`` itself, with the added metadata.

See Also:
    - :meth:`~kornia.onnx.module.ONNXModule.add_metadata`: the same edit on the graph a module wraps.
    - :meth:`~kornia.onnx.sequential.ONNXSequential.add_metadata`: the same edit on a merged graph.

Úversion:NNN)ÚsourceÚkornia)Úmetadata_propsrC   rF   rÊ   Ú__version__r   ÚitemsÚadd)r¶   rÆ   rË   ÚmetadatarC   rF   s   &&    r   Úadd_metadatarÐ   §  sÂ   € ð. Ò"Ø ÐàOY×OhÒOhÓiÑOh¸^×"Ñ" N×$8Ñ$8Ò8ÑOh€HÐiàØ	”F×&Ñ&Ð'ðð 
ó‰
ˆô
 ˜E›
ˆ‹ñð 	×!Ñ! !Ð$Ø—n‘nÖ&‰
ˆØ#×2Ñ2×6Ñ6Ó8ˆØ ÔØ$Öñ 'ð Ðùò js   •B0c               ó    € V ^8„  d   QhRRRR/# )r   Ú	onnx_typer   r   r   r   )r   s   "r   r   r   Ð  s   € ÷ #ñ # #ð #¨#ñ #r   c                ó@  € R \         P                  R\         P                  R\         P                  R\         P                  R\         P
                  R\         P                  R\         P                  R\         P                  /pW9  d   \        RV  R	24      hW,          # )
ztensor(float)ztensor(float16)ztensor(double)ztensor(int32)ztensor(int64)ztensor(uint8)ztensor(int8)ztensor(bool)z
ONNX type z not understood)
ÚnpÚfloat32Úfloat16Úfloat64Úint32Úint64Úuint8Úint8Úbool_rB   )rÒ   Útype_mappings   & r   Úonnx_type_to_numpyrÞ   Ð  sv   € àœŸ™Øœ2Ÿ:™:Øœ"Ÿ*™*ØœŸ™ØœŸ™ØœŸ™ØœŸ™ØœŸ™ð	€Lð Ô$Ü˜* Y K¨Ð?Ó@Ð@ØÕ"Ð"r   )r   rÐ   rÄ   )N).r±   Ú
__future__r   r/   rk   ÚloggingrI   r(   r¢   Úurllib.errorr•   Útypingr   r   r   Úurllib.parser   r   r   Úurllib.requestr	   rÊ   Úkornia.configr
   Úkornia.core.externalr   rÔ   r   Úkornia.onnx.downloadr   Ú__all__Ú	getLoggerrN   Ú_loggerr,   r:   rD   rQ   rY   r]   rf   ro   r   rÄ   rÐ   rÞ   r   r   r   Ú<module>rë      s§   ðñ$	õ #ã Û Û Û 	Û Û Û ß 'Ñ 'ß 4Ñ 4Ý "ã Ý 'Ý ,Ý %Ý 1â
>€à
×
Ò
˜HÓ
%€ð .Ð õ#.õLVõ
bõVõ
õõôQÐ!ô Qõh.÷b&÷R#r   