o
    0jD                     @   s   d dl mZmZmZmZmZmZmZ d dlZ	ddl
mZ ddlmZmZ ddlmZ ddlmZ d	d
lmZ d	dlmZ ejG dd deZedG dd deZdS )    )AnyDictListLiteralOptionalTupleUnionN   )pipeline_requires_extra   )	HPIConfigPaddlePredictorOption)	SegResult)	benchmark   )(AutoParallelImageSimpleInferencePipeline)BasePipelinec                       s   e Zd ZdZddddddddedee dee deeeef  d	ee d
e	dee
eeef ef  ddf fddZ	dde
eee ejeej f de
ed deee f defddZ  ZS )_SemanticSegmentationPipelinezSemantic Segmentation PipelineNFdeviceengineengine_config	pp_optionuse_hpip
hpi_configconfigr   r   r   r   r   r   returnc          
   	      sF   t  jd||||||d| |d d }	| |	| _|	d | _dS )a  Initializes the semantic segmentation pipeline.

        Args:
            config (Dict): Configuration dictionary containing model and other parameters.
            device (Optional[str], optional): The device to use for prediction. Defaults to `None`.
            engine (Optional[str], optional): Inference engine. Defaults to `None`.
            engine_config (Optional[Dict[str, Any]], optional): Engine-specific config. Defaults to `None`.
            pp_option (Optional[PaddlePredictorOption], optional): Paddle predictor options.
                Defaults to `None`.
            use_hpip (bool, optional): Whether to use HPIP. Defaults to `False`.
            hpi_config (Optional[Union[Dict[str, Any], HPIConfig]], optional):
                HPIP configuration. Defaults to `None`.
        r   
SubModulesSemanticSegmentationtarget_sizeN )super__init__Zcreate_modelsemantic_segmentation_modelr   )
selfr   r   r   r   r   r   r   kwargsZ"semantic_segmentation_model_config	__class__r    {/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/pipelines/semantic_segmentation/pipeline.pyr"      s"   
z&_SemanticSegmentationPipeline.__init__inputr   c                 k   s    | j ||dE dH  dS )a^  Predicts semantic segmentation results for the given input.

        Args:
            input (str | list[str] | np.ndarray | list[np.ndarray]): The input image(s) or path(s) to the images.
            target_size (Literal[-1] | None | int | tuple[int]): The Image size model used to do prediction. Default is None.
                If it's set to -1, the original image size will be used.
                If it's set to None, the previous level's setting will be used.
                If it's set to an integer value, the image will be rescaled to the size of (value, value).
                If it's set to a tuple of two integers, the image will be rescaled to the size of (height, width).
            **kwargs: Additional keyword arguments that can be passed to the function.

        Returns:
            SegResult: The predicted segmentation results.
        )r   N)r#   )r$   r)   r   r%   r    r    r(   predictJ   s   z%_SemanticSegmentationPipeline.predictN)__name__
__module____qualname____doc__r   r   strr   r   boolr   r   r"   r   npZndarrayr   intr   r   r+   __classcell__r    r    r&   r(   r      sB    	.r   Zcvc                   @   s$   e Zd ZdZedd Zdd ZdS )SemanticSegmentationPipelineZsemantic_segmentationc                 C   s   t S r,   )r   )r$   r    r    r(   _pipeline_clse   s   z*SemanticSegmentationPipeline._pipeline_clsc                 C   s   |d d  ddS )Nr   r   Z
batch_size   )get)r$   r   r    r    r(   _get_batch_sizei   s   z,SemanticSegmentationPipeline._get_batch_sizeN)r-   r.   r/   entitiespropertyr7   r:   r    r    r    r(   r6   a   s
    
r6   )typingr   r   r   r   r   r   r   numpyr3   Z
utils.depsr
   modelsr   r   Z#models.semantic_segmentation.resultr   Zutils.benchmarkr   Z	_parallelr   baser   Ztime_methodsr   r6   r    r    r    r(   <module>   s   $E