§
    ù¸¸jf/  ã                  ó  — d dl mZ g d¢Zd dlZd dlZd dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 d d	l4m5Z5m6Z6 d d
l7m8Z8m9Z9m:Z: d dl;m<Z= d dlm>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJ eed         eKf         ZLdZMd9d„ZNd:d„ZOd;d„ZP	 d<d=d„ZQ	 	 d>d?d$„ZR	 d<d@d&„ZSeMfdAd*„ZTeMfdBd+„ZU	 d<d,ddd-d,d.œdCd7„ZV	 d<dDd8„ZWeRZXeTZYeVZZdS )Eé    )Úannotations)?ÚONNX_MLÚ
IR_VERSIONÚIR_VERSION_2017_10_10ÚIR_VERSION_2017_10_30ÚIR_VERSION_2017_11_3ÚIR_VERSION_2019_1_22ÚIR_VERSION_2019_3_18ÚIR_VERSION_2019_9_19ÚIR_VERSION_2020_5_8ÚIR_VERSION_2021_7_30ÚIR_VERSION_2023_5_5ÚIR_VERSION_2024_3_25ÚEXPERIMENTALÚSTABLEÚcheckerÚcomposeÚdefsÚ	gen_protoÚhelperÚhubÚmappingÚnumpy_helperÚparserÚprinterÚshape_inferenceÚutilsÚversion_converterÚAttributeProtoÚDeviceConfigurationProtoÚFunctionProtoÚ
GraphProtoÚIntIntListEntryProtoÚMapProtoÚ
ModelProtoÚNodeDeviceConfigurationProtoÚ	NodeProtoÚOperatorProtoÚOperatorSetIdProtoÚOperatorSetProtoÚOperatorStatusÚOptionalProtoÚSequenceProtoÚSimpleShardedDimProtoÚShardedDimProtoÚShardingSpecProtoÚSparseTensorProtoÚStringStringEntryProtoÚTensorAnnotationÚTensorProtoÚTensorShapeProtoÚTrainingInfoProtoÚ	TypeProtoÚValueInfoProtoÚVersionÚconvert_model_to_external_dataÚload_external_data_for_modelÚload_model_from_stringÚ
load_modelÚload_tensor_from_stringÚload_tensorÚ
save_modelÚsave_tensorÚwrite_external_data_tensorsN)ÚIOÚLiteralÚUnion)Úserialization)r   )r;   rB   r:   )#r   r    r   r!   r"   r#   r   r   r   r   r	   r
   r   r   r   r   r   r%   r&   r'   r)   r+   r   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   )r(   r*   )r$   r,   r-   )Úversion)r   r   r   r   r   r   r   r   r   r   r   r   r   )ÚprotobufÚ	textprotoÚonnxtxtÚjsonrH   ÚfúIO[bytes] | str | os.PathLikeÚreturnÚbytesc                óÞ  — t          | d¦  «        rot          t          j        t          t
                   | ¦  «        j        ¦  «        r8t          j        t          t
                   | ¦  «                             ¦   «         }nmt          j        t          t          t          j
        f         | ¦  «        } t          | d¦  «        5 }|                     ¦   «         }d d d ¦  «         n# 1 swxY w Y   |S )NÚreadÚrb)ÚhasattrÚcallableÚtypingÚcastrC   rO   rQ   rE   ÚstrÚosÚPathLikeÚopen)rL   ÚcontentÚreadables      ú]/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/onnx/__init__.pyÚ_load_bytesr^   ž   sè   € Ýˆq�&ÑÔð &�h¥v¤{µ2µe´9¸aÑ'@Ô'@Ô'EÑFÔFð &Ý”+�b¥œi¨Ñ+Ô+×0Ò0Ñ2Ô2ˆˆåŒK��c¥2¤;Ð.Ô/°Ñ3Ô3ˆÝ�!�T‰]Œ]ð 	&˜hØ—m’m‘o”oˆGð	&ð 	&ð 	&ñ 	&ô 	&ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&øøøð 	&ð 	&ð 	&ð 	&à€Ns   ÃC"Ã"C&Ã)C&r[   ÚNonec                óæ  — t          |d¦  «        rqt          t          j        t          t
                   |¦  «        j        ¦  «        r:t          j        t          t
                   |¦  «                             | ¦  «         d S t          j        t          t          t          j
        f         |¦  «        }t          |d¦  «        5 }|                     | ¦  «         d d d ¦  «         d S # 1 swxY w Y   d S )NÚwriteÚwb)rS   rT   rU   rV   rC   rO   ra   rE   rW   rX   rY   rZ   )r[   rL   Úwritables      r]   Ú_save_bytesrd   ¨   sþ   € Ýˆq�'ÑÔð $�x­¬µBµu´I¸qÑ(AÔ(AÔ(GÑHÔHð $ÝŒ•B•u”I˜qÑ!Ô!×'Ò'¨Ñ0Ô0Ð0Ð0Ð0åŒK��c¥2¤;Ð.Ô/°Ñ3Ô3ˆÝ�!�T‰]Œ]ð 	$˜hØ�NŠN˜7Ñ#Ô#Ð#ð	$ð 	$ð 	$ñ 	$ô 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$øøøð 	$ð 	$ð 	$ð 	$ð 	$ð 	$s   ÃC&Ã&C*Ã-C*ú$IO[bytes] | str | os.PathLike | Noneú
