o
    ॵil                     @   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   auto_collateN )super__init__)selfr   kwargs	__class__r   l/home/ubuntu/.local/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	   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   	inference)r   r   outputsr    r   r   r   forward$   s   z%ImageSalientDetectionPipeline.forwardinputsc                 C   s   | j |}tj|i}|S )N)r   postprocessr   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   modelscope.metainfor   modelscope.outputsr   modelscope.pipelines.baser   r   modelscope.pipelines.builderr   modelscope.preprocessorsr	   modelscope.utils.constantr
   register_modulesemantic_segmentationsalient_detectionsalient_boudary_detectioncamouflaged_detectionr   r   r   r   r   <module>   s$   