Ë
    Fêñia  ã                  óÜ  — d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZmZmZmZmZmZmZmZ dZ ed	D � �cg c]  } d
D ]
  }d| › |› d�‘Œ Œ c}} d	D � �cg c]  } dD ]
  }d| › |› d�‘Œ Œ c}} z   d	D � �cg c]  } dD ]
  }d| › |› d�‘Œ Œ c}} z   d	D � �cg c]  } dD ]
  }d| › |› d�‘Œ Œ c}} z   d	D � �cg c]  } dD ]
  }d| › |› d�‘Œ Œ c}} z   dD � cg c]  } d| › d�‘Œ
 c} z   dD � cg c]  } d| › d�‘Œ
 c} z   dD � cg c]  } d| › d�‘Œ
 c} z   dD � �cg c]  } dD ]
  }d| › |› d�‘Œ Œ c}} z   dD � �cg c]  } dD ]
  }d| › |› d�‘Œ Œ c}} z   d	D � �cg c]  } dD ]
  }d| › |› d�‘Œ Œ c}} z   dD � cg c]  } d | › d�‘Œ
 c} z   d!D � cg c]  } d"| › d�‘Œ
 c} z   dD � cg c]  } d#| › d�‘Œ
 c} z   d$D � cg c]  } d%| › d�‘Œ
 c} z   d&D � cg c]  } d'| › d�‘Œ
 c} z   d&D � cg c]  } d(| › d�‘Œ
 c} z   d)D � cg c]  } d*| › d�‘Œ
 c} z   d+D � cg c]  } d,| › d�‘Œ
 c} z   g d-¢z   «      Z ed.„ eD «       «      Zd>d?d0„Zd@dAd1„Z	 	 	 dB	 	 	 	 	 	 	 	 	 dCd3„Z	 	 	 	 dD	 	 	 	 	 	 	 	 	 	 	 dEd4„Z ej@                  «       d5d2f	 	 	 	 	 	 	 	 	 dFd6„Z!dGd7„Z"	 	 	 	 	 	 	 	 	 dH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dId9„Z#	 	 	 dJ	 	 	 	 	 	 	 dKd:„Z$	 	 dL	 	 	 	 	 	 	 dMd;„Z% ej@                  «       d2d/d/d<d8d/f	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dNd=„Z&yc c}} w c c}} w c c}} w c c}} w c c}} w c c} w c c} w c c} w c c}} w c c}} w c c}} w c c} w c c} w c c} w c c} w c c} w c c} w c c} w c c} w )Oé    )ÚannotationsN)Úrepeat)Ú
ThreadPool)ÚPath)ÚparseÚrequest)Ú
ASSETS_URLÚLOGGERÚTQDMÚchecksÚ	clean_urlÚemojisÚ	is_onlineÚurl2fileúultralytics/assetsÚnsmlx)Ú ú-clsú-segú-poseú-obbz-oiv7Úyolov8z.pt)r   r   r   r   r   Úyolo11)r   Úyolo12Úyolo26)r   Ú6Úyolov5zu.pt)r   z-sppz-tinyÚyolov3Úsmlxz	-world.ptz-worldv2.ptÚsml)r   z-seg-pfzyoloe-v8zyoloe-11zyoloe-26ÚtsmceÚyolov9ÚnsmblxÚyolov10Ú	yolo_nas_ÚblÚsam_ÚblstÚsam2_zsam2.1_ÚsxzFastSAM-Úlxzrtdetr-)zmobile_sam.ptzmobileclip_blt.tszyolo11n-grayscale.ptz:calibration_image_sample_data_20x128x128x3_float32.npy.zipc              #  óD   K  — | ]  }|j                  d «      d   –— Œ y­w)ú.r   N)Ú
rpartition)Ú.0Úks     ú]/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/utils/downloads.pyú	<genexpr>r2   -   s   è ø€ ÒR¸ §¡¨SÓ 1°!Õ 4ÑRùs   ‚ Fc                ó.  — 	 t        | «      } t        j                  | «      }|j                  r|j                  sy|rJt        j                  t        j                  | d¬«      d¬«      }d|j                  «       cxk  xr dk  S c S y# t        $ r Y yw xY w)	a  Validate if the given string is a URL and optionally check if the URL exists online.

    Args:
        url (str | Path): The string to be validated as a URL.
        check (bool, optional): If True, performs an additional check to see if the URL exists online.

    Returns:
        (bool): True for a valid URL. If 'check' is True, also returns True if the URL exists online.

    Examples:
        >>> valid = is_url("https://www.example.com")
        >>> valid_and_exists = is_url("https://www.example.com", check=True)
    FÚHEAD)Úmethodé   )ÚtimeoutéÈ   i�  T)