str | Nonec                óö   — t          | t          t          j        f¦  «        rt          j                             | ¦  «        S t          | d¦  «        r(| €J ‚t          j                             | j        ¦  «        S d S )NÚname)Ú
isinstancerW   rX   rY   ÚpathÚabspathrS   rh   )rL   s    r]   Ú_get_file_pathrl   ±   se   € Ý�!•c�2œ;Ð'Ñ(Ô(ð "ÝŒw�Š˜qÑ!Ô!Ð!Ýˆq�&ÑÔð 'Øˆ}ˆ}ˆ}ÝŒw�Š˜qœvÑ&Ô&Ð&Øˆ4ó    Úfmtú_SupportedFormat | Noneú$str | os.PathLike | IO[bytes] | Noneúserialization.ProtoSerializerc                ó@  — | �t           j                             | ¦  «        S t          |¦  «        x}�At          j                             |¦  «        \  }}t           j                             |¦  «        } | pt          } | €J ‚t           j                             | ¦  «        S )zQGet the serializer for the given path and format from the serialization registry.)	rF   ÚregistryÚgetrl   rX   rj   ÚsplitextÚget_format_from_file_extensionÚ_DEFAULT_FORMAT)rn   rL   Ú	file_pathÚ_Úexts        r]   Ú_get_serializerr{   º   sŽ   € ð
 €ÝÔ%×)Ò)¨#Ñ.Ô.Ð.å# AÑ&Ô&Ð&ˆ	Ð3Ý”×!Ò! )Ñ,Ô,‰ˆˆ3ÝÔ$×CÒCÀCÑHÔHˆð Ð
 •€CØˆ?ˆ?ˆ?åÔ!×%Ò% cÑ*Ô*Ð*rm   TÚformatÚload_external_dataÚboolr%   c                ó  — t          || ¦  «                             t          | ¦  «        t          ¦   «         ¦  «        }|r@t	          | ¦  «        }|r/t
          j                             |¦  «        }t          ||¦  «         |S )a  Loads a serialized ModelProto into memory.

    Args:
        f: can be a file-like object (has "read" function) or a string/PathLike containing a file name
        format: The serialization format. When it is not specified, it is inferred
            from the file extension when ``f`` is a path. If not specified _and_
            ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
            be "utf-8" when the format is a text format.
        load_external_data: Whether to load the external data.
            Set to True if the data is under the same directory of the model.
            If not, users need to call :func:`load_external_data_for_model`
            with directory to load external data from.

    Returns:
        Loaded in-memory ModelProto.
    )	r{   Údeserialize_protor^   r%   rl   rX   rj   Údirnamer;   )rL   r|   r}   ÚmodelÚmodel_filepathÚbase_dirs         r]   r=   r=   Í   sr   € õ* ˜F AÑ&Ô&×8Ò8½ÀQ¹¼ÍÉÌÑVÔV€Eàð :Ý'¨Ñ*Ô*ˆØð 	:Ý”w—’ ~Ñ6Ô6ˆHÝ(¨°Ñ9Ô9Ð9à€Lrm   r4   c                ó|   — t          || ¦  «                             t          | ¦  «        t          ¦   «         ¦  «        S )a  Loads a serialized TensorProto into memory.

    Args:
        f: can be a file-like object (has "read" function) or a string/PathLike containing a file name
        format: The serialization format. When it is not specified, it is inferred
            from the file extension when ``f`` is a path. If not specified _and_
            ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
            be "utf-8" when the format is a text format.

    Returns:
        Loaded in-memory TensorProto.
    )r{   r€   r^   r4   )rL   r|   s     r]   r?   r?   í   s.   € õ  ˜6 1Ñ%Ô%×7Ò7½ÀA¹¼ÍÉÌÑVÔVÐVrm   Úsúbytes | strÚ_SupportedFormatc                ó`   — t          |¦  «                             | t          ¦   «         ¦  «        S )aì  Loads a binary string (bytes) that contains serialized ModelProto.

    Args:
        s: a string, which contains serialized ModelProto
        format: The serialization format. When it is not specified, it is inferred
            from the file extension when ``f`` is a path. If not specified _and_
            ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
            be "utf-8" when the format is a text format.

    Returns:
        Loaded in-memory ModelProto.
    )r{   r€   r%   ©r†   r|   s     r]   r<   r<      s&   € õ  ˜6Ñ"Ô"×4Ò4°Q½
¹¼ÑEÔEÐErm   c                ó`   — t          |¦  «                             | t          ¦   «         ¦  «        S )aï  Loads a binary string (bytes) that contains serialized TensorProto.

    Args:
        s: a string, which contains serialized TensorProto
        format: The serialization format. When it is not specified, it is inferred
            from the file extension when ``f`` is a path. If not specified _and_
            ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
            be "utf-8" when the format is a text format.

    Returns:
        Loaded in-memory TensorProto.
    )r{   r€   r4   rŠ   s     r]   r>   r>     s&   € õ  ˜6Ñ"Ô"×4Ò4°Q½¹¼ÑFÔFÐFrm   Fi   )Úsave_as_external_dataÚall_tensors_to_one_fileÚlocationÚsize_thresholdÚconvert_attributeÚprotoúModelProto | bytesrŒ   r�   rŽ   r�   Úintr�   c               ó¨  — t          | t          ¦  «        r4t          t          ¦  «                             | t          ¦   «         ¦  «        } |rt          | ||||¦  «         t          |¦  «        }|�/t          j	         
                    |¦  «        }	t          | |	¦  «        } t          ||¦  «                             | ¦  «        }
