Ë
    ëÓ^j,  ã                  óÊ   — U d Z ddlmZ ddlmZ ddlmZ  eh d£«      Zde	d<    eh d£«      Z
de	d	<   dd
„Zddœ	 	 	 	 	 	 	 dd„Zdd„Zdd„Z G d„ d«      Z	 	 	 	 	 	 	 	 dd„Zy)z6Shared helpers for dataset augmentation configuration.é    )Úannotations)ÚCallable)ÚAny>   ÚD4ÚFlipÚHorizontalFlipzfrozenset[str]ÚHFLIP_TRANSFORM_NAMES>   ÚOneOfÚSomeOfÚ
SequentialÚCONTAINER_TRANSFORM_NAMESc                ó   —  |d| | «       y)zBEmit the standard warning for a disabled keypoint horizontal flip.zóKeypoint pipeline: '%s' performs a horizontal flip but no keypoint flip pairs were configured. The transform has been disabled to prevent incorrect keypoint annotations. Remove '%s' from your augmentation config or provide keypoint_flip_pairs.N© )Úaug_nameÚwarns     úe/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/rfdetr/datasets/_aug_utils.pyÚ_warn_keypoint_hflip_disabledr      s   € áð	að 	Øõó    T)Úinclude_keypointsc               ó‚   — |s| S t        | t        «      rt        | |¬«      S t        | t        «      rt	        | |¬«      S | S )a   Drop horizontal-flip transforms from keypoint augmentation configs.

    The helper preserves the input config shape: dictionary configs return
    dictionaries, and ordered list configs return lists. Container transforms are
    filtered recursively so nested hflip entries cannot survive inside
    ``OneOf``, ``SomeOf``, or ``Sequential``.

    Args:
        config: Augmentation config accepted by RF-DETR augmentation builders.
        include_keypoints: Whether the config will be applied to keypoint data.
        warn: Warning sink, typically ``logger.warning``.

    Returns:
        A filtered augmentation config with keypoint-unsafe hflip entries removed.
    ©r   )Ú
isinstanceÚlistÚ_filter_keypoint_hflip_entriesÚdictÚ_filter_keypoint_hflip_dict)Úconfigr   r   s      r   Ú#filter_keypoint_hflip_augmentationsr      s?   € ñ* Øˆä�&œ$ÔÜ-¨f¸4Ô@Ð@ä�&œ$ÔÜ*¨6¸Ô=Ð=à€Mr   c               ó&  — g }| D ]‰  }t        |t        «      rt        |«      dk7  r|j                  |«       Œ3t	        t        |j                  «       «      «      \  }}t        |||¬«      }t        |t        «      rŒw|j                  ||i«       Œ‹ |S )z/Filter ordered single-key augmentation entries.é   r   )	r   r   ÚlenÚappendÚnextÚiterÚitemsÚ_filter_keypoint_hflip_itemÚ_DropAugmentation)Úentriesr   Úfiltered_entriesÚentryr   ÚparamsÚfiltered_paramss          r   r   r   @   s�   € à-/ÐØò 	=ˆÜ˜%¤Ô&¬#¨e«*¸ª/Ø×#Ñ# EÔ*Øä¤ U§[¡[£]Ó 3Ó4Ñˆ�&Ü5°hÀÈTÔRˆÜ�oÔ'8Ô9ØØ×Ñ ¨?Ð ;Õ<ð	=ð Ðr   c               ó‚   — i }| j                  «       D ])  \  }}t        |||¬«      }t        |t        «      rŒ%|||<   Œ+ |S )z+Filter a mapping-style augmentation config.r   )r%   r&   r   r'   )r   r   Úfiltered_configr   r+   r,   s         r   r   r   P   sO   € à&(€OØ"ŸL™L›Nò 4Ñˆ�&Ü5°hÀÈTÔRˆÜ�oÔ'8Ô9ØØ$3ˆ˜Ò!ð	4ð
 Ðr   c                  ó   — e Zd ZdZy)r'   z;Sentinel used when an augmentation entry should be removed.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r'   r'   [   s   „ ÚEr   r'   c               óD  — | t         v rt        | |«       t        «       S | t        vr|S t	        |t
        «      rt        ||¬«      }|r|S t        «       S t	        |t        «      rd|vr|S |d   }t	        |t
        «      s|S t        ||¬«      }|s
t        «       S i |¥d|i¥S )zCFilter one augmentation entry, recursing into supported containers.r   Ú
transforms)r	   r   r'   r   r   r   r   r   )r   r+   r   Úfiltered_transformsr5   s        r   r&   r&   _   s²   € ð Ô(Ñ(Ü% h°Ô5Ü Ó"Ð"àÔ0Ñ0Øˆä�&œ$ÔÜ<¸VÈ$ÔOÐÙ&9Ð"ÐRÔ?PÓ?RÐRä�fœdÔ# |¸6Ñ'AØˆà˜Ñ%€JÜ�j¤$Ô'Øˆä8¸È$ÔOÐÙÜ Ó"Ð"à8ˆfÐ8�lÐ$7Ñ8Ð8r   N)r   Ústrr   úCallable[..., None]ÚreturnÚNone)r   r   r   Úboolr   r8   r9   r   )r(   úlist[dict[str, Any]]r   r8   r9   r<   )r   údict[str, Any]r   r8   r9   r=   )r   r7   r+   r   r   r8   r9   zAny | _DropAugmentation)r3   Ú
__future__r   Úcollections.abcr   Útypingr   Ú	frozensetr	   Ú__annotations__r   r   r   r   r   r'   r&   r   r   r   ú<module>rC      s¬   ðò =å "å $Ý ñ )2Ò2RÓ(SÐ �~Ó Sá,5Ò6WÓ,XÐ ˜>Ó Xóð #ñØðð ðð ð	ð
 	óóBó ÷Fñ Fð9Øð9àð9ð ð	9ð
 ô9r   