Ústrr   ÚurlparseÚschemeÚnetlocr   ÚurlopenÚRequestÚgetcodeÚ	Exception)ÚurlÚcheckÚresultÚrs       r1   Úis_urlrE   0   s}   € ð
Ü�#‹hˆÜ—‘ Ó$ˆØ—’ &§-¢-ØÙÜ—‘¤§¡°¸FÔ CÈQÔOˆAØ˜!Ÿ)™)›+Ö+¨Ñ+Ð+Ñ+Ð+ØøÜò Ùðús   ‚8B »AB ÂB Â	BÂBc                ó¼   — |D ]W  }t        t        | «      j                  |«      «      }t        j                  d|› d|› �«       |D ]  }|j                  «        Œ ŒY y)aG  Delete all specified system files in a directory.

    Args:
        path (str | Path): The directory path where the files should be deleted.
        files_to_delete (tuple[str, ...]): The files to be deleted.

    Examples:
        >>> from ultralytics.utils.downloads import delete_dsstore
        >>> delete_dsstore("path/to/dir")

    Notes:
        ".DS_Store" files are created by the Apple operating system and contain metadata about folders and files. They
        are hidden system files and can cause issues when transferring files between different operating systems.
    z	Deleting z files: N)Úlistr   Úrglobr
   ÚinfoÚunlink)ÚpathÚfiles_to_deleteÚfileÚmatchesÚfs        r1   Údelete_dsstorerP   K   s]   € ð  ò ˆÜ”t˜D“z×'Ñ'¨Ó-Ó.ˆÜ�‰�i ˜v X¨g¨YÐ7Ô8Øò 	ˆAØ�H‰H�Jñ	ñó    Tc           	     ó  ‡— ddl m}m}m} t	        | «       t        | «      } | j                  «       st        d| › d�«      ‚| j                  d«      D �‡cg c]*  Š‰j                  «       sŒt        ˆfd„|D «       «      sŒ)‰‘Œ, }}| j                  d«      }	|r|n|}
 ||	d|
«      5 Št        |d	| › d
|	› d�d| ¬«      D ]#  }‰j                  ||j                  | «      «       Œ% 	 ddd«       |	S c c}w # 1 sw Y   |	S xY w)a�  Zip the contents of a directory, excluding specified files.

    The resulting zip file is named after the directory and placed alongside it.

    Args:
        directory (str | Path): The path to the directory to be zipped.
        compress (bool): Whether to compress the files while zipping.
        exclude (tuple[str, ...], optional): A tuple of filename strings to be excluded.
        progress (bool, optional): Whether to display a progress bar.

    Returns:
        (Path): The path to the resulting zip file.

    Examples:
        >>> from ultralytics.utils.downloads import zip_directory
        >>> file = zip_directory("path/to/dir")
    r   )ÚZIP_DEFLATEDÚ
ZIP_STOREDÚZipFilezDirectory 'z' does not exist.Ú*c              3  ó:   •K  — | ]  }|‰j                   v–— Œ y ­w©N)Úname©r/   ÚxrO   s     €r1   r2   z zip_directory.<locals>.<genexpr>€   s   øè ø€ ÒCeÐXYÀAÈQÏVÉVÄOÑCeùs   ƒú.zipÚwzZipping ú to ú...Úfiles©ÚdescÚunitÚdisableN)ÚzipfilerS   rT   rU   rP   r   Úis_dirÚFileNotFoundErrorrH   Úis_fileÚallÚwith_suffixr   ÚwriteÚrelative_to)Ú	directoryÚcompressÚexcludeÚprogressrS   rT   rU   rO   r`   Úzip_fileÚcompressionrM   s          `    r1   Úzip_directoryrs   a   s  ø€ ÷. :Ñ9ä�9ÔÜ�Y“€IØ×ÑÔÜ +¨i¨[Ð8IÐ JÓKÐKð "Ÿ™¨Ó,×f�1°·	±	µÄÓCeÐ]dÔCeÕ@eŠQÐf€EÐfØ×$Ñ$ VÓ,€HÙ"*‘,°
€KÙ	�˜3 Ó	,ð 7°Ü˜ x°	¨{¸$¸x¸jÈÐ%LÐSZÐhpÐdpÔqò 	7ˆDØ�G‰G�D˜$×*Ñ*¨9Ó5Õ6ñ	7÷7ð €Oùò g÷7ð €Oús   ÁC0Á+C0Â C0Â'>C5Ã5C?c           
     ó¼  ‡	— ddl m}m}m} t	        | «      j                  «       r || «      s |d| › d�«      ‚|€t	        | «      j                  } || «      5 }|j                  «       D �	‡	cg c]  Š	t        ˆ	fd„|D «       «      sŒ‰	‘Œ }
}	|
D �	ch c]  }	t	        |	«      j                  d   ’Œ }}	t        |«      dk(  }|r#|}t	        |«      t        t        |«      «      z  }n#t	        |«      t	        | «      j                  z  x}}|j                  «       rBt        |j                  «       «      r)|s't!        j"                  d| › d	|› d
�«       |cddd«       S t	        |«      j%                  «       }t'        |
d| › dt	        |«      j%                  «       › d�d| ¬«      D ]™  Š	t	        ‰	«      }||z  j%                  «       }|j)                  «       s=d|j                  v s/|j                  dt        |j                  «       |j                  k7  rt!        j"                  d‰	› d�«       Œˆ|j+                  ‰	|«       Œ› 	 ddd«       |S c c}	w c c}	w # 1 sw Y   |S xY w)aH  Unzip a *.zip file to the specified path, excluding specified files.

    If the zipfile does not contain a single top-level directory, the function will create a new directory with the same
    name as the zipfile (without the extension) to extract its contents. If a path is not provided, the function will
    use the parent directory of the zipfile as the default path.

    Args:
        file (str | Path): The path to the zipfile to be extracted.
        path (str | Path, optional): The path to extract the zipfile to.
        exclude (tuple[str, ...], optional): A tuple of filename strings to be excluded.
        exist_ok (bool, optional): Whether to overwrite existing contents if they exist.
        progress (bool, optional): Whether to display a progress bar.

    Returns:
        (Path): The path to the directory where the zipfile was extracted.

    Raises:
        BadZipFile: If the provided file does not exist or is not a valid zipfile.

    Examples:
        >>> from ultralytics.utils.downloads import unzip_file
        >>> directory = unzip_file("path/to/file.zip")
    r   )Ú
