o
    *jl                     @   s   d dl mZmZ d dlm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 ejejejdejejejdejejejdG d	d
 d
e	ZdS )    )AnyDict)	Pipelines)
OutputKeys)InputPipeline)	PIPELINES)	LoadImage)Tasks)module_namec                       s   e Zd Zdef fddZdedeeef fddZdeeef deeef fdd	Z	d
eeef deeef fddZ
  ZS )ImageSalientDetectionPipelinemodelc                    s   t  jd|dd| dS )z8
            model: model id on modelscope hub.
        F)r   Zauto_collateN )super__init__)selfr   kwargs	__class__r   y/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/modelscope/pipelines/cv/image_salient_detection_pipeline.pyr      s   z&ImageSalientDetectionPipeline.__init__inputreturnc                 C   s2   t |}|j\}}}| j|}|||d}|S )N)imgimg_wimg_h)r	   Zconvert_to_ndarrayshaper   
preprocess)r   r   r   r   r   _resultr   r   r   r      s
   
z(ImageSalientDetectionPipeline.preprocessc                 C   s(   | j |d }||d |d d}|S )Nr   r   r   )datar   r   )r   Z	inference)r   r   outputsr   r   r   r   forward$   s   z%ImageSalientDetectionPipeline.forwardinputsc                 C   s   | j |}tj|i}|S )N)r   postprocessr   ZMASKS)r   r"   r   r    r   r   r   r#   .   s   
z)ImageSalientDetectionPipeline.postprocess)__name__
__module____qualname__strr   r   r   r   r   r!   r#   __classcell__r   r   r   r   r      s
    	"*
r   N)typingr   r   Zmodelscope.metainfor   Zmodelscope.outputsr   Zmodelscope.pipelines.baser   r   Zmodelscope.pipelines.builderr   Zmodelscope.preprocessorsr	   Zmodelscope.utils.constantr
   Zregister_moduleZsemantic_segmentationZsalient_detectionZsalient_boudary_detectionZcamouflaged_detectionr   r   r   r   r   <module>   s$   