Ë
    Fêñi9¢  ã                  óv  — d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	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Zd dlZd dl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/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 e)jl                  dz  dfd	„Z7d4d
„Z8ejr                  d5d6d„«       Z:d7d„Z;d8d„Z<ejr                  d„ «       Z=ejr                  	 	 	 	 	 	 d9	 	 	 	 	 	 	 	 	 	 	 	 	 d:d„«       Z>d;d„Z?d„ Z@ e/«       ejr                  d<d„«       «       ZAd=d>d„ZB e0«       d„ «       ZC e0«       e)jl                  dz  dddfd„«       ZDd„ ZEd?d@d„ZFd„ ZGdAd„ZHdBdCd„ZIdDdEd„ZJdFd„ZKdGd „ZLdHd!„ZMejr                  dId"„«       ZNdJd#„ZOd$„ ZPd%„ ZQd&„ ZRdKdLd'„ZSdMd(„ZTd7d)„ZUd*„ ZVd+„ ZWd7d,„ZX eBd-dd¬.«        eG«         e'j²                  d-«      ZZ e'j²                  d/«      Z[ e'j²                  d0«      Z\ e'j²                  d1«      Z] e'j²                  d2«      Z^ eBd/d¬3«      Z_ eBd0d¬3«      Z` eBd1d¬3«      Zay)Né    )ÚannotationsN)Úmetadata)ÚPath)ÚSimpleNamespace)ÚARM64ÚASSETSÚ
ASSETS_URLÚAUTOINSTALLÚGITÚIS_COLABÚ	IS_DOCKERÚ	IS_JETSONÚ	IS_KAGGLEÚIS_PIP_PACKAGEÚLINUXÚLOGGERÚMACOSÚONLINEÚPYTHON_VERSIONÚ
RKNN_CHIPSÚROOTÚTORCH_VERSIONÚTORCHVISION_VERSIONÚUSER_CONFIG_DIRÚWINDOWSÚRetryÚThreadingLockedÚ	TryExceptÚ	clean_urlÚcolorstrÚ	downloadsÚis_github_action_runningÚurl2filezrequirements.txtÚ c                ó  — |r2t        j                  |«      j                  D �cg c]	  }d|vsŒ|‘Œ }}n't        | «      j	                  «       j                  «       }g }|D ]™  }|j                  «       }|sŒ|j                  d«      rŒ(|j                  d«      d   j                  «       }t        j                  d|«      x}sŒc|j                  t        |d   |d   r|d   j                  «       nd¬«      «       Œ› |S c c}w )	a/  Parse a requirements.txt file, ignoring lines that start with '#' and any text after '#'.

    Args:
        file_path (Path): Path to the requirements.txt file.
        package (str, optional): Python package to use instead of requirements.txt file.

    Returns:
        requirements (list[SimpleNamespace]): List of parsed requirements as SimpleNamespace objects with `name` and
            `specifier` attributes.

    Examples:
        >>> from ultralytics.utils.checks import parse_requirements
        >>> parse_requirements(package="ultralytics")
    z	extra == ú#r   z ([a-zA-Z0-9-_]+)\s*([<>!=~]+.*)?é   é   r$   )ÚnameÚ	specifier)r   ÚdistributionÚrequiresr   Ú	read_textÚ
