Ë
    ëÓ^jW•  ã                  óB  — d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
Zd dlZerd dlmZ d dlmZmZ d dlmZ d d	lmZmZmZmZ d d
lmZmZmZ ddgZddgZddgZh d£Z d/d„Z!d0d„Z"d/d„Z#d1d„Z$d2d„Z%d3d„Z&d4d„Z' ed¬«       G d„ d«      «       Z( G d„ d«      Z)ddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d5d „Z*	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d6d!„Z+d"dd#œ	 	 	 	 	 	 	 	 	 	 	 	 	 d7d$„Z,d8d%„Z-d8d&„Z.	 	 	 	 	 	 	 	 	 	 d9d'„Z/	 d:	 	 	 	 	 	 	 d;d(„Z0d<d)„Z1 G d*„ d+«      Z2 G d,„ d-e«      Z3d=d.„Z4y)>é    )ÚannotationsN)Ú	dataclass)ÚPath)ÚTYPE_CHECKINGÚAny©Ú
Detections)ÚImageÚ	ImageDraw)ÚVisionDataset)ÚYoloKeypointSchemaÚ#_extract_yolo_class_names_from_dataÚ_load_yaml_mappingÚinfer_yolo_keypoint_schema)Ú%_resolve_runtime_augmentation_backendÚmake_coco_transformsÚ"make_coco_transforms_square_div_64ú	data.yamlzdata.ymlÚtrainÚvalidÚimagesÚlabels>	   ú.bmpú.dngú.jpgú.mpoú.pngú.tifú.jpegú.tiffú.webpc           	     ó"  — | \  }}}}t        j                  t        |«      t        |«      dz  z
  t        |«      t        |«      dz  z
  t        |«      t        |«      dz  z   t        |«      t        |«      dz  z   gt         j                  ¬«      S )zDParse a YOLO center-width-height box into relative XYXY coordinates.é   ©Údtype)ÚnpÚarrayÚfloatÚfloat32)ÚvaluesÚx_centerÚy_centerÚwidthÚheights        ú_/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/rfdetr/datasets/yolo.pyÚ_parse_yolo_boxr0   (   sƒ   € à(.Ñ%€Hˆh˜˜vÜ�8‰8ä�(‹Oœe E›l¨QÑ.Ñ.Ü�(‹Oœe F›m¨aÑ/Ñ/Ü�(‹Oœe E›l¨QÑ.Ñ.Ü�(‹Oœe F›m¨aÑ/Ñ/ð		
ô �j‰jôð ó    c                ó”   — t        j                  | d   | d   g| d   | d   g| d   | d   g| d   | d   ggt         j                  ¬«      S )z4Convert a relative XYXY box into a 4-corner polygon.r   é   r#   é   r$   )r&   r'   r)   )Úboxs    r/   Ú_box_to_polygonr6   6   sZ   € ä�8‰8Ø
ˆa‰&�#�a‘&Ð	˜C ™F C¨¡FÐ+¨c°!©f°c¸!±fÐ-=ÀÀAÁÈÈAÉÐ?OÐPÜ�j‰jôð r1   c                ól   — t        j                  | t         j                  ¬«      j                  dd«      S )z7Parse a flattened YOLO polygon into relative XY points.r$   éÿÿÿÿr#   )r&   r'   r)   Úreshape)r*   s    r/   Ú_parse_yolo_polygonr:   >   s$   € ä�8‰8�F¤"§*¡*Ô-×5Ñ5°b¸!Ó<Ð<r1   c                ó2  — |\  }}t        j                  d||fd«      }| j                  dkD  rKt        j                  |«      j                  | j                  «       D �cg c]  }t        |«      ‘Œ c}d¬«       t        j                  |t        ¬«      S c c}w )zËRasterize a polygon into a dense boolean mask.

    TODO: remove once supervision ships a direct CompactMask.from_polygon factory;
    at that point the dense intermediate array is no longer needed.
    ÚLr   r3   )Úfillr$   )r
   ÚnewÚsizer   ÚDrawÚpolygonÚtolistÚtupler&   r'   Úbool)rA   Úresolution_whr-   r.   ÚmaskÚpoints         r/   Ú_polygon_to_maskrH   C   sy   € ð "�M€Eˆ6Ü�9‰9�S˜5 &˜/¨1Ó-€DØ‡|�|�aÒÜ�‰�tÓ×$Ñ$ÀÇÁÓ@PÖ%Q°u¤e¨E¥lÒ%QÐXYÐ$ÔZÜ�8‰8�D¤Ô%Ð%ùò &Rs   ÁBc           	     óÈ   — t        | «      dk(  r#|\  }}t        j                  d||ft        ¬«      S t        j                  | D �cg c]  }t        ||«      ‘Œ c}«      S c c}w )záRasterize per-instance polygons into an ``(N, H, W)`` boolean array.

    TODO: remove once supervision ships a direct CompactMask.from_polygon factory;
    at that point the dense intermediate array is no longer needed.
    r   r$   )Úlenr&   ÚzerosrD   ÚstackrH   )ÚpolygonsrE   r-   r.   rA   s        r/   Ú_polygons_to_masksrN   P   sV   € ô ˆ8ƒ}˜ÒØ%‰ˆˆvÜ�x‰x˜˜F EÐ*´$Ô7Ð7Ü�8‰8ÈXÖVÀ'Ô% g¨}Õ=ÒVÓWÐWùÒVs   ÁAc                óT   — t        d„ t        | «      j                  «       D «       «      S )z(List YOLO image files in a stable order.c              3  ó’   K  — | ]?  }|j                  «       r-|j                  j                  «       t        v rt	        |«      –— ŒA y ­w©N)Úis_fileÚsuffixÚlowerÚYOLO_IMAGE_EXTENSIONSÚstr)Ú.0Úpaths     r/   ú	<genexpr>z)_list_yolo_image_paths.<locals>.<genexpr>^   s:   è ø€ ò àØ�<‰<Œ>˜dŸk™k×/Ñ/Ó1Ô5JÑJô 	ˆD�	ñùs   ‚AA)Úsortedr   Úiterdir)Úimages_directory_paths    r/   Ú_list_yolo_image_pathsr]   \   s+   € äñ äÐ.Ó/×7Ñ7Ó9ôó ð r1   c                óF   — t        | «      }t        |«      }t        ||«      S )z0Read class names from a YOLO ``data.yaml`` file.)r   r   r   )Ú	data_filerX   Údatas      r/   Ú_extract_yolo_class_namesra   e   s"   € ä�	‹?€DÜ˜dÓ#€DÜ.¨t°TÓ:Ð:r1   T)Úfrozenc                  ó`   — e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
ed<   ded<   dd„Zy)Ú_LazyYoloSampleaq  Lightweight per-image YOLO metadata with polygons kept lazy until fetch time.

    Note: ``frozen=True`` prevents field *reassignment* but does NOT prevent
    in-place mutation of ``np.ndarray`` fields (e.g. ``sample.xyxy[0] = 999.0`` would silently succeed).  This is safe
    across DataLoader workers because each worker receives a pickled copy of the dataset.
    rV   Ú
