o
    _{jõ  ã                   @   s>   d dl mZ d dlmZ ddlmZ e ¡ G dd„ dƒƒZdS )é    )ÚSequence)Úbuild_from_cfgé   )Ú	PIPELINESc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚComposez¶Compose a data pipeline with a sequence of transforms.

    Args:
        transforms (list[dict | callable]):
            Either config dicts of transforms or transform objects.
    c                 C   sj   t |tƒsJ ‚g | _|D ]&}t |tƒrt|tƒ}| j |¡ qt|ƒr*| j |¡ qtdt	|ƒ› �ƒ‚d S )Nz.transform must be callable or a dict, but got )
Ú
isinstancer   Ú
transformsÚdictr   r   ÚappendÚcallableÚ	TypeErrorÚtype)Úselfr   Ú	transform© r   ú9/root/disk_3tb/HAC/mmaction/datasets/pipelines/compose.pyÚ__init__   s   

ÿùzCompose.__init__c                 C   sB   t | jƒD ]\}}||ƒ}|dkr|d }|du r dS q||fS )zÄCall function to apply transforms sequentially.

        Args:
            data (dict): A result dict contains the data to transform.

        Returns:
            dict: Transformed data.
        é   Ú
frame_indsN)Ú	enumerater   )r   ÚdataÚiÚtr   r   r   r   Ú__call__   s   ÿzCompose.__call__c                 C   s:   | j jd }| jD ]}|d7 }|d |¡7 }q	|d7 }|S )Nú(Ú
z    {0}z
))Ú	__class__Ú__name__r   Úformat)r   Úformat_stringr   r   r   r   Ú__repr__5   s   
zCompose.__repr__N)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r    r   r   r   r   r      s
    r   N)Úcollections.abcr   Ú
mmcv.utilsr   Úregistryr   Úregister_moduler   r   r   r   r   Ú<module>   s
    