BadZipFilerU   Ú
is_zipfilezFile 'z&' does not exist or is a bad zip file.Nc              3  ó&   •K  — | ]  }|‰v–— Œ
 y ­wrX   © rZ   s     €r1   r2   zunzip_file.<locals>.<genexpr>±   s   øè ø€ Ò4QÀA°Q¸a´ZÑ4Qùs   ƒé   z	Skipping z  unzip as destination directory z is not empty.ú
Unzipping r^   r_   r`   ra   ú..ú Potentially insecure file path: ú, skipping extraction.)re   ru   rU   rv   r   ÚexistsÚparentÚnamelistri   ÚpartsÚlenÚnextÚiterÚstemÚanyÚiterdirr
   ÚwarningÚresolver   Úis_absoluteÚextract)rM   rK   ro   Úexist_okrp   ru   rU   rv   ÚzipObjrO   r`   Útop_level_dirsÚunzip_as_dirÚextract_pathÚf_pathÚtargets            `      r1   Ú
unzip_filer“   Š   s+  ø€ ÷< 8Ñ7ä�‹J×ÑÔ¡J¨tÔ$4Ù˜6 $ Ð'MÐNÓOÐOØ€|Ü�D‹z× Ñ ˆñ 
�‹ð ,˜&Ø"ŸO™OÓ-×R�q´Ó4QÈÔ4QÕ1Q’ÐRˆÐRØ49Ö:¨qœ$˜q›'Ÿ-™-¨Ó*Ð:ˆÐ:ô ˜>Ó*¨aÑ/ˆÙàˆLÜ˜“:¤¤T¨.Ó%9Ó :Ñ:‰Dô #' t£*¬t°D«z¯©Ñ">Ð>ˆD�<ð �;‰;Œ=œS §¡£Ô0¹ä�N‰N˜Y t fÐ,LÈTÈFÐR`ÐaÔbØ÷%,ñ ,ô( ˜LÓ)×1Ñ1Ó3ˆÜ�e J¨t¨f°D¼¸d»×9KÑ9KÓ9MÐ8NÈcÐ"RÐY`ÐnvÐjvÔwò 
	,ˆAÜ˜!“WˆFØ" VÑ+×4Ñ4Ó6ˆFà×"Ñ"Ô$Ø˜6Ÿ<™<Ñ'Ø—<‘<Ð 9¤# l×&8Ñ&8Ó"9Ð:¸l×>PÑ>PÒPä—‘Ð!AÀ!ÀÐDZÐ[Ô\ØØ�N‰N˜1˜lÕ+ñ
	,÷+,ðB €KùòA SùÚ:÷,ðB €Kús8   ÁIÁ,IÂIÂ
IÂIÂ/B IÅC#IÉ
IÉIg      ø?c                ó  — t        j                  |«      \  }}}| |z  |k  ryd„ }d ||«      › d |t        | |z  «      «      › d |t        | |z  |z
  «      «      › d�}|rt        |«      ‚t	        j
                  |«       y)að  Check if there is sufficient disk space to download and store a file.

    Args:
        file_bytes (int): The file size in bytes.
        path (str | Path, optional): The path or drive to check the available free space on.
        sf (float, optional): Safety factor, the multiplier for the required free space.
        hard (bool, optional): Whether to throw an error or not on insufficient disk space.

    Returns:
        (bool): True if there is sufficient disk space, False otherwise.
    Tc                ó0   — | dk  r	| dz  d›d�S | dz  d›d�S )Ni   @é   ú.1fz MBz.3fz GBrx   )Úbs    r1   Ú	fmt_bytesz#check_disk_space.<locals>.fmt_bytesé   s1   € Ø,-°ªM�!�w‘- Ð$ CÐ(ÐXÀ!ÀwÁ-ÐPSÐATÐTWÐ?XÐXrQ   zInsufficient free disk space z < z required, Please free z% additional disk space and try again.F)ÚshutilÚ
disk_usageÚintÚMemoryErrorr
   rˆ   )	Ú
file_bytesrK   ÚsfÚhardÚ_totalÚ_usedÚfreer™   Útexts	            r1   Úcheck_disk_spacer¥   Ô   s    € ô" !×+Ñ+¨DÓ1Ñ€FˆE�4Ø�B�˜ÒØòYð
 (©	°$«Ð'8¸¹IÄcÈ*ÐWYÉ/ÓFZÓ<[Ð;\ð ]Ù ¤ Z°"¡_°tÑ%;Ó!<Ó=Ð>Ð>cð	eð 	ñ Ü˜$ÓÐÜ
‡N�N�4ÔØrQ   c                óB  — ddl }| j                  d«      d   j                  dd«      d   }d|› �}d}|j                  «       5 }|j                  |d¬«      }d	t	        |j
                  j                  «       «      v rt        t        d