image_pathÚintr-   r.   ú
np.ndarrayÚxyxyÚclass_idútuple[np.ndarray, ...]rM   Ú	keypointsc                ób  — ddl m} t        | j                  «      dk(  r |j                  «       S t        | j
                  «      dk(  r || j                  | j                  ¬«      S t        | j
                  | j                  | j                  f«      } || j                  | j                  |¬«      S )zFMaterialize the current sample as a supervision ``Detections`` object.r   r   )ri   rh   )ri   rh   rF   )
Úsupervisionr	   rJ   ri   ÚemptyrM   rh   rN   r-   r.   )Úselfr	   rF   s      r/   Úto_detectionsz_LazyYoloSample.to_detections}   sƒ   € å*äˆt�}‰}Ó Ò"Ø#�:×#Ñ#Ó%Ð%Üˆt�}‰}Ó Ò"á t§}¡}¸4¿9¹9ÔEÐEô " $§-¡-°$·*±*¸d¿k¹kÐ1JÓKˆÙ 4§=¡=°t·y±yÀtÔLÐLr1   N)Úreturnz'Detections')Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rp   © r1   r/   rd   rd   l   s6   … ñð ƒOØƒJØƒKØ
ÓØÓØ$Ó$ØÓôMr1   rd   c                  ó0   — e Zd ZdZdd„Zdd„Zd	d„Zd
d„Zy)Ú_LazyYoloDetectionDatasetzMLazy YOLO dataset that defers dense mask rasterization until ``__getitem__``.c                ó    — || _         || _        y rQ   )ÚclassesÚ_samples)ro   r{   Úsampless      r/   Ú__init__z"_LazyYoloDetectionDataset.__init__”   s   € ØˆŒØˆ�r1   c                ó,   — t        | j                  «      S rQ   )rJ   r|   ©ro   s    r/   Ú__len__z!_LazyYoloDetectionDataset.__len__˜   s   € Ü�4—=‘=Ó!Ð!r1   c                óŠ  — | j                   |   }	 t        j                  |j                  «      5 }t	        j
                  |j                  d«      «      }d d d «       |j                  |j                  «       fS # 1 sw Y   Œ&xY w# t        t        t        j                  f$ r}t        d|j                  › �«      |‚d }~ww xY w)NÚRGBz Could not read image from path: )r|   r
   Úopenre   r&   r'   ÚconvertÚFileNotFoundErrorÚOSErrorÚUnidentifiedImageErrorÚ
ValueErrorrp   )ro   ÚidxÚsampleÚimageÚ	rgb_imageÚexcs         r/   Ú__getitem__z%_LazyYoloDetectionDataset.__getitem__›   s¯   € Ø—‘˜sÑ#ˆð	^Ü—‘˜F×-Ñ-Ó.ð ;°%ÜŸH™H U§]¡]°5Ó%9Ó:�	÷;ð × Ñ  )¨V×-AÑ-AÓ-CÐCÐC÷	;ð ;ûä!¤7¬E×,HÑ,HÐIò 	^ÜÐ?À×@QÑ@QÐ?RÐSÓTÐZ]Ð]ûð	^ús.   ‘B °%A:ÁB Á:BÁ?B ÂCÂ$B=Â=Cc                ó    — | j                   |   S )zBReturn lightweight metadata without loading pixels or dense masks.)r|   )ro   rŠ   s     r/   Úget_image_infoz(_LazyYoloDetectionDataset.get_image_info¤   s   € à�}‰}˜SÑ!Ð!r1   N)r{   ú	list[str]r}   zlist[_LazyYoloSample]rq   ÚNone©rq   rf   )rŠ   rf   rq   z$tuple[str, np.ndarray, 'Detections'])rŠ   rf   rq   rd   )rr   rs   rt   ru   r~   r�   r�   r‘   rw   r1   r/   ry   ry   ‘   s   „ ÙWó ó"óDô"r1   ry   ©Úparse_polygonsc               óª  — t        | «      dk  r't        dt        |«      ›d|› dt        | «      › d�«      ‚t        | «      dkD  r>t        | dd «      dz  d	k7  r*t        d
t        |«      ›d|› dt        | dd «      › d�«      ‚	 t        | d	   «      }|d	k  s||k\  r't        dt        |«      ›d|› d|› d|› d|dz
  › d�«      ‚t        | «      dk(  rt	        | dd «      }	|rt        |	«      nd}
n¦	 t        | dd «      }t        j                  t        j                  |dd…d	f   «      t        j                  |dd…df   «      t        j                  |dd…d	f   «      t        j                  |dd…df   «      gt        j                  ¬«      }	|r|nd}
|	t        j                  ||||gt        j                  ¬«      z  }|
€||dfS |
t        j                  ||gt        j                  ¬«      z  }t        j                  |dd…d	f   dt        |dz
  «      «      |dd…d	f<   t        j                  |dd…df   dt        |dz
  «      «      |dd…df<   |||j                  t        j                  «      fS # t        $ r'}t        dt        |«      ›d|› d| d	   ›d�«      |‚d}~ww xY w# t        $ r!}t        d
t        |«      ›d|› d�«      |‚d}~ww xY w)aÍ  Parse one YOLO label line and return ``(class_id, xyxy_px, polygon_px)``.

    Args:
        values: Whitespace-split fields from the label line.
        line_num: 1-based line number (for error messages).
        label_path: Path to the label file (for error messages).
        num_classes: Total number of classes in the dataset (used for range check).
        width: Image width in pixels.
        height: Image height in pixels.
        parse_polygons: When ``False`` the pixel-space polygon array is not
            computed or returned (``polygon_px`` will be ``None``).  Set to ``False`` on the detection-only path to
            avoid allocating polygon arrays that would immediately be discarded.

    Returns:
        Tuple of ``(class_id, xyxy_px, polygon_px)`` where coordinates are in pixel space.  ``polygon_px`` is ``None``
        when ``parse_polygons=False``.

    Raises:
        ValueError: If the line is malformed or the class ID is out of range.
    é   zMalformed label in ú	 at line uc   : expected 5 (bbox) fields or â‰¥ 7 fields for polygons (class_id + at least 3 (x, y) points), got ú.r3   Nr#   r   zMalformed polygon in z<: polygon coordinates must be paired (x, y) values, but got z coordinate values (odd count).zLabel z line z: invalid class ID z (must be an integer).z: class ID z" is out of range for dataset with u    classes (valid range 0â€“z).z.: could not parse coordinate values as floats.r$   ç        )rJ   r‰   rV   rf   r0   r6   r:   r&   r'   ÚminÚmaxr)   Úclipr(   Úastype)r*   Úline_numÚ
