o
    ॵi                     @   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	m
Z
 d dlmZ d dlmZmZ d dlmZmZ d dlmZ e Zejejejd	G d
d de
ZdS )    )AnyDict)	Pipelines)
OutputKeys)InputModelPipeline)	PIPELINES)is_modelis_official_hub_path)InvokeTasks)
get_logger)module_namec                       s   e Zd ZdZ							d 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	deeef deeef fddZ
  ZS )NeRFRecon4KPipelinea   NeRF reconstruction acceleration pipeline
    Example:

    ```python
    >>> from modelscope.pipelines import pipeline
    >>> nerf_recon_acc = pipeline(Tasks.nerf_recon_acc,
                'damo/cv_nerf-3d-reconstruction-accelerate_damo')
    >>> nerf_recon_acc({
            'data_dir': '/data/lego', # data dir path (str)
            'render_dir': 'save_dir', # save dir path (str)
        })
    >>> #
    ```
    blender            ?      gpuc	           
         s   t |rtj||dtj||||||d
n|}t jd
d|i|	 t| jts0t	
d td|| _| jdkrE| jdkrEtd| jt	d d	S )ae  
        use model to create a image sky change pipeline for image editing
        Args:
            model (str or Model): model_id on modelscope hub
            data_type (str): currently only support 'blender' and 'colmap'
            use_mask (bool): segment the object or not
            ckpt_path (str): the checkpoint ckpt_path
            save_mesh (bool): render mesh or not
            n_test_traj_steps (int): number of random sampled images for test view, only for colmap data.
            test_ray_chunk (int): ray chunk size for test, avoid GPU OOM
            device (str): only support gpu
        T)	devicemodel_prefetched
invoked_by	data_typetest_ray_chunk	test_tilestepsizefactorload_srmodelz model object is not initialized.r   llffz%data type {} is not support currentlyzload model doneN )r
   r   from_pretrainedr   PIPELINEsuper__init__
isinstancer!   loggererror	Exceptionr   formatinfo)
selfr!   r   r   r   r   r   r    r   kwargs	__class__r#   b/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/cv/nerf_recon_4k_pipeline.pyr'   !   s2    

zNeRFRecon4KPipeline.__init__inputsreturnc                 C      |S Nr#   r.   r3   r#   r#   r2   
preprocessM      zNeRFRecon4KPipeline.preprocessinputc                 C   s(   |d }|d }| j || tjdiS )Ndata_cfg
render_dirDone)r!   nerf_reconstructionr   OUTPUT)r.   r:   r;   r<   r#   r#   r2   forwardP   s   
zNeRFRecon4KPipeline.forwardc                 C   r5   r6   r#   r7   r#   r#   r2   postprocessV   r9   zNeRFRecon4KPipeline.postprocess)r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r'   r   strr   r8   r@   rA   __classcell__r#   r#   r0   r2   r      s    ","*r   N)typingr   r   modelscope.metainfor   modelscope.outputsr   modelscope.pipelines.baser   r   r   modelscope.pipelines.builderr	   modelscope.pipelines.utilr
   r   modelscope.utils.constantr   r   modelscope.utils.loggerr   r)   register_modulenerf_recon_4kr   r#   r#   r#   r2   <module>   s   