| › d�«      «      ‚|j                  j                  «       D ]  \  }}|j                  d«      sŒ|d|› �z  }Œ! |j                  j                  d«      x}	rt        j                  d|	«      d   }ddd«       ||fS # 1 sw Y   ||fS xY w)at  Retrieve the direct download link and filename for a shareable Google Drive file link.

    Args:
        link (str): The shareable link of the Google Drive file.

    Returns:
        url (str): Direct download URL for the Google Drive file.
        filename (str | None): Original filename of the Google Drive file. If filename extraction fails, returns None.

    Examples:
        >>> from ultralytics.utils.downloads import get_google_drive_file_info
        >>> link = "https://drive.google.com/file/d/1cqT-cJgANNrhIHCrEufUYhQ4RqiWG_lJ/view?usp=drive_link"
        >>> url, filename = get_google_drive_file_info(link)
    r   Nz/d/ry   z/viewz/https://drive.google.com/uc?export=download&id=T)Ústreamzquota exceededui   â�Œ  Google Drive file download quota exceeded. Please try again later or download this file manually at r-   Údownload_warningz	&confirm=zcontent-dispositionzfilename="(.+)")ÚrequestsÚsplitÚSessionÚgetr9   ÚcontentÚlowerÚConnectionErrorr   ÚcookiesÚitemsÚ
startswithÚheadersÚreÚfindall)
Úlinkr©   Úfile_idÚ	drive_urlÚfilenameÚsessionÚresponser0   ÚvÚcds
             r1   Úget_google_drive_file_infor¾   ÷   sD  € ó à�j‰j˜Ó Ñ"×(Ñ(¨°!Ó4°QÑ7€GØAÀ'ÀÐK€IØ€Hð 
×	Ñ	Ó	ð <˜wØ—;‘;˜y°�;Ó6ˆØœs 8×#3Ñ#3×#9Ñ#9Ó#;Ó<Ñ<Ü!ÜðPØPTÈvÐUVðXóóð ð ×$Ñ$×*Ñ*Ó,ò 	-‰DˆAˆqØ�|‰|Ð.Õ/Ø˜y¨¨˜_Ñ,‘	ð	-ð ×!Ñ!×%Ñ%Ð&;Ó<Ð<ˆ2Ð<Ü—z‘zÐ"3°RÓ8¸Ñ;ˆH÷<ð �hÐÐ÷<ð �hÐÐús   ÁBDÃA DÄDr6   c
                óÀ  — t        | «      } d| vr&t        | «      j                  «       rt        | «      }
�n}| j                  d«      }|rt	        | «      \  } }| j                  dd«      } t        |xs d«      |xs t        | «      z  }
|
j                  «       �s|r| n
t        | «      j                  t        d«      }d|› d|
› d	�}|
j                  j                  d
d
¬«       t        j                  d«      }t        |dz   «      D �]ª  }	 |s|dkD  rG|rEd|	 z  }t        j                  ddd|› d�| d|
ddddg
«      j                   }|dk(  s
J d|› �«       ‚d}nét#        j$                  | «      5 }t'        |j)                  dd«      «      }|dk(  r|dkD  rt+        ||
j                  ¬«       |rt-        dt/        d|dz  «      «      nd}t1        |||	 dd
d¬ «      5 }t3        |
d!«      5 }	 |j5                  |«      }|sn,|j7                  |«       |j9                  t;        |«      «       Œ@	 ddd«       ddd«       ddd«       |
j=                  «       r_|
j?                  «       j@                  }||kD  r0r,||k7  r'tC        jD                  d"|› d#|› d$||z  d%z  d&›d'�«       n n|
jG                  «        �Œ­ |�rP|
j=                  «       �r?|
jR                  d-v �r0dd.l*m+} |xs |
j                  jY                  «       } ||
«      rt[        |
|||	¬/«      }�nß|
jR                  d0v �rÐtC        j\                  d1|
› d2|› d3�«       t_        j2                  |
d4«      5 }|D �]Ž  }|ja                  «       s|jc                  «       r |je                  «       s|jg                  «       r$tC        jD                  d5|jh                  › d6�«       Œht        |jh                  «      }||z  jY                  «       }|jk                  «       s=d7|jl                  v s/|jl                  dt;        |jl                  «       |jl                  k7  r%tC        jD                  d8|jh                  › d6�«       �Œ|jc                  «       r|j                  d
d
¬«       �Œ'|jo                  |«      x} s�Œ<|j                  j                  d
d
¬«       | 5  t3        |d!«      5 }
t        jp                  | |
«       ddd«       ddd«       �Œ‘ 	 ddd«       |r|
jG                  «        |S |
S # 1 sw Y   �ŒáxY w# 1 sw Y   �ŒæxY w# 1 sw Y   �ŒëxY w# tH        $ r ‚ tJ        $ rw}|dk(  r#tM        «       stO        tQ        d(|› d)�«      «      |‚||k\  rtO        tQ        d(|› d*|› �«      «      |‚tC        jD                  d+|dz   › d#|› d|› d,|› �«       Y d}~�Œ®d}~ww xY w# 1 sw Y   ŒæxY w# 1 sw Y   �ŒzxY w# 1 sw Y   ŒëxY w)9aú  Download files from a URL with options for retrying, unzipping, and deleting the downloaded file. Enhanced with
    robust partial download detection using Content-Length validation.

    Args:
        url (str | Path): The URL of the file to be downloaded.
        file (str | Path, optional): The filename of the downloaded file. If not provided, the file will be saved with
            the same name as the URL.
        dir (str | Path, optional): The directory to save the downloaded file. If not provided, the file will be saved
            in the current working directory.
        unzip (bool, optional): Whether to unzip the downloaded file.
        delete (bool, optional): Whether to delete the downloaded file after unzipping.
        curl (bool, optional): Whether to use curl command line tool for downloading.
        retry (int, optional): The number of times to retry the download in case of failure.
        min_bytes (float, optional): The minimum number of bytes that the downloaded file should have, to be considered
            a successful download.
        exist_ok (bool, optional): Whether to overwrite existing contents during unzipping.
        progress (bool, optional): Whether to display a progress bar during the download.

    Returns:
        (Path | str): The path to the downloaded file or extracted directory.

    Examples:
        >>> from ultralytics.utils.downloads import safe_download
        >>> link = "https://ultralytics.com/assets/bus.jpg"
        >>> path = safe_download(link)
    ú://zhttps://drive.google.com/ú z%20r-   zhttps://ultralytics.com/assetsúDownloading z to 'ú'T©ÚparentsrŒ   Úcurlry   r   ÚsSz-#ú-ÚLz-oz--retryÚ3z-CzCurl return value NzContent-Lengthr–   )rK   i    iè  ÚBi   )Útotalrb   rd   rc   Ú