splitlinesÚstripÚ
startswithÚ	partitionÚreÚmatchÚappendr   )Ú	file_pathÚpackageÚxr,   ÚrequirementsÚliner3   s          úZ/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/utils/checks.pyÚparse_requirementsr;   :   sï   € ñ Ü'×4Ñ4°WÓ=×FÑFÖ_˜!È+Ð]^ÒJ^’AÐ_ˆÑ_ä˜	“?×,Ñ,Ó.×9Ñ9Ó;ˆà€LØò tˆØ�z‰z‹|ˆÚ˜Ÿ™¨Õ,Ø—>‘> #Ó& qÑ)×/Ñ/Ó1ˆDÜŸ™Ð!DÀdÓKÐKˆuÑKØ×#Ñ#¤O¸¸q¹ÐafÐghÒaiÈUÐSTÉXÏ^É^ÔM]ÐoqÔ$rÕsðtð Ðùò `s
   ¤	C>®C>c                ó¨   — t        j                  «       D ]:  }|j                  d«      xs dj                  «       }| |v sŒ+|j                   d   c S  | S )z`Get the pip distribution name for a given import name (e.g., 'cv2' -> 'opencv-python-headless').ztop_level.txtr$   ÚName)r   Údistributionsr-   Úsplit)Úimport_nameÚdistÚ	top_levels      r:   Úget_distribution_namerC   Y   sU   € ä×&Ñ&Ó(ò )ˆØ—^‘^ OÓ4Ò:¸×AÑAÓCˆ	Ø˜)Ò#Ø—=‘= Ñ(Ò(ð)ð Ðó    c           	     óÆ   — 	 t        t        t        t        j                  d| «      dd «      «      S # t
        $ r%}t        j                  d| › d|› �«       Y d}~yd}~ww xY w)a%  Convert a version string to a tuple of integers, ignoring any extra non-numeric string attached to the version.

    Args:
        version (str): Version string, i.e. '2.0.1+cpu'

    Returns:
        (tuple): Tuple of integers representing the numeric part of the version, i.e. (2, 0, 1)
    z\d+Né   zfailure for parse_version(z), returning (0, 0, 0): )r   r   r   )ÚtupleÚmapÚintr2   ÚfindallÚ	Exceptionr   Úwarning)ÚversionÚes     r:   Úparse_versionrO   b   s[   € ðÜ”SœœbŸj™j¨°Ó9¸"¸1Ð=Ó>Ó?Ð?øÜò Ü�‰Ð3°G°9Ð<TÐUVÐTWÐXÔYÜûðús   ‚/2 ²	A »AÁA c                ó8   — t        d„ t        | «      D «       «      S )a  Check if a string is composed of only ASCII characters.

    Args:
        s (str | list | tuple | dict): Input to be checked (all are converted to string for checking).

    Returns:
        (bool): True if the string is composed only of ASCII characters, False otherwise.
    c              3  ó8   K  — | ]  }t        |«      d k  –— Œ y­w)é€   N)Úord)Ú.0Úcs     r:   ú	<genexpr>zis_ascii.<locals>.<genexpr>|   s   è ø€ Ò, Œs�1‹v˜�|Ñ,ùs   ‚)ÚallÚstr)Úss    r:   Úis_asciirZ   s   s   € ô Ñ,¤S¨£VÔ,Ó,Ð,rD   c           	     ó€  — t        t        |t        j                  «      r|j	                  «       n|«      }t        | t         «      r| g} n‰t        | t
        t        f«      rt        | «      } ngt        | t        «      r2| j                  «       rt        | «      gnt        j                  | «      } n%t        d| › dt        | «      j                  › d�«      ‚t        | «      |kD  rHd}|dk7  rt        d| › d|› �«      ‚t!        j"                  dt	        | «      › d	|› �«       t	        | «      g} | D �cg c]'  }t	        t%        j&                  ||z  «      |z  |«      ‘Œ) }}|| k7  rt!        j"                  d| › d
|› d|› �«       |dk(  rt        |«      dk(  r|d   |d   g}|S |dk(  rt        |«      dk(  r|d   }|S |}|S c c}w )a(  Verify image size is a multiple of the given stride in each dimension. If the image size is not a multiple of the
    stride, update it to the nearest multiple of the stride that is greater than or equal to the given floor value.

    Args:
        imgsz (int | list[int]): Image size.
        stride (int): Stride value.
        min_dim (int): Minimum number of dimensions.
        max_dim (int): Maximum number of dimensions.
        floor (int): Minimum allowed value for image size.

    Returns:
        (list[int] | int): Updated image size.
    z'imgsz=z' is of invalid type zK. Valid imgsz types are int i.e. 'imgsz=640' or list i.e. 'imgsz=[640,640]'z®'train' and 'val' imgsz must be an integer, while 'predict' and 'export' imgsz may be a [h, w] list or an integer, i.e. 'yolo export imgsz=640,480' or 'yolo export imgsz=640'r'   zimgsz=z is not a valid image size. zupdating to 'imgsz=z'. z  must be multiple of max stride z, updating to r(   r   )rI   Ú
isinstanceÚtorchÚTensorÚmaxÚlistrG   rX   Ú	isnumericÚastÚliteral_evalÚ	TypeErrorÚtypeÚ__name__ÚlenÚ
ValueErrorr   rL   ÚmathÚceil)ÚimgszÚstrideÚmin_dimÚmax_dimÚfloorÚmsgr7   Úszs           r:   Úcheck_imgszrr      sÊ  € ô ¤¨F´E·L±LÔ!A�—‘”ÀvÓN€Fô �%œÔØ�‰Ü	�EœD¤%˜=Ô	)Ü�U“‰Ü	�Eœ3Ô	Ø %§¡Ô 1”�U“‘´s×7GÑ7GÈÓ7N‰äØ�e�WÐ1´$°u³+×2FÑ2FÐ1Gð HXð Yó
ð 	
ô ˆ5ƒz�GÒðYð 	ð �aŠ<Ü˜v e WÐ,HÈÈÐNÓOÐOÜ�‰Ð,¬S°«Z¨L¸¸C¸5ÐAÔBÜ�U“�ˆà>CÖ	D¸Œ#Œd�i‰i˜˜F™
Ó# fÑ,¨eÕ
4Ð	D€BÐ	Dð 
ˆU‚{Ü�‰˜ ˜wÐ&FÀvÀhÈnÐ]_Ð\`ÐaÔbð # aš<¬C°«G°qªLˆ"ˆQ‰%��A‘ˆ€Bà€Ið HOÐRSÂ|ÔX[Ð\^ÓX_ÐcdÒXd¸bÀ¹e€Bà€Ið km€Bà€Iùò 
Es   Ä-,F;c                 ón   — 	 t        j                  ddgd¬«      j                  dk(  S # t        $ r Y yw xY w)zBCheck if uv package manager is installed and can run successfully.Úuvz-VT)Úcapture_outputr   F)Ú
subprocessÚrunÚ
returncodeÚFileNotFoundError© rD   r:   Úcheck_uvr{   ´   s9   € ðÜ�~‰~˜t T˜l¸4Ô@×KÑKÈqÑPÐPøÜò Ùðús   ‚%( ¨	4³4Fc                ó0  — | st        j                  d| › d|› d�«       y| d   j                  «       s	 | }t        j                  | «      } |syd	|v r#t        rd
|vst        rd|vst        r	d|vrd|vryd}d}d}	t        | «      }
|j                  d«      j                  d«      D ]‡  }t        j                  d|«      j                  «       \  }}|sd}t        |«      }|dk(  r|
|k7  rd}	ŒF|dk(  r|
|k(  rd}	ŒS|dk(  r|
|k\  sd}	Œ`|dk(  r|
|k  sd}	Œm|dk(  r|
|kD  sd}	Œz|dk(  sŒ€|
|k  rŒ†d}	Œ‰ |	s3|› |› d|› d| › d|› �}|rt        |«      ‚|rt        j                  |«       |	S # t        j
                  $ r}|rt        | › d�«      |‚Y d}~yd}~ww xY w)aŒ  Check current version against the required version or range.

    Args:
        current (str): Current version or package name to get version from.
        required (str): Required version or range (in pip-style format).
        name (str): Name to be used in warning message.
        hard (bool): If True, raise a ModuleNotFoundError if the requirement is not met.
        verbose (bool): If True, print warning message if requirement is not met.
        msg (str): Extra message to display if verbose.

    Returns:
        (bool): True if requirement is met, False otherwise.

    Examples:
        Check if current version is exactly 22.04
        >>> check_version(current="22.04", required="==22.04")

        Check if current version is greater than or equal to 22.04
        >>> check_version(current="22.10", required="22.04")  # assumes '>=' inequality if none passed

        Check if current version is less than or equal to 22.04
        >>> check_version(current="22.04", required="<=22.04")

        Check if current version is between 20.04 (inclusive) and 22.04 (exclusive)
        >>> check_version(current="21.10", required=">20.04,<22.04")
    zinvalid check_version(ú, z!) requested, please check values.Tr   z& package is required but not installedNFÚsys_platformÚwin32ÚlinuxÚmacosÚdarwinr$   ú,z([^0-9]*)([\d.]+)ú>=z==z!=z<=ú>ú<z is required, but z is currently installed )r   rL   Úisdigitr   rM   ÚPackageNotFoundErrorÚModuleNotFoundErrorr   r   r   rO   r/   r?   r2   r3   Úgroups)ÚcurrentÚrequiredr)   ÚhardÚverboserp   rN   ÚoprM   ÚresultrU   ÚrÚvrL   s                 r:   Úcheck_versionr“   ½   sâ  € ñF Ü�‰Ð/°¨y¸¸8¸*ÐDeÐfÔgØØ�Q‰Z×ÑÔ!ð	ØˆDÜ×&Ñ& wÓ/ˆGñ Øà˜Ñ!Ý	�W HÑ,Ý�g XÑ-Ý�g XÑ-°(À(Ñ2Jàà	€BØ€GØ€FÜ�gÓ€AØ�^‰^˜CÓ ×&Ñ& sÓ+ò ˆÜ—h‘hÐ3°QÓ7×>Ñ>Ó@‰ˆˆGÙØˆBÜ˜'Ó"ˆØ�Š:˜!˜qš&Ø‰FØ�4ŠZ˜A šFØ‰FØ�4ŠZ  a¢Ø‰FØ�4ŠZ  a¢Ø‰FØ�3ŠY  A¢Ø‰FØ�3‹Y  A£Ø‰Fð!ñ" Ø�F˜8˜*Ð$6°t°f¸B¸w¸iÐG_Ð`cÐ_dÐeˆÙÜ% gÓ.Ð.ÙÜ�N‰N˜7Ô#Ø€MøôW ×,Ñ,ò 	ÙÜ)¨W¨IÐ5[Ð*\Ó]ÐcdÐdäûð		ús   ´E' Å'FÅ:FÆFc                óì   — ddl }	 |j                  j                  j                  «        |j	                  d| › d�d¬«      }|j
                  dk(  r|j                  «       d   d	   S y# t        $ r Y yw xY w)
a  Return the latest version of a PyPI package without downloading or installing it.

    Args:
        package_name (str): The name of the package to find the latest version for.

    Returns:
        (str | None): The latest version of the package, or None if unavailable.
    r   Nzhttps://pypi.org/pypi/z/jsonrF   )ÚtimeoutéÈ   ÚinforM   )ÚrequestsÚpackagesÚurllib3Údisable_warningsÚgetÚstatus_codeÚjsonrK   )Úpackage_namer˜   Úresponses      r:   Úcheck_latest_pypi_versionr¡     s|   € ó ðØ×Ñ×!Ñ!×2Ñ2Ô4Ø—<‘<Ð"8¸¸ÀeÐ LÐVW�<ÓXˆØ×Ñ 3Ò&Ø—=‘=“? 6Ñ*¨9Ñ5Ð5ð 'øäò Ùðús   †AA' Á'	A3Á2A3c                 ó²   — t         rBt        r<	 ddlm}  t	        «       }t        | d|› �«      rt        j                  d|› d�«       y	 yy# t        $ r Y yw xY w)z›Check if a new version of the ultralytics package is available on PyPI.

    Returns:
        (bool): True if an update is available, False otherwise.
    r   )Ú__version__r†   z)New https://pypi.org/project/ultralytics/u8    available ðŸ˜ƒ Update with 'pip install -U ultralytics'TF)	r   r   Úultralyticsr£   r¡   r“   r   r—   rK   )r£   Úlatests     r:   Úcheck_pip_update_availabler¦   )  sn   € õ •.ð	Ý/ä.Ó0ˆFÜ˜[¨A¨f¨X¨,Ô7Ü—‘Ø?À¸xð H?ð @ôð ð 8ñ øô ò 	ØØð	ús   Ž8A
 Á
	AÁAc                óT  — ddl m} t        | «      j                  }t        |z  }|j                  «       r|S |j                  «       D �cg c]	  }| |v sŒ|‘Œ }}t        |«      r|d   S t        › d|› �}t        j                  |d¬«      rt        j                  ||¬«       |S yc c}w )zÔFind font locally or download to user's configuration directory if it does not already exist.

    Args:
        font (str): Path or name of font.

    Returns:
        (Path | str): Resolved font file path.
    r   )Úfont_managerú/T)Úcheck)ÚurlÚfileN)Ú