label_pathÚnum_classesr-   r.   r–   ÚcidrŽ   r5   rA   Ú_raw_polygonÚxyxy_pxÚ
polygon_pxs                 r/   Ú_parse_yolo_label_liner§   ©   s  € ô< ˆ6ƒ{�Q‚ÜØ!¤# j£/Ð!4°I¸h¸Zð H:ä:=¸f»+¸ÀaðIó
ð 	
ô
 ˆ6ƒ{�Q‚œ3˜v a b˜z›?¨QÑ.°!Ò3ÜØ#¤C¨
£OÐ#6°iÀ¸zð Jä˜6 ! "˜:“Ð'Ð'FðHó
ð 	
ð
Ü�&˜‘)‹nˆð ˆQ‚w�#˜Ò$ÜØ”S˜“_Ð' v¨h¨Zð 8Ø�uÐ>¸{¸mð L#Ø#.°¡?Ð"3°2ð7ó
ð 	
ô
 ˆ6ƒ{�aÒÜ˜f Q R˜jÓ)ˆá=K¤_°SÔ%9ÐQU‰ð	Ü.¨v°a°b¨zÓ:ˆLô �h‰hä—‘�|¢A q DÑ)Ó*Ü—‘�|¢A q DÑ)Ó*Ü—‘�|¢A q DÑ)Ó*Ü—‘�|¢A q DÑ)Ó*ð	ô —*‘*ô
ˆñ #1‘,°dˆØ”B—H‘H˜e V¨U°FÐ;Ä2Ç:Á:ÔNÑN€GØ€Ø�G˜TÐ!Ð!Øœ2Ÿ8™8 U¨F O¼2¿:¹:ÔFÑF€JÜ—w‘w˜zª!¨Q¨$Ñ/°´e¸EÀA¹IÓ6FÓG€JŠq�!ˆtÑÜ—w‘w˜zª!¨Q¨$Ñ/°´e¸FÀQ¹JÓ6GÓH€JŠq�!ˆtÑØ�˜×*Ñ*¬2¯:©:Ó6Ð6Ð6øôY ò ÜØ”S˜“_Ð' v¨h¨ZÐ7JÈ6ÐRSÉ9È-ÐWmÐnó
àð	ûðûô* ò 	ÜØ'¬¨J«Ð':¸)ÀHÀ:ð N?ð @óð ðûð	ús0   ÂI5 Ã/J( É5	J%É>"J Ê J%Ê(	KÊ1KËKc               óÎ  — d||z  z   }t        | «      |k7  rIt        | «      dk(  r|dkD  rdnd}	t        dt        |«      ›d|› d|› d|› d	|› d
t        | «      › d|	› �«      ‚t        | dd |||||d¬«      \  }
}}	 t	        j
                  | dd t        j                  ¬«      j                  ||«      }t	        j                  |«      j                  «       st        dt        |«      ›d|› d�«      ‚|dd…dd…f   }t	        j                  |dft        j                  ¬«      }|dk(  re|dd…df   }t	        j                  |dk  |dkD  z  «      rt        dt        |«      ›d|› d�«      ‚t	        j                  |dd|¬«       ||dd…df<   n\|dd…df   dk  |dd…df   dk  z  }t	        j                  |dd|¬«       d||dd…f<   |dd…df   dk(  |dd…df   dk(  z   }d||df<   |dd…df   t        |«      z  |dd…df<   |dd…df   t        |«      z  |dd…df<   |dd…df   dk  }d||dd…f<   |
||fS # t        $ r!}t        dt        |«      ›d|› d�«      |‚d}~ww xY w)zNParse one Ultralytics YOLO pose row into pixel boxes and COCO-style keypoints.r˜   r   z¨ This looks like a detection-only label row (5 fields). Check whether the dataset mixes detection and pose annotations or whether the kpt_shape in data.yaml is correct.Ú zMalformed YOLO pose label in r™   z: expected z fields from kpt_shape=[z, z], got rš   NFr•   r$   z,: could not parse keypoint values as floats.z: non-finite keypoint.r#   r4   r›   g       @z/: keypoint visibility values must be in [0, 2].g      ð?)Úoutr3   )rJ   r‰   rV   r§   r&   Úasarrayr)   r9   ÚisfiniteÚallrK   Úanyrž   r(   )r*   r    r¡   r¢   r-   r.   Únum_keypointsÚkeypoint_dimÚexpected_fieldsÚhintr£   r¥   Ú_Úraw_keypointsrŽ   Úxyrk   Ú
visibilityÚ	absent_2dÚpresentÚabsents                        r/   Ú_parse_yolo_pose_label_linerº     sý  € ð ˜-¨,Ñ6Ñ6€OÜ
ˆ6ƒ{�oÒ%ô
 �6‹{˜aÒ M°AÒ$5ñ@ð ð 	ô Ø+¬C°
«OÐ+>¸iÈÀzð RØ'Ð(Ð(@ÀÀÈrÐR^ÐQ_ð `Ü�v“;�-˜q  ð(ó
ð 	
ô -Øˆr�ˆ
ØØØØØØô�O€Cˆ�!ðÜŸ
™
 6¨!¨" :´R·Z±ZÔ@×HÑHÈÐXdÓeˆô �;‰;�}Ó%×)Ñ)Ô+ÜÐ8¼¸Z»Ð8KÈ9ÐU]ÐT^Ð^tÐuÓvÐvØ	’q˜"˜1˜"�uÑ	€Bä—‘˜-¨Ð+´2·:±:Ô>€IØ�qÒà"¢1 a 4Ñ(ˆ
Ü�6‰6�: Ñ#¨
°SÑ(8Ñ9Ô:ÜØ/´°J³Ð/BÀ)ÈHÈ:ð V@ð @óð ô 	�‰��C˜ "Õ%Ø$ˆ	’!�Q�$Šð š˜1˜‘X ‘^¨ª1¨a¨4©°3©Ñ7ˆ	Ü
�‰��C˜ "Õ%àˆˆ9’aˆ<ÑØš˜1˜‘X ‘_¨ªA¨q¨D©°S©Ñ9Ð:ˆØ #ˆ	�'˜1�*Ñàš˜A˜‘h¤ u£Ñ-€IŠa�ˆd�OØš˜A˜‘h¤ v£Ñ.€IŠa�ˆd�Oà’q˜!�t‰_ Ñ#€FØ€Iˆf�b�q�bˆjÑØ�˜Ð"Ð"øôM ò ÜØ+¬C°
«OÐ+>¸iÈÀzð R9ð 9ó
ð ð	ûðús   Á:8H: È:	I$ÉIÉI$F)Úinclude_keypointsÚkeypoint_schemac               óº  — |r|rt        d«      ‚|r?|xs t        |«      }|j                  }t        |j                  d¬«      }|j
                  }nt        |«      }d}d}g }	t        | «      D �]I  }