unit_scaleÚunit_divisorÚwbzPartial download: ú/z bytes (éd   r—   z%)u   â�Œ  Download failure for z. Environment may be offline.z. Retry limit reached. zDownload failure, retrying z... >   r   ú.gzú.tarr\   )rv   )rM   rK   rŒ   rp   >   rÒ   rÓ   rz   r^   r_   zr:*z!Potentially insecure tar member: r}   r{   r|   )9r9   r   rh   r²   r¾   Úreplacer   r   r	   r   Úmkdirrš   ÚwhichÚrangeÚ
subprocessÚrunÚ
returncoder   r=   rœ   Ú	getheaderr¥   ÚmaxÚminr   ÚopenÚreadrk   Úupdater‚   r~   ÚstatÚst_sizer
   rˆ   rJ   r�   r@   r   r¯   r   Úsuffixre   rv   r‰   r“   rI   ÚtarfileÚisfileÚisdirÚissymÚislnkrY   rŠ   r�   ÚextractfileÚcopyfileobj)!rA   rM   ÚdirÚunzipÚdeleterÆ   ÚretryÚ	min_bytesrŒ   rp   rO   ÚgdriveÚurirb   Úcurl_installedÚiÚsrD   Úexpected_sizer»   Úbuffer_sizeÚpbarÚf_openedÚdataÚ	file_sizeÚerv   Ú	unzip_dirÚtarÚmÚm_pathr’   Úsources!                                    r1   Úsafe_downloadr    s¢  € ôL ˆc‹(€CØ�CÑœD ›I×-Ñ-Ô/Ü�‹IŠà—‘Ð ;Ó<ˆÙÜ2°3Ó7‰IˆC�Ø�k‰k˜#˜uÓ%ˆä�’˜Ó Ò 5¬°«Ñ6ˆØ�y‰y�{Ù ‘3¤i°£n×=Ñ=¼jÐJjÓkˆCØ! #  e¨A¨3¨aÐ0ˆDØ�H‰H�N‰N 4°$ˆNÔ7Ü#Ÿ\™\¨&Ó1ˆNÜ˜5 1™9Ó%ó 3_�ð2_Ù  A¢©>Ø ¨ LÑ1˜Ü&ŸN™N¨F°D¸A¸a¸SÀ¸(ÀCÈÈqÐR[Ð]`ÐbfÐhkÐ+lÓm×xÑx˜Ø  AšvÐ?Ð);¸A¸3Ð'?Ó?˜vØ(,™ä$Ÿ_™_¨SÓ1ð ?°XÜ,/°×0BÑ0BÐCSÐUVÓ0WÓ,X˜MØ  Ašv¨-¸'Ò*AÜ 0°ÀQÇXÁXÕ NÙ\i¬#¨d´C¸ÀÐRVÑAVÓ4WÔ*XÐos˜KÜ!%Ø&3Ø%)Ø,4¨Ø%(Ø+/Ø-1ô"ð ?ð "&Ü%)¨!¨T£]ð !?°hØ*.Ø/7¯}©}¸[Ó/I¨Ù/3Ø,1Ø(0¯©°tÔ(<Ø(,¯©´C¸³IÔ(>ð +/ð -2÷	!?÷?÷?ð* —x‘x”zØ$%§F¡F£H×$4Ñ$4˜	Ø$ yÒ0á,°¸mÒ1KÜ &§¡Ø&8¸¸À1À]ÀOÐS[Ð\eÐhuÑ\uÐx{Ñ\{Ð|ð  \Að  ACð  %Dõ!"ñ !&ØŸ™œ
ùðO3_òj �—‘• §¡Ð,GÒ GÝ&à’_˜AŸH™H×-Ñ-Ó/ˆ	Ù�aŒ=Ü"¨°	ÀHÐW_Ô`ŠIØ�X‰X˜Ò(Ü�K‰K˜* Q C t¨I¨;°cÐ:Ô;Ü—‘˜a Ó'ð :¨3Øó :�AØŸH™HœJ¨!¯'©'¬)¸¿¹¼	ÀQÇWÁWÄYÜŸ™Ð)JÈ1Ï6É6È(ÐRhÐ'iÔjØ Ü! !§&¡&›\�FØ'¨&Ñ0×9Ñ9Ó;�Fà×*Ñ*Ô,Ø 6§<¡<Ñ/Ø!Ÿ<™<Ð(>¬#¨i¯o©oÓ*>Ð?À9Ç?Á?ÒRäŸ™Ð)IÈ!Ï&É&ÈÐQgÐ'hÔiÙ Ø—w‘w”yØŸ™¨T¸D˜ÖAØ#&§?¡?°1Ó#5Ð5˜Ò5ØŸ™×+Ñ+°DÀ4Ð+ÔHØ#ñ :¤T¨&°$Ó%7ð :¸1Ü"×.Ñ.¨v°qÔ9÷:÷ :ñ :ñ#:÷:ñ( Ø�H‰HŒJØÐØ€H÷!?ñ !?ú÷?ñ ?ú÷?ñ ?ûô@ #ò ØÜ ò 	_Ø˜A’v¤i¤kÜ-Ü"Ð%?À¸uÐDaÐ#bÓcóà ð!ð ˜ešÜ-Ü"Ð%?À¸uÐD[Ð\]Ð[^Ð#_Ó`óà ð!ô —N‘NÐ%@ÀÀQÁÀÀqÈÈÈqÐQTÐPUÐUYÐZ[ÐY\Ð#]×^Ò^ûð	_ú÷J:ð :ú÷ :ñ :ú÷%:ð :ús®   Ä
A#T/Å-A,T"ÇTÇ&AT	È)TÈ1T"È9A%T/Ê T/ÍD=WÒWÒ2WÒ?V;	ÓWÓWÔTÔTÔTÔT"Ô"T,	Ô'T/Ô/V8ÕA,V3Ö3V8Ö;W× W×W×W×Wc                óœ  — ddl }|dk7  rd|› �}d| › d|› �}|j                  |«      }|j                  dk7  r"|j                  dk7  r|r|j                  |«      }|j                  dk7  r6t	        j
                  d	|› d
|j                  › d|j                  › �«       dg fS |j                  «       }|d   |d   D �cg c]  }|d   ‘Œ	 c}fS c c}w )ag  Retrieve the specified version's tag and assets from a GitHub repository.

    If the version is not specified, the function fetches the latest release assets.

    Args:
        repo (str, optional): The GitHub repository in the format 'owner/repo'.
        version (str, optional): The release version to fetch assets from.
        retry (bool, optional): Flag to retry the request in case of a failure.

    Returns:
        tag (str): The release tag.
        assets (list[str]): A list of asset names.

    Examples:
        >>> tag, assets = get_github_assets(repo="ultralytics/assets", version="latest")
    r   NÚlatestztags/zhttps://api.github.com/repos/z