matplotlibr¨   r   r)   r   ÚexistsÚfindSystemFontsÚanyr	   r!   Úis_urlÚsafe_download)Úfontr¨   r)   r¬   rY   Úmatchesr«   s          r:   Ú
check_fontrµ   ?  s¥   € õ (ô �‹:�?‰?€DÜ˜TÑ!€DØ‡{�{„}Øˆð '×6Ñ6Ó8ÖF�Q¸DÀAºIŠqÐF€GÐFÜ
ˆ7„|Ø�q‰zÐô ˆL˜˜$˜Ð
 €CÜ×Ñ˜ 4Õ(Ü×Ñ C¨dÕ3Øˆð )ùò Gs   Á		B%ÁB%Tc                ó*   — t        t        | d||¬«      S )aš  Check current python version against the required minimum version.

    Args:
        minimum (str): Required minimum version of python.
        hard (bool): If True, raise a ModuleNotFoundError if the requirement is not met.
        verbose (bool): If True, print warning message if requirement is not met.

    Returns:
        (bool): Whether the installed Python version meets the minimum constraints.
    ÚPython)r)   r�   rŽ   )r“   r   )Úminimumr�   rŽ   s      r:   Úcheck_pythonr¹   ^  s   € ô œ¨°xÀdÐT[Ô\Ð\rD   c                óÚ  ‡— t        ddd«      }g }| D ]k  Š	 t        j                  dd‰gddd¬«      }|j                  d	k7  s,t	        ˆfd
„|j
                  j                  «       D «       «      s|j                  ‰«       Œm |rÈt        j                  |› ddt        |«      dkD  z  › d|› d�«       t        «       rdgng ddgz   }t        j                  |ddd¬«      }t        «       rdgng g d¢z   |z   }t        j                  |ddd¬«      }t        j                  |› d�«       t        j                  |› dt        dd«      › d�«       yy# t        $ r |j                  ‰«       Y �ŒVw xY w)zŸCheck if apt packages are installed and install missing ones.

    Args:
        requirements (list[str]): List of apt package names to check and install.
    ÚredÚboldzapt requirements:Údpkgz-lTF)ru   Útextrª   r   c              3  óL   •K  — | ]  }|j                  d «      xr ‰|v –— Œ y­w)ÚiiN)r0   )rT   r9   r6   s     €r:   rV   z)check_apt_requirements.<locals>.<genexpr>{  s+   øè ø€ ò 1Ø>B�—‘ Ó%Ò9¨'°T¨/Ó9ñ1ùs   ƒ!$ú Ultralytics requirementrY   r'   ú ú$ not found, attempting AutoUpdate...ÚsudoÚaptÚupdate)rª   ru   r¾   )rÅ   Úinstallz-yu    AutoUpdate success âœ…ú;Restart runtime or rerun command for updates to take effectú
