
    9i                        S SK r S SKrS SKJrJrJr  S SKrS SKrS SK	r	S SK
Jr  S SKJr  S SKJr  S SKJrJrJr  S SKJr  S SKJr  S S	KJr  S S
KJr  \" 5       r\R:                  " \R<                  \R<                  S9 " S S\5      5       rg)    N)AnyDictUnion)	Pipelines)ImageSkyChangePreprocessor)
OutputKeys)InputModelPipeline)	PIPELINES)	LoadImage)Tasks)
get_logger)module_namec                      ^  \ rS rSrSrS\4U 4S jjrS\\\4   S\\\4   4S jr	S\\\4   S\\\4   4S	 jr
S
rU =r$ )ImageSkychangePipeline   a  
Image Sky Change Pipeline. Given two images(sky_image and scene_image), pipeline will replace the sky style
of sky_image with the sky style of scene_image.

Examples:

>>> from modelscope.pipelines import pipeline
>>> detector = pipeline('image-skychange', 'damo/cv_hrnetocr_skychange')
>>> detector({
        'sky_image': 'sky_image.jpg', # sky_image path (str)
        'scene_image': 'scene_image.jpg', # scene_image path (str)
    })
>>> {"output_img": [H * W * 3] 0~255, we can use cv2.imwrite to save output_img as an image.}
modelc                 
  > [         TU ]  " SSU0UD6  [        U R                  [        5      (       d   [
        R                  S5        [        S5      eU R                  c  [        5       U l        [
        R                  S5        g)z
use `model` to create a image sky change pipeline for image editing
Args:
    model (`str` or `Model`): model_id on modelscope hub
    preprocessor(`Preprocessor`, *optional*,  defaults to None): `ImageSkyChangePreprocessor`.
r   z model object is not initialized.Nzload model done )super__init__
isinstancer   r
   loggererror	Exceptionpreprocessorr   info)selfr   kwargs	__class__s      p/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/pipelines/cv/image_skychange_pipeline.pyr   ImageSkychangePipeline.__init__(   sh     	/u//$**e,,LL;<>??$ : <D%&    inputreturnc                 ^    U R                   R                  " S0 UD6n[        R                  U0$ )Nr   )r   forwardr   
OUTPUT_IMG)r   r%   ress      r"   r(   ImageSkychangePipeline.forward7   s*    jj  )5)%%s++r$   inputsc                     U$ )Nr   )r   r,   s     r"   postprocess"ImageSkychangePipeline.postprocess;   s    r$   )r   )__name__
__module____qualname____firstlineno____doc__strr   r   r   r(   r.   __static_attributes____classcell__)r!   s   @r"   r   r      s_    'c ',T#s(^ ,S#X ,$sCx. T#s(^  r$   r   ) pdbtimetypingr   r   r   cv2numpynpPILmodelscope.metainfor   $modelscope.models.cv.image_skychanger   modelscope.outputsr   modelscope.pipelines.baser	   r
   r   modelscope.pipelines.builderr   modelscope.preprocessorsr   modelscope.utils.constantr   modelscope.utils.loggerr   r   register_moduleimage_skychanger   r   r$   r"   <module>rI      su    
  # # 
  
 ) K ) < < 2 . + .	 	y'@'@B$X $B$r$   