/releases/r8   zrate limit exceededz GitHub assets check failure for z: rÁ   r   Útag_nameÚassetsrY   )r©   r¬   Ústatus_codeÚreasonr
   rˆ   Újson)ÚrepoÚversionrî   r©   rA   rD   rù   r[   s           r1   Úget_github_assetsr  ª  sÕ   € ó* à�(ÒØ˜'˜Ð#ˆØ)¨$¨¨z¸'¸Ð
C€CØ�‰�SÓ€AØ‡}�}˜Ò §¡Ð,AÒ AÁeØ�L‰L˜ÓˆØ‡}�}˜ÒÜ�‰Ð9¸#¸¸bÀÇÁÀÈqÐQR×QYÑQYÐPZÐ[Ô\Ø�2ˆvˆØ�6‰6‹8€DØ�
Ñ°°h±Ö@¨A˜a ›iÒ@Ð@Ð@ùÒ@s   Â9C	c                óÆ  — ddl m} t        | «      } t        j                  | «      } t        | j                  «       j                  dd«      «      } | j                  «       rt        | «      S |d   | z  j                  «       rt        |d   | z  «      S t        t        j                  t        | «      «      «      j                  }d|› d�}t        | «      j                  d«      rˆt        | «      j                  d	d
«      }t        |«      } t        | «      j                  «       r/t        j                   dt#        |«      › d| › �«       t        | «      S t%        d|| ddœ|¤Ž t        | «      S |t&        k(  r*|t(        v r"t%        d|› d|› d|› �| ddœ|¤Ž t        | «      S t+        ||«      \  }}	|	st+        |«      \  }}	||	v rt%        d|› d|› d|› �| ddœ|¤Ž t        | «      S )aN  Attempt to download a file from GitHub release assets if it is not found locally.

    Args:
        file (str | Path): The filename or file path to be downloaded.
        repo (str, optional): The GitHub repository in the format 'owner/repo'.
        release (str, optional): The specific release version to be downloaded.
        **kwargs (Any): Additional keyword arguments for the download process.

    Returns:
        (str): The path to the downloaded file.

    Examples:
        >>> file_path = attempt_download_asset("yolo26n.pt", repo="ultralytics/assets", release="latest")
    r   )ÚSETTINGSrÃ   r   Úweights_dirzhttps://github.com/z/releases/download)zhttp:/zhttps:/z:/rÀ   zFound z locally at g     jø@)rA   rM   rï   rÐ   rx   )Úultralytics.utilsr  r9   r   Úcheck_yolov5u_filenamer   ÚstriprÔ   r~   r   ÚunquoterY   r²   r   rh   r
   rI   r   r  ÚGITHUB_ASSETS_REPOÚGITHUB_ASSETS_NAMESr  )