N)r    rv   rw   rx   r°   Ústdoutr.   r4   rK   r   r—   rg   Úis_sudo_availablerL   )r8   ÚprefixÚmissing_packagesr�   Úcmdr6   s        @r:   Úcheck_apt_requirementsrÏ   l  sˆ  ø€ ô �e˜VÐ%8Ó9€FàÐØò -ˆð
	-ä—^‘^ V¨T°7Ð$;ÈDÐW[ÐchÔiˆFà× Ñ  AÒ%¬Só 1ØFLÇmÁm×F^ÑF^ÓF`ô1ô .ð !×'Ñ'¨Ô0øð-ñ Ü�‰ØˆhÐ.¨s´cÐ:JÓ6KÈaÑ6OÑ/PÐ.QÐQRÐScÐRdð  eIð  Jô	
ô -Ô.�‰x°B¸5À(Ð:KÑKˆÜ—‘ ¨4ÀÈ4ÔPˆô -Ô.�‰x°BÒ:RÑRÐUeÑeˆÜ—‘ ¨4ÀÈ4ÔPˆä�‰�v�hÐ5Ð6Ô7Ü�‰˜&˜ ¤8¨FÐ4qÓ#rÐ"sÐsuÐvÕwð øô ò 	-à×#Ñ# G×,ð	-ús   —A(EÅE*Å)E*rz   c                óÌ  — t        ddd«      }t        j                  j                  dd«      dk(  rt	        j
                  |› d�«       yt        | t        «      rm| j                  «       }|j                  «       sJ |› d	|› d
�«       ‚t        |«      D �cg c]+  }|j                  |vsŒ|j                  › |j                  › �‘Œ- } }nt        | t        «      r| g} g }| D ]ò  }t        |t        t        f«      r|n|g}	d}
|	D ]  }|j!                  d«      d   j#                  dd«      }t%        j&                  d|«      }|d   |d   r|d   j)                  «       nd}}	 t+        t-        j.                  |«      |«      rd}
 nŒ� |
rŒ§|	d   }d|v r2|j5                  d«      \  }}}t%        j6                  dd|«      |z   |z   }|j9                  |«       Œô t;        dd¬«      d„ «       }d	j=                  d„ |D «       «      }|rä|rát>        rÛtA        |«      }t	        j
                  |› dd|dkD  z  › d	|› d�«       	 tC        jB                  «       }tD        sJ d«       ‚tF         xr
 tI        «       }t	        j
                   ||||¬«      «       tC        jB                  «       |z
  }t	        j
                  |› d|d ›d�«       t	        jJ                  |› d	t        dd!«      › d"�«       yyyc c}w # t0        t,        j2                  f$ r Y �Œw xY w# tL        $ rP}|› d#|› �}tO        |d$«      r|jP                  r|d"|jP                  › �z  }t	        jJ                  |«       Y d%}~yd%}~ww xY w)&a¶  Check if installed dependencies meet Ultralytics YOLO models requirements and attempt to auto-update if needed.

    Args:
        requirements (Path | str | list[str|tuple] | tuple[str]): Path to a requirements.txt file, a single package
            requirement as a string, a list of package requirements as strings, or a list containing strings and tuples
            of interchangeable packages.
        exclude (tuple): Tuple of package names to exclude from checking.
        install (bool): If True, attempt to auto-update packages that don't meet requirements.
        cmds (str): Additional commands to pass to the pip install command when auto-updating.

    Examples:
        >>> from ultralytics.utils.checks import check_requirements

        Check a requirements.txt file
        >>> check_requirements("path/to/requirements.txt")

        Check a single package
        >>> check_requirements("ultralytics>=8.3.200", cmds="--index-url https://download.pytorch.org/whl/cpu")

        Check multiple packages
        >>> check_requirements(["numpy", "ultralytics"])

        Check with interchangeable packages
        >>> check_requirements([("onnxruntime", "onnxruntime-gpu"), "numpy"])
    r»   r¼   zrequirements:Ú$ULTRALYTICS_SKIP_REQUIREMENTS_CHECKSÚ0Ú1zN ULTRALYTICS_SKIP_REQUIREMENTS_CHECKS=1 detected, skipping requirements check.TrÂ   z not found, check failed.Fr©   éÿÿÿÿz.gitr$   z([a-zA-Z0-9-_]+)([<>!=~]+.*)?r'   r(   r   zgit+ú;z[<>!=~]+.*$)ÚtimesÚdelayc           	     ó   — |r?t        j                  dt        j                  › d| › d|› d�dt         j                  d¬«      S t        j                  dt        j                  › d| › d|› �dt         j                  d¬«      S )	zGAttempt package installation with uv if available, falling back to pip.z(uv pip install --no-cache-dir --python "z" rÂ   z; --index-strategy=unsafe-best-match --break-system-packagesT)ÚshellÚstderrr¾   ú"z " -m pip install --no-cache-dir )rv   Úcheck_outputÚsysÚ
executableÚSTDOUT)r™   ÚcommandsÚuse_uvs      r:   Úattempt_installz+check_requirements.<locals>.attempt_installÓ  s“   € ñ ô ×*Ñ*Ø:¼3¿>¹>Ð:JÈ"ÈXÈJÐVWÐX`ÐWað bMð NàÜ!×(Ñ(Øôð ô ×&Ñ&Ø”—‘ÐÐ?À¸zÈÈ8È*ÐUØÜ×$Ñ$Øô	
ð 	
rD   c              3  ó(   K  — | ]
  }d |› d �–— Œ y­w)rÛ   Nrz   )rT   r7   s     r:   rV   z%check_requirements.<locals>.<genexpr>ç  s   è ø€ Ò(˜a�1�Q�C�q”Ñ(ùs   ‚rÁ   rY   rÃ   zAutoUpdate skipped (offline))rá   u    AutoUpdate success âœ… ú.1frÈ   rÉ   u    â�Œ ÚoutputN))r    ÚosÚenvironrœ   r   r—   r\   r   Úresolver®   r;   r)   r*   rX   r`   rG   Ú
rpartitionÚreplacer2   r3   r/   r“   r   rM   ÚAssertionErrorrˆ   r1   Úsubr4   r   Újoinr
   rg   Útimer   r   r{   rL   rK   Úhasattrrå   )r8   ÚexcluderÇ   ÚcmdsrÌ   r¬   r7   Úpkgsr‘   Ú
candidatesÚ	satisfiedÚ	candidateÚ
r_strippedr3   r)   rŒ   Úpkgr«   ÚsepÚmarkerrâ   rY   ÚnÚtrá   ÚdtrN   rp   s                               r:   Úcheck_requirementsrý   ”  sS  € ô6 �e˜V _Ó5€Fä	‡z�z‡~�~Ð<¸cÓBÀcÒIÜ�‰�v�hÐlÐmÔnØä�,¤Ô%Ø×#Ñ#Ó%ˆØ�{‰{Œ}ÐI  ¨¨$¨Ð/HÐIÓIˆ}Ü:LÈTÓ:RÖl°QÐVW×V\ÑV\ÐdkÒVk˜1Ÿ6™6˜( 1§;¡; -Ò0ÐlˆÑlÜ	�L¤#Ô	&Ø$�~ˆà€DØò ˆÜ$ Q¬¬u¨Ô6‘Q¸Q¸Cˆ
Øˆ	à#ò 		ˆIØ"×-Ñ-¨cÓ2°2Ñ6×>Ñ>¸vÀrÓJˆJÜ—H‘HÐ=¸zÓJˆEØ" 1™X¸5Àº8 u¨Q¡x§~¡~Ô'7È�(ˆDðÜ ¤×!1Ñ!1°$Ó!7¸ÔBØ $�IÙð Cð		ò Ø˜Q‘-ˆCØ˜‰}Ø#&§=¡=°Ó#5Ñ ��S˜&Ü—f‘f˜^¨R°Ó5¸Ñ;¸fÑD�Ø�K‰K˜Õð)ô, �˜!Ôñ
ó ð
ð& 	�‰Ñ( 4Ô(Ó(€AÙÙ•{ä�D“	ˆAÜ�K‰K˜6˜(Ð":¸3À!ÀaÁ%¹=¸/ÈÈ4È&ÐPtÐuÔvðÜ—I‘I“K�ÝÐ=Ð=Ó=�vÜ"˜Ò1¤x£z�Ü—‘™O¨A¨t¸FÔCÔDÜ—Y‘Y“[ 1‘_�Ü—‘˜v˜hÐ&>¸rÀ#¸hÀaÐHÔIÜ—‘Ø�h˜a¤¨Ð1nÓ oÐpÐprÐsôð ð àùòQ møô" #¤H×$AÑ$AÐBò Úðûô\ ò Ø˜  a SÐ)�Ü˜1˜hÔ'¨A¯HªHØ˜R §¡˜z˜?Ñ*�CÜ—‘˜sÔ#Üûðús8   ÂK%Â(K%Å!K*È8B*L
 Ë*LÌLÌ
	M#ÌAMÍM#c                 ó    — t         rt        rt        rt        d«       t        ddt	        j
                  d«      d   › �¬«       t        d«       y)	zSCheck and install ExecuTorch requirements including platform-specific dependencies.zpackaging>=22.0Ú
executorchztorch==ú+r   )rñ   znumpy<=2.3.5N)r   r   r   rý   r   r?   rz   rD   r:   Úcheck_executorch_requirementsr    s>   € õ •�9ÜÐ,Ô-ä�|¨G´M×4GÑ4GÈÓ4LÈQÑ4OÐ3PÐ*QÕRä�~Õ&rD   c                óŽ   — t         r?t        j                  j                  j	                  d«      d   }t        d|› d| › d�«       yy)z³Check and install TensorRT requirements including platform-specific dependencies.

    Args:
        min_version (str): Minimum supported TensorRT version (default: "7.0.0").
    ú.r   ztensorrt-cur„   z	,!=10.1.0N)r   r]   rM   Úcudar?   rý   )Úmin_versionÚcuda_versions     r:   Úcheck_tensorrtr    sB   € õ Ü—}‘}×)Ñ)×/Ñ/°Ó4°QÑ7ˆÜ˜[¨¨°b¸¸ÀYÐOÕPð rD   c                 óª  ‡— dgdgdgdgdgdgdgdgd	gd
gdgdgdgdœ} dj                  t        j                  dd«      d   j                  d«      dd «      }|| v rw| |   }dj                  t        j                  dd«      d   j                  d«      dd «      Št	        ˆfd„|D «       «      r#t        j                  d‰› d|› d|d   › d�«       yyy)a,  Check the installed versions of PyTorch and Torchvision to ensure they're compatible.

    This function checks the installed versions of PyTorch and Torchvision, and warns if they're incompatible according
    to the compatibility table based on: https://github.com/pytorch/vision#installation.
    z0.25z0.24z0.23z0.22z0.21z0.20z0.19z0.18z0.17z0.16z0.15z0.14z0.13)z2.10z2.9z2.8z2.7z2.6z2.5z2.4z2.3z2.2z2.1z2.0z1.13z1.12r  r   r'   r   Nr(   c              3  ó(   •K  — | ]	  }‰|k7  –— Œ y ­w)Nrz   )rT   r’   Úv_torchvisions     €r:   rV   z$check_torchvision.<locals>.<genexpr>4  s   øè ø€ Ò? aˆ} Õ!Ñ?ùs   ƒztorchvision==z is incompatible with torch==z .
Run 'pip install torchvision==zœ' to fix torchvision or 'pip install -U torch torchvision' to update both.
For a full compatibility table see https://github.com/pytorch/vision#installation)rí   r   r?   r   rW   r   rL   )Úcompatibility_tableÚv_torchÚcompatible_versionsr
  s      @r:   Úcheck_torchvisionr    s  ø€ ð �ØˆxØˆxØˆxØˆxØˆxØˆxØˆxØˆxØˆxØˆxØ�Ø�ñÐð" �h‰h”}×*Ñ*¨3°Ó2°1Ñ5×;Ñ;¸CÓ@ÀÀ!ÐDÓE€GØÐ%Ñ%Ø1°'Ñ:ÐØŸ™Ô!4×!:Ñ!:¸3ÀÓ!BÀ1Ñ!E×!KÑ!KÈCÓ!PÐQSÐRSÐ!TÓUˆÜÓ?Ð+>Ô?Ô?Ü�N‰NØ ˜Ð.KÈGÈ9ð U1Ø1DÀQÑ1GÐ0Hð Idðdõð @ð &rD   c                ó  — | r‹|rˆt        |t        «      r|h}t        | t        t        f«      r| n| gD ]V  }t        |«      j	                  d«      d   j                  «       j                  «       x}sŒ?d|› �|v rŒGJ |› |› d|› d|› �«       ‚ yyy)zýCheck file(s) for acceptable suffix.

    Args:
        file (str | list[str]): File or list of files to check.
        suffix (str | tuple): Acceptable suffix or tuple of suffixes.
        msg (str): Additional message to display in case of error.
    r  rÔ   z acceptable suffix is z, not .N)r\   rX   r`   rG   ré   Úlowerr/   )r¬   Úsuffixrp   ÚfrY   s        r:   Úcheck_suffixr  =  s¦   € ñ ‘Ü�fœcÔ"Ø�XˆFÜ# D¬4´¨-Ô8‘¸t¸fò 	^ˆAÜ˜“F×%Ñ% cÓ*¨2Ñ.×4Ñ4Ó6×<Ñ<Ó>Ð>ˆqÑ>Ø˜1˜#�w &Ò(Ð]¨S¨E°!°Ð4JÈ6È(ÐRYÐZ[ÐY\Ð*]Ó]Ð(ñ	^ð €trD   c                ó*  — d| v sd| v rŠd| v r| j                  dd«      } | S d| v rnd| vrj| }t        j                  dd| «      } t        j                  d	d| «      } t        j                  d