t        |«      t        |
«      j                  › d�z  }t        j                  |
«      5 }|j                  \  }}ddd«       g }g }g }g }|j                  «       �r |j                  d¬«      5 }|D �cg c]#  }|j                  «       sŒ|j                  «       ‘Œ% }}ddd«       t        «      D ]©  \  }}|j!                  «       }|r7t#        ||dz   |t%        |«      ||¬	«      \  }}}d}|j'                  |«       n"t)        ||dz   |t%        |«      |¬
«      \  }}}|j'                  |«       |j'                  |«       |sŒ–|€Œ™|j'                  |«       Œ« |	j'                  t+        |
t-        j.                  |t,        j0                  ¬«      j3                  dd«      t-        j.                  |t,        j4                  ¬«      t7        |«      |r4t-        j8                  |«      j;                  t,        j0                  d¬«      n't-        j<                  d|dft,        j0                  ¬«      ¬«      «       �ŒL ||	fS # 1 sw Y   �ŒxY wc c}w # 1 sw Y   �Œ¶xY w)u>  Build the class list and sample list shared by both YOLO builder functions.

    Iterates over every image in ``img_folder``, reads image dimensions via PIL (header-only, no full decode), and
    parses the matching ``.txt`` label file when present.  Images without a label file are included as *background*
    samples with empty detections.

    Args:
        img_folder: Path to the directory containing images.
        lb_folder: Path to the directory containing YOLO ``.txt`` label files.
        data_file: Path to the ``data.yaml`` / ``data.yml`` file with class names.
        include_polygons: When ``True`` polygon coordinates are stored in each
            :class:`_LazyYoloSample` (segmentation path).  When ``False`` polygon coordinates returned by
            :func:`_parse_yolo_label_line` are discarded and ``polygons=()`` is stored instead (detection-only path).
            Mutually exclusive with ``include_keypoints``.
        include_keypoints: When ``True`` keypoint coordinates are stored in each :class:`_LazyYoloSample` (pose path).
            Mutually exclusive with ``include_polygons``; raises :class:`ValueError` when both are ``True``.
        keypoint_schema: Keypoint schema describing class names, per-class keypoint counts, OKS sigmas, keypoint names,
            flip index, and keypoint dimensionality.  When ``None`` and ``include_keypoints=True`` the schema is
            auto-inferred from ``data_file`` via :func:`infer_yolo_keypoint_schema`.

    Returns:
        A ``(classes, samples)`` tuple where ``classes`` is the ordered list of class names and ``samples`` is a list of
        :class:`_LazyYoloSample` objects.

    Examples:
        >>> # Used internally by _build_lazy_yolo_detection_dataset and
        >>> # _build_lazy_yolo_segmentation_dataset â€” not part of the public API.
        >>> pass
    úHYOLO segmentation masks and keypoints cannot be loaded at the same time.r   ©Údefaultz.txtNzutf-8)Úencodingr3   )r¯   r°   r•   r$   r8   é   F)Úcopyr4   )re   r-   r.   rh   ri   rM   rk   )r‰   r   Úclass_namesr�   Únum_keypoints_per_classr°   ra   r]   r   Ústemr
   r„   r?   ÚexistsÚstripÚ	enumerateÚsplitrº   rJ   Úappendr§   rd   r&   r'   r)   r9   Úint64rC   rL   rŸ   rK   )Ú
img_folderÚ	lb_folderr_   Úinclude_polygonsr»   r¼   r{   r¯   r°   r}   re   r¡   rŒ   r-   r.   rh   ri   rM   rk   ÚhandleÚlineÚlinesÚir*   r£   r¥   Úkeypoints_pxr¦   s                               r/   Ú_build_yolo_samplesrÕ   S  s°  € ñL Ñ-ÜÐcÓdÐdÙØ)ÒRÔ-GÈ	Ó-RˆØ!×-Ñ-ˆÜ˜O×CÑCÈQÔOˆØ&×3Ñ3‰ä+¨IÓ6ˆØˆØˆØ%'€Gä,¨ZÓ8ó 8
ˆ
Ü˜)“_¬$¨zÓ*:×*?Ñ*?Ð)@ÀÐ'EÑEˆ
Ü�Z‰Z˜
Ó#ð 	' uØ!ŸJ™J‰MˆE�6÷	'ð "$ˆØ ˆØ%'ˆØ&(ˆ	Ø×ÑÕØ—‘¨'�Ó2ð J°fØ28ÖI¨$¸D¿J¹J½L˜Ÿ™�ÐI�ÐI÷Jä$ UÓ+ò 0‘��4ØŸ™›�Ù$Ü1LØØ˜A™Ø"Ü˜G›ØØØ&3Ø%1ô	2Ñ.�C˜ ,ð "&�JØ×$Ñ$ \Õ2ä/EØØ˜A™Ø"Ü˜G›ØØØ'7ô0Ñ,�C˜ *ð —‘ Ô$Ø—‘˜GÔ$Ú#¨
Ñ(>Ø—O‘O JÕ/ð90ð< 	�‰ÜØ%ØØÜ—X‘X˜d¬"¯*©*Ô5×=Ñ=¸bÀ!ÓDÜŸ™ (´"·(±(Ô;Ü˜x›ñ !ô —H‘H˜YÓ'×.Ñ.¬r¯z©zÀÐ.ÔFäŸ™ 1 m°QÐ"7¼r¿z¹zÔJôö	
ðU8
ðt �GÐÐ÷q	'ñ 	'üò J÷Jñ Jús0   Â*J>Ã-KÃ2KÄKÄKÊ>K	ËKËK	c                ó@   — t        | ||d¬«      \  }}t        ||¬«      S )u~  Build a YOLO detection dataset that stores bounding boxes lazily.

    Unlike :func:`_build_lazy_yolo_segmentation_dataset`, this function does not store polygon coordinates or dense
    masks â€” only ``xyxy`` boxes are retained, keeping peak memory proportional to the number of annotations.

    Images without a matching ``.txt`` label file are included as *background* samples with empty detections, so
    datasets that mix labelled and unlabelled images are handled correctly.

    Args:
        img_folder: Path to the directory containing images.
        lb_folder: Path to the directory containing YOLO ``.txt`` label files.
        data_file: Path to the ``data.yaml`` / ``data.yml`` file with class names.

    Returns:
        A :class:`_LazyYoloDetectionDataset` whose ``__getitem__`` loads pixel data on demand and returns
        ``sv.Detections`` without mask information.
    F©rÏ   ©r{   r}   ©rÕ   ry   ©rÍ   rÎ   r_   r{   r}   s        r/   Ú"_build_lazy_yolo_detection_datasetrÛ   Ã  s'   € ô$ +¨:°yÀ)Ð^cÔdÑ€GˆWÜ$¨W¸gÔFÐFr1   c                ó@   — t        | ||d¬«      \  }}t        ||¬«      S )aå  Build a YOLO dataset that stores polygons and rasterizes masks on demand.

    Args:
        img_folder: Path to the directory containing images.
        lb_folder: Path to the directory containing YOLO ``.txt`` label files.
        data_file: Path to the ``data.yaml`` / ``data.yml`` file with class names.

    Returns:
        A :class:`_LazyYoloDetectionDataset` whose ``__getitem__`` loads pixel data on demand and rasterizes polygon
        masks into dense boolean tensors.
    Tr×   rØ   rÙ   rÚ   s        r/   Ú%_build_lazy_yolo_segmentation_datasetrÝ   Ù  s'   € ô +¨:°yÀ)Ð^bÔcÑ€GˆWÜ$¨W¸gÔFÐFr1   c                óD   — t        | ||dd|¬«      \  }}t        ||¬«      S )zDBuild a YOLO pose dataset that stores keypoints without dense masks.FT)rÏ   r»   r¼   rØ   rÙ   )rÍ   rÎ   r_   r¼   r{   r}   s         r/   Ú!_build_lazy_yolo_keypoint_datasetrß   é  s4   € ô +ØØØØØØ'ôÑ€GˆWô %¨W¸gÔFÐFr1   c           
     óæ  — ddl m} g }g }g }t        | «      D ];  \  }}||ddœ}	|�t        |j                  «      |	d<   g |	d<   |j                  |	«       Œ= t        |d«      }