rM   r	  ÚreleaseÚkwargsr  rY   Údownload_urlrA   Útagr  s
             r1   Úattempt_download_assetr  Î  sÚ  € õ( +ô ˆt‹9€DÜ×(Ñ(¨Ó.€DÜ�—
‘
“×$Ñ$ S¨"Ó-Ó.€DØ‡{�{„}Ü�4‹yÐØ
�=Ñ
! DÑ
(×	0Ñ	0Ô	2Ü�8˜MÑ*¨TÑ1Ó2Ð2ô ”E—M‘M¤# d£)Ó,Ó-×2Ñ2ˆØ,¨T¨FÐ2DÐEˆÜˆt‹9×ÑÐ 5Ô6Ü�d“)×#Ñ# D¨%Ó0ˆCÜ˜D“>ˆDÜ�D‹z×!Ñ!Ô#Ü—‘˜f¤Y¨s£^Ð$4°LÀÀÐGÔHô �4‹yÐô ÐJ #¨D¸CÑJÀ6ÒJô �4‹yÐð Ô'Ò'¨DÔ4GÑ,GÜÐe  ¨a°¨y¸¸$¸Ð@ÀtÐWZÑeÐ^dÒeô �4‹yÐô ,¨D°'Ó:‰KˆC�ÙÜ/°Ó5‘��VØ�v‰~ÜÐe \ N°!°C°5¸¸$¸Ð"@ÀtÐWZÑeÐ^dÒeä�4‹yÐrQ   ry   c           
     óæ  ‡‡‡‡‡— t        |«      }|j                  dd¬«       t        | t        t         f«      r| gn| }|dkD  r‰t	        j
                  dt        |«      › d|› d|› d�«       t        |«      5 }	|	j                  ˆˆˆˆˆfd„t        |t        |«      «      «       |	j                  «        |	j                  «        d	d	d	«       y	|D ]  }