t          |
|¦  «         dS )a}  Saves the ModelProto to the specified path and optionally, serialize tensors with raw data as external data before saving.

    Args:
        proto: should be a in-memory ModelProto
        f: can be a file-like object (has "write" function) or a string containing
        a file name or a pathlike object
        format: The serialization format. When it is not specified, it is inferred
            from the file extension when ``f`` is a path. If not specified _and_
            ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
            be "utf-8" when the format is a text format.
        save_as_external_data: If true, save tensors to external file(s).
        all_tensors_to_one_file: Effective only if save_as_external_data is True.
            If true, save all tensors to one external file specified by location.
            If false, save each tensor to a file named with the tensor name.
        location: Effective only if save_as_external_data is true.
            Specify the external file that all tensors to save to.
            Path is relative to the model path.
            If not specified, will use the model name.
        size_threshold: Effective only if save_as_external_data is True.
            Threshold for size of data. Only when tensor's data is >= the size_threshold it will be converted
            to external data. To convert every tensor with raw data to external data set size_threshold=0.
        convert_attribute: Effective only if save_as_external_data is True.
            If true, convert all tensors to external data
            If false, convert only non-attribute tensors to external data
    N)ri   rO   r{   rw   r€   r%   r:   rl   rX   rj   r�   rB   Úserialize_protord   )r‘   rL   r|   rŒ   r�   rŽ   r�   r�   rƒ   ÚbasepathÚ