d}t        t        |«      «      D �]N  }|
rr|j                  |«      }|j                  }|j                  |j                  }}|j                  }|j                  }t        |j                  «      dkD  }|j                   }nr||   \  }}}|j"                  dd	 \  }}|j                  }|j                  }|j$                  du}t'        j(                  t        |«      dd
ft&        j*                  ¬«      }|j                  |t-        |«      t/        |«      t/        |«      dœ«       t        t        |«      «      D �]  }||   \  }}}}t1        |«      t1        |«      }}t1        ||z
  «      t1        ||z
  «      }}||t/        ||   «      ||||gt1        ||z  «      ddœ} |rg | d<   |�˜|t        |«      k  r||   n$t'        j(                  dt&        j*                  ¬«      }!|!j3                  d«      j5                  t0        «      j7                  «       | d<   t/        t'        j8                  |!dd…d	f   dkD  «      «      | d<    |j
                  | «       |dz  }�Œ �ŒQ ddi|||dœ}" |«       }#|"|#_        |#j=                  «        |#S )am  Build an in-memory ``pycocotools.COCO`` object from YOLO lazy samples.

    Args:
        classes: Ordered class names where index is the YOLO class ID.
        dataset: Lazy YOLO backend exposing ``__len__`` and either ``get_image_info(idx)`` or ``__getitem__(idx)``.

    Returns:
        Initialized ``pycocotools.COCO`` object with ``dataset`` and indexes.
    r   )ÚCOCOÚnone)ÚidÚnameÚsupercategoryNrk   Úskeletonr‘   r#   r4   r$   )rã   Ú	file_namer.   r-   )rã   Úimage_idÚcategory_idÚbboxÚareaÚiscrowdÚsegmentation)r   r4   r8   r¯   r3   ÚdescriptionzRF-DETR YOLO dataset)Úinfor   r   Ú