t        |
|‰‰‰‰‰¬
«       Œ y	# 1 sw Y   y	xY w)a�  Download files from specified URLs to a given directory.

    Supports concurrent downloads if multiple threads are specified.

    Args:
        url (str | list[str] | Path): The URL or list of URLs of the files to be downloaded.
        dir (Path, optional): The directory where the files will be saved.
        unzip (bool, optional): Flag to unzip the files after downloading.
        delete (bool, optional): Flag to delete the zip files after extraction.
        curl (bool, optional): Flag to use curl for downloading.
        threads (int, optional): Number of threads to use for concurrent downloads.
        retry (int, optional): Number of retries in case of download failure.
        exist_ok (bool, optional): Whether to overwrite existing contents during unzipping.

    Examples:
        >>> download("https://ultralytics.com/assets/example.zip", dir="path/to/dir", unzip=True)
    TrÄ   ry   rÂ   z file(s) with z threads to r_   c           
     ó6   •— t        | d   | d   ‰‰‰‰‰d¬«      S )Nr   ry   T)rA   rë   rì   rí   rÆ   rî   rŒ   rp   )r  )r[   rÆ   rí   rŒ   rî   rì   s    €€€€€r1   ú<lambda>zdownload.<locals>.<lambda>'  s,   ø€ œ-Ø˜!™Ø˜!™ØØ!ØØØ%Ø!ô	€ rQ   N)rA   rë   rì   rí   rÆ   rî   rŒ   )r   rÕ   Ú
isinstancer9   r
   rI   r‚   r   ÚmapÚzipr   ÚcloseÚjoinr  )rA   rë   rì   rí   rÆ   Úthreadsrî   rŒ   ÚurlsÚpoolÚus     ``` ``   r1   Údownloadr&    så   ü€ ô6 ˆs‹)€CØ‡I�I�d T€IÔ*Ü˜s¤S¬$ KÔ0ˆC‰5°c€DØ�‚{Ü�‰�l¤3 t£9 +¨^¸G¸9ÀLÐQTÐPUÐUXÐYÔZÜ˜Ó ð 	 DØ�H‰H÷	ô �Dœ& ›+Ó&ôð �J‰JŒLØ�I‰IŒK÷	ð 	ð" ò 	qˆAÜ˜a S°¸fÈ4ÐW\ÐgoÖpñ	q÷#	ð 	ús   Á7AC'Ã'C0)F)rA   ú
str | PathrB   ÚboolÚreturnr(  )©z	.DS_StoreÚ__MACOSX)rK   r'  rL   útuple[str, ...]r)  ÚNone)Tr*  T)
rm   r'  rn   r(  ro   r,  rp   r(  r)  r   )Nr*  FT)rM   r'  rK   ústr | Path | Nonero   r,  rŒ   r(  rp   r(  r)  r   )
rž   rœ   rK   r'  rŸ   Úfloatr    r(  r)  r(  )r¶   r9   r)  ztuple[str, str | None])	NNTFFr6   g      ð?FT)rA   r'  rM   r.  rë   r.  rì   r(  rí   r(  rÆ   r(  rî   rœ   rï   r/  rŒ   r(  rp   r(  r)  z
Path | str)r   r  F)r	  r9   r
  r9   rî   r(  r)  ztuple[str, list[str]])r   zv8.4.0)rM   r'  r	  r9   r  r9   r)  r9   )rA   zstr | list[str] | Pathrë   r   rì   r(  rí   r(  rÆ   r(  r"  rœ   rî   rœ   rŒ   r(  r)  r-  )'Ú
__future__r   r´   rš   rØ   rä   Ú	itertoolsr   Úmultiprocessing.poolr   Úpathlibr   Úurllibr   r   r  r	   r
   r   r   r   r   r   r   r  Ú	frozensetr  ÚGITHUB_ASSETS_STEMSrE   rP   rs   r“   Úcwdr¥   r¾   r  r  r  r&  )r0   rã   Ú
resolutions   000r1   ú<module>r9     sÌ  ðõ #ã 	Û Û Û Ý Ý +Ý ß !ç f× fÓ fð *Ð ÙØ&-×k Ð<jÒk°&€vˆaˆS��˜ÒÐkÐÓkØ(/×d 1Ð>cÒd°Fˆ�ˆs�6�(˜#ÒÐdÐÓdñeà(/×D 1¸eÒD°Fˆ�ˆs�6�(˜#ÒÐDÐÓDñEð )0×d 1Ð>cÒd°Fˆ�ˆs�6�(˜#ÒÐdÐÓdñeð .5×Q¨ÀyÒQ¸ˆ�ˆs�:�,˜dÒ#ÐQÐ#ÓQñ	Rð
 "7Ö7˜Aˆ�ˆs�$ÒÒ7ñ8ð '-Ö- ˆ�ˆs�)ÒÒ-ñ.ð )/Ö/ 1ˆ�ˆs�+ÒÒ/ñ0ð +0×R QÐ>QÒR°Fˆ�!��V�H˜CÒ ÐRÐ ÓRñSð +0×R QÐ>QÒR°Fˆ�!��V�H˜CÒ ÐRÐ ÓRñ	Sð +2×T QÐ@SÒT°fˆ�!��V�H˜CÒ ÐTÐ ÓTñ
Uð !(Ö(˜1ˆ�ˆs�#‚Ò(ñ)ð "*Ö*˜Aˆ���3ÒÒ*ñ+ð $)Ö)˜aˆ�1�#�SÒÒ)ñ*ð #Ö#˜ˆˆaˆS�‚}Ò#ñ$ð  &Ö&˜!ˆˆqˆc�‚~Ò&ñ'ð  "(Ö(˜Aˆ���3ÒÒ(ñ!)ð" #'Ö'˜Qˆ�!��CÒÒ'ñ#(ð$ "&Ö&˜Aˆ���3ÒÒ&ñ%'ò&ñ'óÐ ñ6  ÑRÐ>QÔRÓRÐ ôô6ð0 Ø8Øð	&Øð&àð&ð ð&ð ð	&ð
 
ó&ðV #Ø8ØØðGØ
ðGà
ðGð ðGð ð	Gð
 ðGð 
óGðX  �t—x‘x“zØØð	 Øð à
ð ð 	ð ð ð	 ð
 
ó óF$ðR #Ø!ØØØØØØØðIØ	ðIà
ðIð 
ðIð ð	Ið
 ðIð ðIð ðIð ðIð ðIð ðIð óIðZ %ØØð!AØ
ð!Aàð!Að ð!Að ó	!AðL %Øð4Ø
ð4à
ð4ð ð4ð
 	ó4ðr �—‘“
ØØØØØØð2qØ	ð2qà	ð2qð ð2qð ð	2qð
 ð2qð ð2qð ð2qð ð2qð 
ô2qùóe lùÛdùÛDùÛdùÛQùÚ7ùÚ-ùÚ/ùÛRùÛRùÛTùÚ(ùÚ*ùÚ)ùÚ#ùÚ&ùÚ(ùÚ'ùÚ&sr   ÁL
Á,LÂLÂ,LÃLÃ+L%
Ä L*
ÄL/
Ä+L4ÅL:Å+M Æ
M
ÆM
Æ4M
Ç	M
ÇM
Ç3M
ÈM$
ÈM)