d| «      } | |k7  r|rt        j                  d|› d| › d�«       | S )a  Replace legacy YOLOv5 filenames with updated YOLOv5u filenames.

    Args:
        file (str): Filename to check and potentially update.
        verbose (bool): Whether to print information about the replacement.

    Returns:
        (str): Updated filename.
    Úyolov3Úyolov5zu.yamlú.yamlú.ptÚuz(.*yolov5([nsmlx]))\.ptz\1u.ptz(.*yolov5([nsmlx])6)\.ptz(.*yolov3(|-tiny|-spp))\.ptu   PRO TIP ðŸ’¡ Replace 'model=z' with new 'model=zÀ'.
YOLOv5 'u' models are trained with https://github.com/ultralytics/ultralytics and feature improved performance vs standard YOLOv5 models trained with https://github.com/ultralytics/yolov5.
)rê   r2   rì   r   r—   )r¬   rŽ   Úoriginal_files      r:   Úcheck_yolov5u_filenamer  M  s¹   € ð �4Ñ˜8 tÑ+Ø�tÑØ—<‘< ¨'Ó2ˆDð €Kð �d‰]˜s¨$™Ø ˆMÜ—6‘6Ð4°iÀÓFˆDÜ—6‘6Ð5°yÀ$ÓGˆDÜ—6‘6Ð8¸)ÀTÓJˆDØ�}Ò$©Ü—‘Ø2°=°/ÐASÐTXÐSYð Zcð dôð
 €KrD   c                óŽ   — t        | «      }|j                  s-|j                  t        j                  v r|j                  d«      S | S )z¶Return a model filename from a valid model stem.

    Args:
        model (str): Model stem to check.

    Returns:
        (str | Path): Model filename with appropriate suffix.
    r  )r   r  Ústemr!   ÚGITHUB_ASSETS_STEMSÚwith_suffix)ÚmodelÚpaths     r:   Úcheck_model_file_from_stemr"  h  s;   € ô �‹;€DØ�;Š;˜4Ÿ9™9¬	×(EÑ(EÑEØ×Ñ Ó&Ð&Ø€LrD   c                óä  — t        | |«       t        | «      j                  «       } t        | «      } | r<d| vrt	        | «      j                  «       s| j                  «       j                  d«      r| S |�r(| j                  «       j                  d«      �rddlm	}  || |¬«      }|€g S t	        | dd «      }|j                  «       sd	|j                  v rt        d
| › �«      ‚t	        |«      |z  t        |«      z  }|j                  dk(  r|j                  d¬«       |j                  «       r/t!        j"                  dt%        |«      › d|› �«       t        |«      S |j&                  j)                  dd¬«       t+        j,                  ||d¬«       t        |«      S |r³| j                  «       j                  d«      r”| j                  d«      rd| dd z   } | }t	        |«      t        | «      z  } | j                  «       r/t!        j"                  dt%        |«      › d| › �«       t        | «      S t+        j,                  || d¬«       t        | «      S t/        j.                  t        t0        dz  | z  «      d¬«      xs/ t/        j.                  t        t0        j&                  | z  «      «      }	|	s|rt3        d| › d�«      ‚t5        |	«      dkD  r|rt3        d| › d|	› �«      ‚t5        |	«      r|	d   S g S )aK  Search/download file (if necessary), check suffix (if provided), and return path.

    Args:
        file (str): File name or path, URL, platform URI (ul://), or GCS path (gs://).
        suffix (str | tuple): Acceptable suffix or tuple of suffixes to validate against the file.
        download (bool): Whether to download the file if it doesn't exist locally.
        download_dir (str): Directory to download the file to.
        hard (bool): Whether to raise an error if the file is not found.

    Returns:
        (str | list): Path to the file, or an empty list if not found.
    z://zgrpc://zul://r   )Úresolve_platform_uri©r�   Né   z..z&Unsafe Ultralytics Platform URI path: z.ndjsonT)Ú
missing_okzFound z locally at )ÚparentsÚexist_okF)r«   r¬   Úunzip)zhttps://zhttp://zrtsp://zrtmp://ztcp://úgs://r+  zhttps://storage.googleapis.com/z**)Ú	recursiveú'z' does not existr'   zMultiple files match 'z', specify exact path: )r  rX   r/   r  r   r®   r  r0   Ú$ultralytics.utils.callbacks.platformr$  Úis_absoluteÚpartsrh   r#   r  Úunlinkr   r—   r   ÚparentÚmkdirr!   r²   Úglobr   ry   rg   )
r¬   r  ÚdownloadÚdownload_dirr�   r$  r«   Úuri_pathÚ
local_fileÚfiless
             r:   Ú
check_filer:  w  sž  € ô ��vÔÜˆt‹9�?‰?Ó€DÜ! $Ó'€DáØ˜Ñ¤$ t£*×"3Ñ"3Ô"5Ø�:‰:‹<×"Ñ" 9Ô-àˆÚ	�d—j‘j“l×-Ñ-¨gÕ6ÝMá" 4¨dÔ3ˆØˆ;ØˆIä˜˜Q˜R˜“>ˆØ×ÑÔ! T¨X¯^©^Ñ%;ÜÐEÀdÀVÐLÓMÐMÜ˜,Ó'¨(Ñ2´X¸c³]ÑBˆ
à×Ñ 	Ò)Ø×Ñ¨ÐÔ.Ø×ÑÔÜ�K‰K˜&¤¨3£Ð 0°¸Z¸LÐIÔJô �:‹Ðð ×Ñ×#Ñ#¨D¸4Ð#Ô@Ü×#Ñ#¨°*ÀEÕJÜ�:‹ÐÙ	�d—j‘j“l×-Ñ-ØHôð �?‰?˜7Ô#Ø4°t¸A¸B°xÑ?ˆDØˆÜ�LÓ!¤H¨T£NÑ2ˆØ�;‰;Œ=Ü�K‰K˜&¤¨3£Ð 0°¸T¸FÐCÔDô �4‹yÐô ×#Ñ#¨°$¸eÕDÜ�4‹yÐä—	‘	œ#œd T™k¨DÑ0Ó1¸TÔBÒhÄdÇiÁiÔPSÔTX×T_ÑT_ÐbfÑTfÓPgÓFhˆÙ™Ü# a¨ vÐ-=Ð$>Ó?Ð?Ü�‹Z˜!Š^¡Ü#Ð&<¸T¸FÐBYÐZ_ÐY`Ð$aÓbÐbÜ˜uœ:ˆu�Q‰xÐ-¨2Ð-rD   c                ó   — t        | ||¬«      S )aa  Search/download YAML file (if necessary) and return path, checking suffix.

    Args:
        file (str | Path): File name or path.
        suffix (tuple): Tuple of acceptable YAML file suffixes.
        hard (bool): Whether to raise an error if the file is not found or multiple files are found.

    Returns:
        (str): Path to the YAML file.
    r%  )r:  )r¬   r  r�   s      r:   Ú
check_yamlr<  ¶  s   € ô �d˜F¨Ô.Ð.rD   c                óè   — t        | «      j                  «       }t        |«      j                  «       }|j                  «       xr/ |j                  dt	        |j                  «       |j                  k(  S )a  Check if the resolved path is under the intended directory to prevent path traversal.

    Args:
        basedir (Path | str): The intended directory.
        path (Path | str): The path to check.

    Returns:
        (bool): True if the path is safe, False otherwise.
    N)r   rè   r®   r0  rg   )Úbasedirr!  Úbase_dir_resolvedÚpath_resolveds       r:   Úcheck_is_path_saferA  Ä  sc   € ô ˜W›×-Ñ-Ó/ÐÜ˜“J×&Ñ&Ó(€Mà×ÑÓ!Òt m×&9Ñ&9Ð:X¼CÐ@Q×@WÑ@WÓ<XÐ&YÐ]n×]tÑ]tÑ&tÐtrD   c                ó®  — 	 t         r't        st        rJ ‚dt        j                  v sJ d«       ‚t        j                  dt        j                  dt        j                  ¬«      «       t        j                  d«       t        j                  «        t        j                  d«       y# t        $ r$}| rt        j                  d|› �«       Y d	}~y