categories)Úpycocotools.cocorá   rÉ   ÚlistÚkeypoint_namesrË   ÚhasattrÚrangerJ   r‘   re   r.   r-   rh   ri   rM   rk   ÚshaperF   r&   rK   r)   rV   rf   r(   r9   rŸ   rB   Úcount_nonzeroÚdatasetÚcreateIndex)$r{   rø   r¼   rá   r   r   rð   rŠ   Ú
class_nameÚcategoryÚuse_lazy_pathÚann_idÚimg_idr‹   re   r.   r-   rh   ri   Ú	has_masksrk   Úimage_arrayÚ
detectionsrÓ   Úx1Úy1Úx2Úy2Úbbox_xÚbbox_yÚbbox_wÚbbox_hÚannÚkeypoints_iÚcoco_datasetÚcocos$                                       r/   Ú_build_coco_api_from_samplesr  û  sð  € õ &à#%€FØ(*€KØ')€JÜ$ WÓ-ò $‰ˆˆZØ zÀFÑKˆØÐ&Ü$(¨×)GÑ)GÓ$HˆH�[Ñ!Ø#%ˆH�ZÑ Ø×Ñ˜(Õ#ð$ô ˜GÐ%5Ó6€MØ€FÜœ˜G›Ó%ó 'ˆÙØ×+Ñ+¨FÓ3ˆFØ×*Ñ*ˆJØ"ŸM™M¨6¯<©<�EˆFØ—;‘;ˆDØ—‘ˆHÜ˜FŸO™OÓ,¨qÑ0ˆIØ×(Ñ(‰Ià29¸&±/Ñ/ˆJ˜ ZØ'×-Ñ-¨b¨qÐ1‰MˆF�EØ—?‘?ˆDØ!×*Ñ*ˆHØ"Ÿ™¨tÐ3ˆIÜŸ™¤# d£)¨Q°Ð!2¼"¿*¹*ÔEˆIà�‰˜V´#°j³/ÌSÐQWË[ÔcfÐglÓcmÑnÔoä”s˜4“yÓ!ó 	ˆAØ! !™W‰NˆB��B˜Ü" 2›Y¬¨b«	�FˆFÜ" 2¨¡7›^¬U°2¸±7«^�FˆFàØ"Ü" 8¨A¡;Ó/Ø ¨°Ð8Ü˜f v™oÓ.ØñˆCñ à&(��NÑ#ØÐ*Ø./´#°i³.Ò.@˜i¨šlÄbÇhÁhÈvÔ]_×]gÑ]gÔFh�Ø#.×#6Ñ#6°rÓ#:×#AÑ#AÄ%Ó#H×#OÑ#OÓ#Q��KÑ Ü'*¬2×+;Ñ+;¸KÊÈ1ÈÑ<MÐPQÑ<QÓ+RÓ'S��OÑ$ØˆK×Ñ˜sÔ#Ø�a‰KŠFò)	ð''ðT Ð 6Ð7ØØ"Ø ñ	€Lñ ‹6€DØ€D„LØ×ÑÔØ€Kr1   c                ó¨   ‡ — t        ˆ fd„t        D «       «      }t        ˆ fd„t        D «       «      }t        ˆ fd„t        D «       «      }|xr |xr |S )aÃ  Checks if the specified dataset directory is in yolo format.

    We accept a dataset to be in yolo format if the following conditions are met:
    - The dataset_dir contains a data.yaml or data.yml file
    - The dataset_dir contains "train" and "valid" subdirectories, each containing "images" and "labels" subdirectories
    - The "test" subdirectory is optional

    Returns a boolean indicating whether the dataset is in correct yolo format.
    c              3  ó˜   •K  — | ]A  }t         j                  j                  t         j                  j                  ‰|«      «      –— ŒC y ­wrQ   ©ÚosrX   rÇ   Újoin)rW   Ú	yaml_fileÚdataset_dirs     €r/   rY   z(is_valid_yolo_dataset.<locals>.<genexpr>V  s2   øè ø€ ò &ØAJŒ�‰�‰”r—w‘w—|‘| K°Ó;×<ñ&ùó   ƒAA
c              3  ó˜   •K  — | ]A  }t         j                  j                  t         j                  j                  ‰|«      «      –— ŒC y ­wrQ   r  )rW   Ú	split_dirr  s     €r/   rY   z(is_valid_yolo_dataset.<locals>.<genexpr>Y  s2   øè ø€ ò 'ØAJŒ�‰�‰”r—w‘w—|‘| K°Ó;×<ñ'ùr  c           	   3  ó°   •K  — | ]M  }t         D ]B  }t        j                  j                  t        j                  j	                  ‰||«      «      –— ŒD ŒO y ­wrQ   )ÚREQUIRED_DATA_SUBDIRSr  rX   rÇ   r  )rW   r  Údata_subdirr  s      €r/   rY   z(is_valid_yolo_dataset.<locals>.<genexpr>\  sL   øè ø€ ò )àÜ0ò)ð ô 	�‰�‰”r—w‘w—|‘| K°¸KÓH×Ið)ØIñ)ùs   ƒAA)r®   ÚREQUIRED_YOLO_YAML_FILESr­   ÚREQUIRED_SPLIT_DIRS)r  Úcontains_required_yolo_yamlÚcontains_required_split_dirsÚcontains_required_data_subdirss   `   r/   Úis_valid_yolo_datasetr!  L  se   ø€ ô #&ó &ÜNfô&ó #Ðô $'ó 'ÜNaô'ó $Ð ô &)ó )ä,ô)ó &Ð"ð
 'ÒjÐ+GÒjÐLjÐjr1   c                  ó"   — e Zd ZdZddd„Zdd„Zy)ÚConvertYoloa–  Converts supervision Detections to the target dict format expected by RF-DETR.

    Args:
        include_masks: whether to include segmentation masks.
        include_keypoints: whether to include pose keypoints.
        num_keypoints: Number of keypoints per instance when keypoints are enabled.

    Examples:
        >>> import numpy as np
        >>> from supervision import Detections
        >>> from PIL import Image
        >>> # Create a sample image and target
        >>> image = Image.new("RGB", (100, 100))
        >>> detections = Detections(
        ...     xyxy=np.array([[10, 20, 30, 40]]),
        ...     class_id=np.array([0])
        ... )
        >>> target = {"image_id": 0, "detections": detections}
        >>> # Create converter
        >>> converter = ConvertYolo(include_masks=False)
        >>> # Call converter
        >>> img, result = converter(image, target)
        >>> sorted(result.keys())
        ['area', 'boxes', 'image_id', 'iscrowd', 'labels', 'orig_size', 'size']
        >>> result["boxes"].shape
        torch.Size([1, 4])
        >>> result["labels"].tolist()
        [0]
        >>> result["image_id"].tolist()
        [0]
    c                ó.   — || _         || _        || _        y rQ   ©Úinclude_masksr»   r¯   )ro   r&  r»   r¯   s       r/   r~   zConvertYolo.__init__…  s   € Ø*ˆÔØ!2ˆÔØ*ˆÕr1   c                ó€  — |j                   \  }}|d   }t        j                  |g«      }|d   }t        |«      dkD  ryt        j                  |j
                  «      j                  t        j                  «      }t        j                  |j                  «      j                  t        j                  «      }nJt        j                  dt        j                  ¬«      }t        j                  dt        j                  ¬«      }|dd…ddd…f   j                  d|¬	«       |dd…d
dd…f   j                  d|¬	«       |dd…df   |dd…d
f   kD  |dd…df   |dd…df   kD  z  }	||	   }||	   }i }
||
d<   ||
d<   ||
d<   |dd…df   |dd…d
f   z
  |dd…df   |dd…df   z
  z  }||
d<   t        j                  |j                  d   ft        j                  ¬«      }||
d<   | j                  rÐ|j                  �ƒt        j                   |j                  «      dkD  rat        j                  |j                  |	j!                  «       j#                  «          «      j                  t        j$                  «      }||
d<   n+t        j                  d||ft        j$                  ¬«      |
d<   |
d   j'                  «       |
d<   | j(                  r›|j+                  d«      }|€@t        j                  |	j                  d   | j,                  dft        j                  ¬«      }n@t        j.                  |t        j                  ¬«      j1                  d| j,                  d«      }||	   |
d<   t        j.                  t3        |«      t3        |«      g«      |
d<   t        j.                  t3        |«      t3        |«      g«      |
d<   ||
fS )zßConvert image and YOLO detections to RF-DETR format.

        Args:
            image: PIL Image
            target: dict with 'image_id' and 'detections'

        Returns:
            tuple of (image, target_dict)
        rè   r  r   )r   rÂ   r$   )r   Nr#   )rœ   r�   r3   r4   Úboxesr   rë   rì   Úmasksrk   r8   Ú	orig_sizer?   )r?   ÚtorchÚtensorrJ   Ú
from_numpyrh   Útor)   ri   rÌ   rK   Úclamp_rö   r&  rF   r&   ÚcpuÚnumpyÚuint8rD   r»   Úgetr¯   Ú	as_tensorr9   rf   )ro   rŒ   ÚtargetÚwÚhrè   r  r(  r{   ÚkeepÚ
target_outrë   rì   r)  r´   rk   s                   r/   Ú__call__zConvertYolo.__call__Š  s8  € ð �z‰z‰ˆˆ1à˜*Ñ%ˆÜ—<‘<  
Ó+ˆà˜LÑ)ˆ
äˆz‹?˜QÒÜ×$Ñ$ Z§_¡_Ó5×8Ñ8¼¿¹ÓGˆEÜ×&Ñ& z×':Ñ':Ó;×>Ñ>¼u¿{¹{ÓK‰Gä—K‘K ¬e¯m©mÔ<ˆEÜ—k‘k $¬e¯k©kÔ:ˆGð 	Ša���A�ˆg‰×Ñ !¨ÐÔ+ØŠa���A�ˆg‰×Ñ !¨ÐÔ+à’a˜�d‘˜e¢A q D™kÑ)¨e²A°q°D©k¸EÂ!ÀQÀ$¹KÑ.GÑHˆØ�d‘ˆØ˜$‘-ˆàˆ
Ø#ˆ
�7ÑØ&ˆ
�8ÑØ!)ˆ
�:Ñð ’a˜�d‘˜e¢A q D™kÑ)¨e²A°q°D©k¸EÂ!ÀQÀ$¹KÑ.GÑHˆØ!ˆ
�6Ñä—+‘+˜wŸ}™}¨QÑ/Ð1¼¿¹ÔEˆØ 'ˆ
�9Ñà×ÒØ�‰Ð*¬r¯w©w°z·±Ó/GÈ!Ò/KÜ×(Ñ(¨¯©¸¿¹»×9IÑ9IÓ9KÑ)LÓM×PÑPÔQV×Q\ÑQ\Ó]�Ø&+�
˜7Ò#ä&+§k¡k°1°a¸°)Ä5Ç;Á;Ô&O�
˜7Ñ#à",¨WÑ"5×":Ñ":Ó"<ˆJ�wÑà×!Ò!Ø"ŸJ™J {Ó3ˆMØÐ$ä!ŸK™K¨¯©°A©¸×8JÑ8JÈAÐ(NÔV[×VcÑVcÔd‘	ä!ŸO™O¨MÄÇÁÔO×WÑWÐXZÐ\`×\nÑ\nÐpqÓr�	Ø&/°¡oˆJ�{Ñ#ä"'§/¡/´3°q³6¼3¸q»6Ð2BÓ"Cˆ
�;ÑÜ"Ÿ_™_¬c°!«f´c¸!³fÐ-=Ó>ˆ
�6Ñà�jÐ Ð r1   N)FFr   )r&  rD   r»   rD   r¯   rf   )rŒ   zImage.Imager5  Údictrq   rC   )rr   rs   rt   ru   r~   r:  rw   r1   r/   r#  r#  d  s   „ ñô@+ô
A!r1   r#  c                  óT   ‡ — e Zd ZdZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dˆ fd„Zdd„Zdd„Zˆ xZS )	ÚYoloDetectionuž  YOLO format dataset with lazy image loading and optional mask support.

    Both detection (``include_masks=False``) and segmentation (``include_masks=True``) paths use a lazy backend: image
    pixels are loaded on demand inside ``__getitem__`` rather than at construction time, which keeps peak RAM
    proportional to the number of annotations rather than to ``N Ã— H Ã— W``.

    Images without a matching ``.txt`` label file are treated as *background* images and produce empty detections.  This
    ensures that datasets containing a mix of annotated and unannotated images are handled correctly in both single-GPU
    and multi-GPU training.

    This class provides a VisionDataset interface compatible with RF-DETR training, matching the API of CocoDetection.

    Args:
        img_folder: Path to the directory containing images
        lb_folder: Path to the directory containing YOLO annotation .txt files
        data_file: Path to data.yaml file containing class names and dataset info
        transforms: Optional transforms to apply to images and targets
        include_masks: Whether to load segmentation masks (for YOLO segmentation format).
            When True polygons are parsed and rasterized on demand; when False only bounding-box coordinates are stored.
        include_keypoints: Whether to load Ultralytics YOLO pose keypoints.
        num_keypoints_per_class: Optional keypoint schema used by RF-DETR.
    c                ó\  •— |r|rt        d«      ‚t        t        | �  |«       || _        || _        || _        |r	 t        |«      | _        nd | _        t        |xs g d¬«      | _        | j                  �0t        | j                  j                  | j                  ¬«      | _        t        ||| j                  ¬«      | _        |rt!        |||| j                  «      | _        n'|rt%        |||«      | _        nt'        |||«      | _        | j"                  j(                  | _        t+        t-        t/        | j"                  «      «      «      | _        t3        | j(                  | j"                  | j                  «      | _        y # t        t         t        f$ r}t        d|›d�«      |‚d }~ww xY w)Nr¾   z6YOLO keypoint training requires kpt_shape metadata in rš   r   r¿   r%  )r‰   Úsuperr=  r~   Ú_transformsr&  r»   r   r¼   r†   r‡   r�   r¯   rÅ   r#  Úpreparerß   Ú
sv_datasetrÝ   rÛ   r{   rò   rõ   rJ   Úidsr  r  )
ro   rÍ   rÎ   r_   Ú
transformsr&  r»   rÅ   rŽ   Ú	__class__s
            €r/   r~   zYoloDetection.__init__æ  s‰  ø€ ñ Ñ.ÜÐgÓhÐhÜŒm˜TÑ+¨JÔ7Ø%ˆÔØ*ˆÔØ!2ˆÔÙðsÜ'AÀ)Ó'L�Õ$ð $(ˆDÔ Ü Ð!8Ò!>¸BÈÔJˆÔØ×ÑÐ+Ü!$ T×%9Ñ%9×%QÑ%QÐ[_×[mÑ[mÔ!nˆDÔÜ"Ø'Ø/Ø×,Ñ,ô
ˆŒñ
 Ü?ØØØØ×$Ñ$ó	ˆD�Oñ ÜCÀJÐPYÐ[dÓeˆD�Oä@ÀÈYÐXaÓbˆDŒOà—‘×.Ñ.ˆŒÜœœc $§/¡/Ó2Ó3Ó4ˆŒô 1°·±¸t¿¹ÐPT×PdÑPdÓeˆ�	øô9 &¤z´7Ð;ò sÜ Ð#YÐZcÐYfÐfgÐ!hÓiÐorÐrûðsús   ¼F ÆF+ÆF&Æ&F+c                ó,   — t        | j                  «      S rQ   )rJ   rB  r€   s    r/   r�   zYoloDetection.__len__  s   € Ü�4—?‘?Ó#Ð#r1   c                óV  — | j                   |   }| j                  |   \  }}}t        j                  |«      }||dœ}| j                  r(| j                  j                  |«      j                  |d<   | j                  ||«      \  }}| j                  �| j                  ||«      \  }}||fS )N)rè   r  rk   )	rC  rB  r
   Ú	fromarrayr»   r‘   rk   rA  r@  )ro   rŠ   rè   re   r�   r  Úimgr5  s           r/   r�   zYoloDetection.__getitem__  s¤   € Ø—8‘8˜C‘=ˆØ,0¯O©O¸CÑ,@Ñ)ˆ
�I˜zä�o‰o˜iÓ(ˆà&°jÑAˆØ×!Ò!Ø"&§/¡/×"@Ñ"@ÀÓ"E×"OÑ"OˆF�;ÑØ—l‘l 3¨Ó/‰ˆˆVà×ÑÐ'Ø×*Ñ*¨3°Ó7‰KˆC�à�Fˆ{Ðr1   )NFFN)rÍ   rV   rÎ   rV   r_   rV   r&  rD   r»   rD   rÅ   zlist[int] | Noner”   )rŠ   rf   )rr   rs   rt   ru   r~   r�   r�   Ú__classcell__)rE  s   @r/   r=  r=  Î  sg   ø„ ñð8 Ø#Ø"'Ø48ð/fàð/fð ð/fð ð	/fð ð/fð  ð/fð "2õ/fób$÷r1   r=  c                ó  ‡— t        |j                  «      Š‰j                  «       sJ d‰› d�«       ‚‰dz  dz  ‰dz  dz  f‰dz  dz  ‰dz  dz  f‰dz  dz  ‰dz  dz  fdœ}t        ˆfd	„t        D «       ‰d
z  «      }|| j                  d«      d      \  }}t        |dd«      }t        |dd«      }t        |dd«      }	t        |dd«      }
t        |dd«      }t        |dd«      }t        |dd«      }t        |dd«      }t        |dd«      }t        |dg «      }|rt        |dg «      xs g nd}t        t        |dd«      «      }|dk7  }|r	 t        |«       |rCt        t        |«      t        |«      t        |«      t        | ||	|
| |||||¬«
      |||¬«      }|S t        t        |«      t        |«      t        |«      t        | ||	|
| |||||¬«
      |||¬«      }|S # t        t        t        f$ r}t        d«      |‚d}~ww xY w)a…  Build a Roboflow YOLO-format dataset.

    This uses Roboflow's standard YOLO directory structure (train/valid/test folders with images/ and labels/
    subdirectories).

    Args:
        image_set: Dataset split to load. One of ``"train"``, ``"val"``, or
            ``"test"``.
        args: Argument namespace. The following attributes are consumed:
            ``dataset_dir``, ``square_resize_div_64``, ``aug_config``, ``segmentation_head``, ``multi_scale``,
            ``expanded_scales``, ``do_random_resize_via_padding``, ``patch_size``, ``num_windows``. ``aug_config`` is
            forwarded to the transform builder; when ``None`` the builder falls back to the default
            :data:`~rfdetr.datasets.aug_configs.AUG_CONFIG`.
        resolution: Target square resolution in pixels.

    Returns:
        A :class:`YoloDetection` dataset instance ready for use with a DataLoader.
    zprovided Roboflow path z does not existr   r   r   r   Útest)r   ÚvalrL  c              3  óP   •K  — | ]  }‰|z  j                  «       sŒ‰|z  –— Œ y ­wrQ   )rÇ   )rW   ÚfÚroots     €r/   rY   z+build_roboflow_from_yolo.<locals>.<genexpr>I  s$   øè ø€ ÒX 1ÀTÈAÁX×DUÑDUÕDW�d˜Q•hÑXùs   ƒ&œ
&r   r³   r   Úsquare_resize_div_64FÚsegmentation_headÚmulti_scaleÚexpanded_scalesNÚdo_random_resize_via_paddingÚ
patch_sizeÚnum_windowsÚ
aug_configÚuse_grouppose_keypointsrÅ   Úkeypoint_flip_pairsÚaugmentation_backendr0  zeYOLO keypoint training requires an Ultralytics pose data.yaml/data.yml with valid kpt_shape metadata.)rS  rT  Úskip_random_resizerV  rW  rX  Úgpu_postprocessrZ  )rÍ   rÎ   r_   rD  r&  r»   rÅ   )r   r  rÇ   Únextr  rÊ   Úgetattrr   r   r†   r‰   r‡   r=  rV   r   r   )Ú	image_setÚargsÚ
resolutionÚPATHSr_   rÍ   rÎ   rQ  r&  rS  rT  rU  rV  rW  rX  r»   rÅ   rZ  Úresolved_augmentation_backendr]  rŽ   rø   rP  s                         @r/   Úbuild_roboflow_from_yolore  +  s’  ø€ ô& �× Ñ Ó!€DØ�;‰;Œ=ÐIÐ3°D°6¸ÐIÓIˆ=ð ˜‘. 8Ñ+¨T°G©^¸hÑ-FÐGØ�w‘ Ñ)¨4°'©>¸HÑ+DÐEØ˜‘ Ñ)¨4°&©=¸8Ñ+CÐDñ€Eô ÓXÔ(@ÔXÐZ^ÐalÑZlÓm€IØ! )§/¡/°#Ó"6°qÑ"9Ñ:Ñ€J�	Ü" 4Ð)?ÀÓGÐÜ˜DÐ"5°uÓ=€MÜ˜$ ¨uÓ5€KÜ˜dÐ$5°tÓ<€OÜ#*¨4Ð1OÐQVÓ#WÐ Ü˜˜|¨TÓ2€JÜ˜$ ¨tÓ4€KÜ˜˜|¨TÓ2€JÜ Ð&?ÀÓGÐÜ% dÐ,EÀrÓJÐá<MŒ�Ð,¨bÓ	1Ò	7±RÐSWð ô %JÌ'ÐRVÐXnÐpuÓJvÓ$wÐ!Ø3°uÑ<€Oáð	Ü& yÔ1ñ ÜÜ˜:“Ü˜)“nÜ˜)“nÜ9ØØØ'Ø /Ø'CÐ#CØ%Ø'Ø%Ø /Ø$7ôð (Ø/Ø$;ô%
ˆðR €Nô)  Ü˜:“Ü˜)“nÜ˜)“nÜ+ØØØ'Ø /Ø'CÐ#CØ%Ø'Ø%Ø /Ø$7ôð (Ø/Ø$;ô%
ˆð( €Nøô_ "¤:¬wÐ7ò 	ÜØwóàðûð	ús   ÅG  Ç HÇ4H È H)r*   r’   rq   rg   )r5   rg   rq   rg   )rA   rg   rE   útuple[int, int]rq   rg   )rM   rj   rE   rf  rq   rg   )r\   rV   rq   r’   )r_   rV   rq   r’   )r*   r’   r    rf   r¡   r   r¢   rf   r-   rf   r.   rf   r–   rD   rq   z)tuple[int, np.ndarray, np.ndarray | None])r*   r’   r    rf   r¡   r   r¢   rf   r-   rf   r.   rf   r¯   rf   r°   rf   rq   z"tuple[int, np.ndarray, np.ndarray])rÍ   rV   rÎ   rV   r_   rV   rÏ   rD   r»   rD   r¼   úYoloKeypointSchema | Nonerq   z'tuple[list[str], list[_LazyYoloSample]])rÍ   rV   rÎ   rV   r_   rV   rq   ry   )
rÍ   rV   rÎ   rV   r_   rV   r¼   r   rq   ry   rQ   )r{   r’   rø   r   r¼   rg  rq   r   )r  rV   rq   rD   )r`  rV   ra  r   rb  rf   rq   r=  )5Ú
__future__r   r  Údataclassesr   Úpathlibr   Útypingr   r   r1  r&   r+  rm   r	   ÚPILr
   r   Útorchvision.datasetsr   Ú rfdetr.datasets._keypoint_schemar   r   r   r   Úrfdetr.datasets.cocor   r   r   r  r  r  rU   r0   r6   r:   rH   rN   r]   ra   rd   ry   r§   rº   rÕ   rÛ   rÝ   rß   r  r!  r#  r=  re  rw   r1   r/   ú<module>rp     su  ðõ #ã 	Ý !Ý ß %ã Û áÝ&ß  Ý .÷ó ÷ñ ð (¨Ð4Ð Ø Ð(Ð Ø! 8Ð,Ð ÚcÐ óóó=ó

&ó	Xóó;ñ �$Ô÷!Mð !Mó ð!M÷H"ñ "ð@  ñX7ØðX7àðX7ð ðX7ð ð	X7ð
 ðX7ð ðX7ð ðX7ð /óX7ðvL#ØðL#àðL#ð ðL#ð ð	L#ð
 ðL#ð ðL#ð ðL#ð ðL#ð (óL#ðj $Ø15ñmØðmàðmð ðmð
 ðmð ðmð /ðmð -ómó`Gó,Gð GØðGàðGð ðGð (ð	Gð
 óGð* 26ðNØðNàðNð /ðNð 	ó	Nóbk÷0g!ñ g!ôTZ�Mô Zôzbr1   