U
    h                     @   s   d dl Z d dlmZ d dlmZ d dlZd dlmZm	Z	m
Z
 e jdkrTd dlmZ nd dlmZ eeeje
f ejf eeeje
f ejf ddd	Zeeeje
f ejf eeeje
f ejf dd
dZdS )    N)wraps)Callable)MONO_CHANNEL_DIMENSIONSNUM_MULTI_CHANNEL_DIMENSIONSP)   
   )Concatenate)funcreturnc                    s,   t  tjtjtjtjd fdd}|S )zLEnsure that input img is contiguous and the output array is also contiguous.imgargskwargsr   c                    s>   t j| dgd}  | f||}|jd s:t j|dgdS |S )NZC_CONTIGUOUS)requirements)nprequireflags)r   r   r   resultr
    7/tmp/pip-unpacked-wheel-rlprxnb3/albucore/decorators.pywrapped_function   s
    
z$contiguous.<locals>.wrapped_functionr   r   ndarrayr   r   r   r
   r   r   r   r   
contiguous   s    "r   c                    s,   t  tjtjtjtjd fdd}|S )zPreserve dummy channel dim.r   c                    sv   | j } | f||}t|tkrF|d dkrF|jtkrFtj|ddS t|tkrr|jtkrr|d d d d df S |S )N   )Zaxisr   )shapelenr   ndimr   r   Zexpand_dims)r   r   r   r   r   r   r   r   r   (   s    "z.preserve_channel_dim.<locals>.wrapped_functionr   r   r   r   r   preserve_channel_dim#   s    "
r"   )sys	functoolsr   typingr   Znumpyr   Zalbucore.utilsr   r   r   version_infor	   Ztyping_extensionsr   r   r"   r   r   r   r   <module>   s   