d	}~ww xY w)zíCheck if environment supports image displays.

    Args:
        warn (bool): Whether to warn if environment doesn't support image displays.

    Returns:
        (bool): True if environment supports image displays, False otherwise.
    ÚDISPLAYz+The DISPLAY environment variable isn't set.Útest)é   rE  rF   )Údtyper'   Tz>Environment does not support cv2.imshow() or PIL Image.show()
NF)r   r   r   ræ   rç   Úcv2ÚimshowÚnpÚzerosÚuint8ÚwaitKeyÚdestroyAllWindowsrK   r   rL   )ÚwarnrN   s     r:   Úcheck_imshowrO  Ô  s›   € ðÝÝ­	Ð1Ð1Ø¤§
¡
Ñ*ÐYÐ,YÓYÐ*Ü�
‰
�6œ2Ÿ8™8 I´R·X±XÔ>Ô?Ü�‰�AŒÜ×ÑÔÜ�‰�AŒØøÜò ÙÜ�N‰NÐ\Ð]^Ð\_Ð`ÔaÜûðús   ‚B$B' Â'	CÂ0CÃCc           	     óê  — ddl }ddlm} t        rt	        j
                  dd¬«       | r}d}|j                  «       j                  }t	        j                  d«      \  }}}d	t        j                  «       › d
||z  d›d||z
  |z  d›d||z  d›d�	}		 ddlm}
 |
j                  «        nd}	t        j                   r
t#        «         ||d¬«       t%        j&                  d|	› �«       y# t        $ r Y ŒHw xY w)zÅPrint a human-readable YOLO software and hardware summary.

    Args:
        verbose (bool): Whether to print verbose information.
        device (str | torch.device): Device to use for YOLO.
    r   N)Úselect_deviceÚsample_dataT)Úignore_errorsé   @r©   ú(z CPUs, rä   z	 GB RAM, z	 GB disk))Údisplayr$   F)ÚdeviceÚnewlineu   Setup complete âœ… )ÚpsutilÚultralytics.utils.torch_utilsrQ  r   ÚshutilÚrmtreeÚvirtual_memoryÚtotalÚ
disk_usageræ   Ú	cpu_countÚIPythonrV  Úclear_outputÚImportErrorr   Úis_repoÚcheck_multiple_installr   r—   )rŽ   rW  rY  rQ  ÚgibÚramr^  Ú_usedÚfreerY   rV  s              r:   Ú
check_yolorj  í  sð   € ó å;åÜ�‰�m°4Õ8áàˆØ×#Ñ#Ó%×+Ñ+ˆÜ#×.Ñ.¨sÓ3Ñˆˆu�dØ”—‘“Ð˜w s¨S¡y° o°YÀÈÁÐPSÑ?SÐTWÐ>XÐXYÐZ_ÐbeÑZeÐfiÐYjÐjsÐtˆð	Ý'à× Ñ Õ"ð ˆä
‡{‚{ÜÔ á˜¨Õ/Ü
‡K�KÐ% a SÐ)Õ*øô ò 	Ùð	ús   ÂC& Ã&	C2Ã1C2c                 ó,  — ddl } ddlm} ddlm}m} d}t        j                  j                  «       }t        «        t        j                  d«      \  }}}t        j                  «       |t        t        j                  rdn	t         rdnd	t#        t$        «      | j'                  «       j(                  |z  d
›d�||z
  |z  d›d||z  d›d� |«       t+        j,                  «       |r	 |d¬«      nd|rt        j                  j/                  «       nd|rt        j0                  j                  nddœ}	t3        j4                  ddj7                  d„ |	j9                  «       D «       «      z   dz   «       i }
t;        t=        d«      ¬«      D ]¢  }	 t?        j0                  |j@                  «      }tC        |t#        |jD                  «      |j@                  d¬«      rdnd}|› |› |jD                  › �|
|j@                  <   t3        j4                  |j@                  d›|
|j@                     › �«       Œ¤ |
|	d<   tI        «       r¼t+        jJ                  d«      t+        jJ                  d«      t+        jJ                  d«      t+        jJ                  d«      t+        jJ                  d«      t+        jJ                  d«      d œ}t3        j4                  ddj7                  d!„ |j9                  «       D «       «      z   «       ||	d"<   |	S # t>        jF                  $ r d}d}Y �Œ9w xY w)#z¤Collect and print relevant system information including OS, Python, RAM, CPU, and CUDA.

    Returns:
        (dict): Dictionary containing system information.
    r   N)ÚENVIRONMENT)Úget_cpu_infoÚget_gpu_inforT  r©   ÚgitÚpipÚotherz.2fz GBrä   )Úindex)ÚOSÚEnvironmentr·   ÚInstallr   ÚRAMÚDiskÚCPUz	CPU countÚGPUz	GPU countÚCUDArÉ   c              3  ó0   K  — | ]  \  }}|d ›|› �–— Œ y­w)ú<23Nrz   ©rT   Úkr’   s      r:   rV   z&collect_system_info.<locals>.<genexpr>/  s   è ø€ Ò M±4°1°a A c 7¨1¨#¤Ñ Mùó   ‚r¤   )r6   T)r)   r�   u   âœ… u   â�Œ z(not installed)r|  zPackage InfoÚ	RUNNER_OSÚGITHUB_EVENT_NAMEÚGITHUB_WORKFLOWÚGITHUB_ACTORÚGITHUB_REPOSITORYÚGITHUB_REPOSITORY_OWNER)r€  r�  r‚  rƒ  r„  r…  c              3  ó0   K  — | ]  \  }}|› d |› �–— Œ y­w)ú: Nrz   r}  s      r:   rV   z&collect_system_info.<locals>.<genexpr>G  s   è ø€ Ò$Q±T°Q¸¨ s¨"¨Q¨C¤[Ñ$Qùr  zGitHub Info)&rY  Úultralytics.utilsrl  rZ  rm  rn  r]   r  Úis_availablerj  r[  r_  Úplatformr   r   rd  r   rX   r   r]  r^  ræ   r`  Údevice_countrM   r   r—   rí   Úitemsr;   rC   r   r)   r“   r*   rˆ   r"   Úgetenv)rY  rl  rm  rn  rf  r  r^  Ú_ri  Ú	info_dictÚpackage_infor‘   r‹   Úis_metÚgithub_infos                  r:   Úcollect_system_infor“    s„  € ó å-ßHà