serializeds              r]   r@   r@   &  sÊ   € õH �%�ÑÔð XÝ¥Ñ0Ô0×BÒBÀ5Í*É,Ì,ÑWÔWˆàð 
Ý&ØÐ*¨H°nÐFWñ	
ô 	
ð 	
õ $ AÑ&Ô&€NØÐ!Ý”7—?’? >Ñ2Ô2ˆÝ+¨E°8Ñ<Ô<ˆå  ¨Ñ8Ô8×HÒHÈÑOÔO€JÝ�
˜AÑÔÐÐÐrm   c                ól   — t          ||¦  «                             | ¦  «        }t          ||¦  «         dS )a  Saves the TensorProto to the specified path.

    Args:
        proto: should be a in-memory TensorProto
        f: can be a file-like object (has "write" function) or a string
        containing a file name or a pathlike object.
        format: The serialization format. When it is not specified, it is inferred
            from the file extension when ``f`` is a path. If not specified _and_
            ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
            be "utf-8" when the format is a text format.
    N)r{   r•   rd   )r‘   rL   r|   r—   s       r]   rA   rA   [  s7   € õ  ! ¨Ñ+Ô+×;Ò;¸EÑBÔB€JÝ�
˜AÑÔÐÐÐrm   )rL   rM   rN   rO   )r[   rO   rL   rM   rN   r_   )rL   re   rN   rf   )N)rn   ro   rL   rp   rN   rq   )NT)rL   rM   r|   ro   r}   r~   rN   r%   )rL   rM   r|   ro   rN   r4   )r†   r‡   r|   rˆ   rN   r%   )r†   rO   r|   rˆ   rN   r4   )r‘   r’   rL   rM   r|   ro   rŒ   r~   r�   r~   rŽ   rf   r�   r“   r�   r~   rN   r_   )r‘   r4   rL   rM   r|   ro   rN   r_   )[Ú
__future__r   Ú__all__rX   rU   rC   rD   rE   ÚonnxrF   Úonnx.onnx_cpp2py_exportr   Úonnx.external_data_helperr;   rB   r:   Úonnx.onnx_pbr   r    r   r!   r"   r#   r   r   r   r   r	   r
   r   r   r   r   r   r%   r&   r'   r)   r+   r   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   Úonnx.onnx_operators_pbr(   r*   Úonnx.onnx_data_pbr$   r,   r-   Úonnx.versionrG   Ú__version__r   r   r   r   r   r   r   r   r   r   r   r   r   rW   rˆ   rw   r^   rd   rl   r{   r=   r?   r<   r>   r@   rA   ÚloadÚload_from_stringÚsave© rm   r]   ú<module>r§      sƒ  ðð
 #Ð "Ð "Ð "Ð "Ð "ðDð Dð D€ðN 
€	€	€	Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %ð Ð Ð Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +ðð ð ð ð ð ð ð ð ð ð
$ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ðJ CÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DØ /Ð /Ð /Ð /Ð /Ð /ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð& ØÐ6Ô7¸Ð<ôÐ ð €ðð ð ð ð$ð $ð $ð $ðð ð ð ð MQð+ð +ð +ð +ð +ð* '+Ø#ðð ð ð ð ðD '+ðWð Wð Wð Wð Wð*  /ðFð Fð Fð Fð Fð*  /ðGð Gð Gð Gð Gð, '+ð2ð
 #(Ø$(ØØØ#ð2ð 2ð 2ð 2ð 2ð 2ðp '+ðð ð ð ð ð* €Ø)Ð Ø€€€rm   