€CÜ�:‰:×"Ñ"Ó$€DÜ„LÜ×&Ñ& sÓ+�N€Eˆ1ˆdô ×ÑÓ!Ø"Ü ÜŸKšK‘5µn©UÈ'Ü”D“	Ø×'Ñ'Ó)×/Ñ/°#Ñ5°cÐ:¸#Ð>Ø˜D‘L CÑ'¨Ð,¨A¨e°c©k¸#Ð->¸cÐBÙ‹~Ü—\‘\“^Ù(,‰| !Õ$°$Ù26”U—Z‘Z×,Ñ,Ô.¸DÙ&*”—‘×"Ò"°ñ€Iô ‡K�K��t—y‘yÑ M¸9¿?¹?Ó;LÔ MÓMÑMÐPTÑTÔUà€LÜÔ(=¸mÓ(LÔMò ;ˆð	Ü×&Ñ& q§v¡vÓ.ˆGÜ,¨W´c¸!¿+¹+Ó6FÈQÏVÉVÐZ^Õ_‘VÐekˆFð #) ¨'¨°1·;±;°-Ð@ˆ�Q—V‘VÑÜ�‰�q—v‘v˜c�l <°·±Ñ#7Ð"8Ð9Õ:ð;ð !-€IˆnÑäÔ!äŸ™ ;Ó/Ü!#§¡Ð+>Ó!?Ü!Ÿy™yÐ):Ó;ÜŸI™I nÓ5Ü!#§¡Ð+>Ó!?Ü')§y¡yÐ1JÓ'Kñ
ˆô 	�‰�D˜4Ÿ9™9Ñ$Q¸[×=NÑ=NÓ=PÔ$QÓQÑQÔRØ#.ˆ	�-Ñ àÐøô) ×,Ñ,ò 	Ø'ˆGØ‹Fð	ús   Æ
AK8Ë8LÌLc                ó   ‡ ‡‡	— ddl mŠ t        ‰ j                  «       «      j                  Š	t        d«      }‰	j                  dv ryt        j                  dt        j                  «      }t        j                  j                  ‰	«      }t        |j                  |«      «      rt        j                   |› d|› d�«       yˆˆ	ˆ fd	„}t"        d
z  }t        j$                  |› d�«       d}	 ddlm}  | |d«      |«      sJ ‚t        j$                  |› d�«       y# t*        $ r t        j                   |› d|› �«       Y yt,        t.        f$ r t        j                   |› d|› �«       Y yt0        $ r t        j2                  |› d�«       Y yw xY w)av  Check the PyTorch Automatic Mixed Precision (AMP) functionality of a YOLO model.

    If the checks fail, it means there are anomalies with AMP on the system that may cause NaN losses or zero-mAP
    results, so AMP will be disabled during training.

    Args:
        model (torch.nn.Module): A YOLO model instance.

    Returns:
        (bool): Returns True if the AMP functionality works correctly with YOLO model, else False.

    Examples:
        >>> from ultralytics import YOLO
        >>> from ultralytics.utils.checks import check_amp
        >>> model = YOLO("yolo26n.pt").model.cuda()
        >>> check_amp(model)
    r   )ÚautocastzAMP: >   ÚcpuÚmpsFzV(nvidia|geforce|quadro|tesla).*?(1660|1650|1630|t400|t550|t600|t1000|t1200|t2000|k40m)u#   checks failed â�Œ. AMP training on zW GPU may cause NaN losses or zero-mAP results, so AMP will be disabled during training.c                ó¼  •— |gdz  }t        dt        ‰j                  j                  «       dz  «      «      } | ||‰d¬«      d   j                  j                  } ‰d¬«      5   | ||‰d¬«      d   j                  j                  }d	d	d	«       ~ |j
                  j
                  k(  xr& t        j                  ||j                  «       d
¬«      S # 1 sw Y   ŒKxY w)zAll close FP32 vs AMP results.rE  é   é   F)rk   rW  rŽ   r   T)ÚenabledNg      à?)Úatol)	r_   rI   rl   ÚboxesÚdataÚshaper]   ÚallcloseÚfloat)	ÚmÚimÚbatchrk   ÚaÚbr•  rW  r   s	         €€€r:   Úamp_allclosezcheck_amp.<locals>.amp_allcloses  sÂ   ø€ à��q‘ˆÜ�Cœ˜UŸ\™\×-Ñ-Ó/°!Ñ3Ó4Ó5ˆÙˆe˜5¨¸Ô?ÀÑB×HÑH×MÑMˆÙ˜dÔ#ñ 	RÙ�%˜u¨V¸UÔCÀAÑF×LÑL×QÑQˆA÷	RàØ�w‰w˜!Ÿ'™'Ñ!ÒL¤e§n¡n°Q¸¿¹»	ÈÔ&LÐL÷	Rð 	Rús   Á$$CÃCzbus.jpgz1running Automatic Mixed Precision (AMP) checks...z`Setting 'amp=True'. If you experience zero-mAP or NaN losses you can disable AMP with amp=False.)ÚYOLOú
yolo26n.ptu   checks passed âœ…zGchecks skipped. Offline and unable to download YOLO26n for AMP checks. zichecks skipped. Unable to load YOLO26n for AMP checks due to possible Ultralytics package modifications. z˜checks failed. Anomalies were detected with AMP on your system that may lead to NaN losses or zero-mAP results, so AMP will be disabled during training.T)rZ  r•  ÚnextÚ
parametersrW  r    re   r2   ÚcompileÚ
IGNORECASEr]   r  Úget_device_nameÚboolÚsearchr   rL   r   r—   r¤   r¨  ÚConnectionErrorÚAttributeErrorr‰   rë   Úerror)
r   rÌ   ÚpatternÚgpur§  r£  Úwarning_msgr¨  r•  rW  s
   `       @@r:   Ú	check_ampr·  M  s�  ú€ õ$ 7ä�%×"Ñ"Ó$Ó%×,Ñ,€FÜ�gÓ€FØ‡{�{�nÑ$Øô —*‘*ØeÔgi×gtÑgtó
ˆô �j‰j×(Ñ(¨Ó0ˆÜ�—‘˜sÓ#Ô$Ü�N‰NØ�(Ð=¸c¸Uð C[ð \ôð öMô 
�)Ñ	€BÜ
‡K�K�6�(ÐKÐLÔMØt€KðÝ$á™D Ó.°Ô3Ð3Ð3Ü�‰�v�hÐ/Ð0Ô1ð øô ò xÜ�‰˜&˜Ð!hÐitÐhuÐvÕwð ô Ô/Ð0ò 
Ü�‰Øˆhð hØhsÐgtðvõ	
ð ô ò Ü�‰Øˆhð Wð Xô	
ñ ðús   Ã+/D Ä#FÅ (FÅ* FÆFc                 ó^  — ddl } 	 t        j                  | j                  ddddgdd¬«      }d	t        j
                  › d
�}|j                  dk7  r<d|j                  j                  «       v rt        j                  dt        › d|› �«       yt        t        j                  d|j                  t        j                  ¬«      d   «      dz  j!                  «       }|j#                  t	        j                   «       «      s#t        j                  d|› dt        › d|› �«       yy# t$        $ r Y yw xY w)z6Check if there are multiple Ultralytics installations.r   Nz-mrp  Úshowr¤   T)ru   r¾   z>Install your local copy in editable mode with 'pip install -e z?' to avoid issues. See https://docs.ultralytics.com/quickstart/z	not foundz2Ultralytics not found via pip but importing from: z. zlocation:\s+(.+))ÚflagsrÔ   zFMultiple Ultralytics installations detected. The `yolo` command uses: z$, but current session imports from: z$. This may cause version conflicts. )rÝ   rv   rw   rÞ   r   r2  rx   rÚ   r  r   rL   r   r2   rJ   rÊ   ÚIrè   ÚsamefilerK   )rÝ   r�   Úinstall_msgÚ	yolo_paths       r:   re  re  •  s"  € ãðÜ—‘ §¡°°u¸fÀmÐ TÐeiÐptÔuˆàLÌTÏ[É[ÈMð ZCð Cð 	ð ×Ñ Ò!Ø˜fŸm™m×1Ñ1Ó3Ñ3Ü—‘Ð!SÔTXÐSYÐY[Ð\gÐ[hÐiÔjØÜœ"Ÿ*™*Ð%8¸&¿-¹-ÌrÏtÉtÔTÐUWÑXÓYÐ\iÑi×rÑrÓtˆ	Ø×!Ñ!¤$§,¡,£.Ô1Ü�N‰NØXÐYbÐXcð d5Ü59°FÐ:^Ð_jÐ^kðmõð 2øô
 ò Ùðús   †BD  ÂBD  Ä 	D,Ä+D,c           
     ó˜  ‡— d„ Št        j                  «       j                  }t        j                  |«      \  }}}}}| €Bt        j                  |«      \  } }}}|j                  «       D ��	ci c]  \  }}	|| v sŒ||	“Œ } }}		 t        |«      j                  «       j                  t        «      j                  d«      }|r|› d�nd|r|› d�ndz   }
t        j                  t        |
«      dj!                  ˆfd„t#        | j                  «       «      D «       «      z   «       yc c}	}w # t        $ r t        |«      j                  }Y ŒŠw xY w)zçPrint function arguments (optional args dict).

    Args:
        args (dict, optional): Arguments to print.
        show_file (bool): Whether to show the file name.
        show_func (bool): Whether to show the function name.
    c                óz   — t        | t        «      r*| j                  d«      rt        | «      dkD  rt	        | «      S | S )zTClean longer Ultralytics HUB URLs by stripping potential authentication information.Úhttpéd   )r\   rX   r0   rg   r   )r’   s    r:   Ú
strip_authzprint_args.<locals>.strip_auth¶  s5   € ä *¨1¬cÔ 2°q·|±|ÀFÔ7KÔPSÐTUÓPVÐY\ÒP\Œy˜‹|ÐdÐcdÐdrD   Nr$   r‡  r}   c              3  ó>   •K  — | ]  \  }}|› d  ‰|«      › �–— Œ y­w)ú=Nrz   )rT   r~  r’   rÃ  s      €r:   rV   zprint_args.<locals>.<genexpr>Ä  s$   øè ø€ Ò'`Á4À1Àa¨1¨#¨Q©z¸!«}¨oÔ(>Ñ'`ùs   ƒ)ÚinspectÚcurrentframeÚf_backÚgetframeinfoÚgetargvaluesrŒ  r   rè   Úrelative_tor   r  rh   r  r   r—   r    rí   Úsorted)ÚargsÚ	show_fileÚ	show_funcr7   r¬   rŽ  ÚfuncÚfrmr~  r’   rY   rÃ  s              @r:   Ú
print_argsrÒ  ­  s!  ø€ òeô 	×ÑÓ×%Ñ%€AÜ!×.Ñ.¨qÓ1Ñ€Dˆ!ˆT�1�aØ€|Ü!×.Ñ.¨qÓ1‰ˆˆa��CØ!$§¡£×:™˜˜A°°T²	��1‘Ð:ˆÑ:ðÜ�D‹z×!Ñ!Ó#×/Ñ/´Ó5×AÑAÀ"ÓEˆñ "ˆDˆ6�‰ r¹Y°°°b©kÈBÑO€AÜ
‡K�K”˜“˜dŸi™iÓ'`Ì6ÐRV×R\ÑR\ÓR^ÓK_Ô'`Ó`Ñ`Õaùó ;øô ò Ü�D‹z�‰Šðús   Á-D"Á:D"Â;D( Ä(E	ÅE	c                 ó"  — t         rt        j                  j                  «       S 	 t	        j
                  g d¢d¬«      } | j                  «       j                  dd«      d   }t        |«      S # t        j                  t        t        f$ r Y yw xY w)z‚Get the number of NVIDIA GPUs available in the environment.

    Returns:
        (int): The number of NVIDIA GPUs available.
    )z
nvidia-smiz--query-gpu=countz--format=csv,noheader,nounitszutf-8)ÚencodingrÉ   r'   r   )r   r]   r  r‹  rv   rÜ   r/   r?   rI   ÚCalledProcessErrorry   rh   )rå   Ú
first_lines     r:   Úcuda_device_countr×  Ç  s~   € õ ä�z‰z×&Ñ&Ó(Ð(ð	ä×,Ñ,ÚTÐ_fôˆFð
  Ÿ™›×-Ñ-¨d°AÓ6°qÑ9ˆJä�z“?Ð"øÜ×-Ñ-Ô/@Ä*ÐMò 	áð	ús   ¦AA- Á-BÂBc                 ó   — t        «       dkD  S )z‘Check if CUDA is available in the environment.

    Returns:
        (bool): True if one or more NVIDIA GPUs are available, False otherwise.
    r   )r×  rz   rD   r:   Úcuda_is_availablerÙ  à  s   € ô Ó Ñ"Ð"rD   c                 ó4  — t         rwt        rq	 t        d«      5 } | j                  «       }|j	                  d«      �^ }}|j                  dd«      j	                  dd«      d   t        v r
	 ddd«       y		 ddd«       yyy
# 1 sw Y   ŒxY w# t        $ r Y y
w xY w)z•Check if the current environment is running on a Rockchip SoC.

    Returns:
        (bool): True if running on a Rockchip SoC, False otherwise.
    z/proc/device-tree/compatiblerƒ   ú r$   ú-r'   r   NTF)r   r   ÚopenÚreadr?   rê   r   ÚOSError)r  Údev_strrŽ  Úsocs       r:   Úis_rockchiprâ  é  s    € õ •ð	ÜÐ4Ó5ð  ¸ØŸ&™&›(�Ø!Ÿ-™-¨Ó,‘��CØ—;‘;˜v rÓ*×0Ñ0°°aÓ8¸Ñ;¼zÑIØ÷	 ð  ð J÷ ñ  ð ÷ ð  ûô
 ò 	Ùð	ús/   ŽB ™AA?Á*B Á4B Á?BÂB Â	BÂBc                 óÌ   — ddl m}  d | «       j                  «       v ry	 t        j                  ddgddd¬«      }d|j
                  j                  «       v S # t        $ r Y y	w xY w)
zŒCheck if the system has Intel hardware (CPU or GPU).

    Returns:
        (bool): True if Intel hardware is detected, False otherwise.
    r   )rm  ÚintelTzxpu-smiÚ	discoveryr&  )ru   r¾   r•   F)rZ  rm  r  rv   rw   rÊ   rK   )rm  r�   s     r:   Úis_intelræ  ü  si   € õ ;ð ‘,“.×&Ñ&Ó(Ñ(ØðÜ—‘ ¨KÐ 8ÈÐTXÐbcÔdˆØ˜&Ÿ-™-×-Ñ-Ó/Ð/Ð/øÜò Ùðús    6A Á	A#Á"A#c                 ó˜   — t         ryd} t        j                  | dt        j                  t        j                  ¬«      j                  dk(  S )z•Check if the sudo command is available in the environment.

    Returns:
        (bool): True if the sudo command is available, False otherwise.
    Fzsudo --versionT)rÙ   rÊ   rÚ   r   )r   rv   rw   ÚDEVNULLrx   )rÎ   s    r:   rË   rË     s<   € õ ØØ
€CÜ�>‰>˜# T´*×2DÑ2DÌZ×M_ÑM_Ô`×kÑkÐopÑpÐprD   z3.8)r�   rŽ   z3.9z3.10z3.12z3.13r%  )r@   rX   ÚreturnrX   )ú0.0.0)ré  rG   )ré  r¯  )é    r'   r(   r   )rê  rê  rM   FFr$   )r‹   rX   rŒ   rX   r)   rX   r�   r¯  rŽ   r¯  rp   rX   ré  r¯  )r¤   )z	Arial.ttf)z3.8.0TF)r¸   rX   r�   r¯  rŽ   r¯  ré  r¯  )z7.0.0)r  rX   )r©  r  r$   )T)r¬   rX   rŽ   r¯  ré  rX   )Úyolo11n)r   rX   ré  z
str | Path)r$   Tr  T))r  z.ymlT)r>  ú
Path | strr!  rí  ré  r¯  )F)Tr$   )NTF)rÍ  zdict | None)ré  rI   )bÚ
__future__r   rb   Ú	functoolsr4  rÆ  ri   ræ   rŠ  r2   r[  rv   rÝ   rî   Ú	importlibr   Úpathlibr   Útypesr   rG  ÚnumpyrI  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   r   r    r!   r"   r#   r2  r;   rC   Ú	lru_cacherO   rZ   rr   r{   r“   r¡   r¦   rµ   r¹   rÏ   rý   r  r  r  r  r  r"  r:  r<  rA  rO  rj  r“  r·  re  rÒ  r×  rÙ  râ  ræ  rË   r0   ÚIS_PYTHON_3_8ÚIS_PYTHON_3_9ÚIS_PYTHON_3_10ÚIS_PYTHON_3_12ÚIS_PYTHON_3_13ÚIS_PYTHON_MINIMUM_3_9ÚIS_PYTHON_MINIMUM_3_10ÚIS_PYTHON_MINIMUM_3_12rz   rD   r:   ú<module>rý     sÒ  ðõ #ã 
Û Û Û Û Û 	Û Û 	Û Û Û 
Û Ý Ý Ý !ã 
Û Û ÷÷ ÷ ÷ ÷ ÷ ÷ õ ðB "&§¡Ð/AÑ!AÈ2ó ó>ð ×Ñóó ðó 	-ó2ðj ×Ññó ðð ×ÑàØØØØØðTØðTàðTð ðTð ð	Tð
 ðTð 
ðTð 
òTó ðTónò(ñ, ÓØ
×Ñòó ó ðô:]ñ ƒñ$xó ð$xñN ƒØ$(§K¡KÐ2DÑ$DÈbÐZ^Ðegò kó ðkò\'ôQò!óH^ô ô6ó<.ó~/óuð  ×Ñòó ðó0!+òH9òxEòPô0bó4ó2#òò&ó(	qñ ˆU˜¨Õ -Ù Ô ð *�×)Ñ)¨%Ó0€Ø)�×)Ñ)¨%Ó0€Ø*�×*Ñ*¨6Ó2€Ø*�×*Ñ*¨6Ó2€Ø*�×*Ñ*¨6Ó2€á$ U°Ô7Ð Ù% f°5Ô9Ð Ù% f°5Ô9Ñ rD   