@@ -190,17 +190,36 @@ class DiffusionPipelineWrapper:
190190    Monolithic diffusion pipelines wrapper. 
191191    """ 
192192
193-     __LAST_CALLED  =  None 
193+     __LAST_RECALL_PIPELINE : _pipelines .TorchPipelineFactory  =  None 
194+     __LAST_RECALL_SECONDARY_PIPELINE : _pipelines .TorchPipelineFactory  =  None 
194195
195196    @staticmethod  
196-     def  last_called_wrapper () ->  typing .Optional ['DiffusionPipelineWrapper' ]:
197+     def  recall_last_used_main_pipeline () ->  typing .Optional [_pipelines . TorchPipelineCreationResult ]:
197198        """ 
198-         Return a reference to the last :py:class:`DiffusionPipelineWrapper ` 
199-         that successfully executed an image generation. 
199+         Return a reference to the last :py:class:`dgenerate.pipelinewrapper.pipelines.TorchPipelineCreationResult ` 
200+         for the pipeline  that successfully executed an image generation. 
200201
201-         :return: :py:class:`DiffusionPipelineWrapper` 
202+         This may recreate the pipeline if it is not cached. 
203+ 
204+         If no image generation has occurred, this will return ``None``. 
205+ 
206+         :return: :py:class:`dgenerate.pipelinewrapper.pipelines.TorchPipelineCreationResult` or ``None`` 
207+         """ 
208+         return  DiffusionPipelineWrapper .__LAST_RECALL_PIPELINE ()
209+ 
210+     @staticmethod  
211+     def  recall_last_used_secondary_pipeline () ->  typing .Optional [_pipelines .TorchPipelineCreationResult ]:
212+         """ 
213+         Return a reference to the last :py:class:`dgenerate.pipelinewrapper.pipelines.TorchPipelineCreationResult` 
214+         for the secondary pipeline (refiner / stable cascade decoder) that successfully executed an image generation. 
215+ 
216+         This may recreate the pipeline if it is not cached. 
217+ 
218+         If no image generation has occurred or no secondary pipeline has been called, this will return ``None``. 
219+ 
220+         :return: :py:class:`dgenerate.pipelinewrapper.pipelines.TorchPipelineCreationResult` or ``None`` 
202221        """ 
203-         return  DiffusionPipelineWrapper .__LAST_CALLED 
222+         return  DiffusionPipelineWrapper .__LAST_RECALL_SECONDARY_PIPELINE () 
204223
205224    def  __str__ (self ):
206225        return  f'{ self .__class__ .__name__ } { str (_types .get_public_attributes (self ))}  
@@ -524,7 +543,7 @@ def _init(
524543        self ._pipeline_type  =  None 
525544        self ._local_files_only  =  local_files_only 
526545        self ._recall_main_pipeline  =  None 
527-         self ._recall_refiner_pipeline  =  None 
546+         self ._recall_secondary_pipeline  =  None 
528547        self ._model_extra_modules  =  model_extra_modules 
529548        self ._second_model_extra_modules  =  second_model_extra_modules 
530549        self ._model_cpu_offload  =  model_cpu_offload 
@@ -2642,23 +2661,23 @@ def recall_main_pipeline(self) -> _pipelines.PipelineCreationResult:
26422661
26432662        return  self ._recall_main_pipeline ()
26442663
2645-     def  recall_refiner_pipeline (self ) ->  _pipelines .PipelineCreationResult :
2664+     def  recall_secondary_pipeline (self ) ->  _pipelines .PipelineCreationResult :
26462665        """ 
2647-         Fetch the last used refiner pipeline creation result, possibly the  
2648-         pipeline will be recreated if no longer in the in memory cache. 
2649-         If there is no refiner pipeline currently created, which will be the 
2650-         case if an image was never generated yet or a refiner model was not 
2666+         Fetch the last used refiner / stable cascade decoder  pipeline creation result, 
2667+         possibly the  pipeline will be recreated if no longer in the in memory cache. 
2668+         If there is no refiner / decoder  pipeline currently created, which will be the 
2669+         case if an image was never generated yet or a refiner / decoder  model was not 
26512670        specified, :py:exc:`RuntimeError` will be raised. 
26522671
26532672        :raises RuntimeError: 
26542673
26552674        :return: :py:class:`dgenerate.pipelinewrapper.PipelineCreationResult` 
26562675        """ 
26572676
2658-         if  self ._recall_refiner_pipeline  is  None :
2677+         if  self ._recall_secondary_pipeline  is  None :
26592678            raise  RuntimeError ('Cannot recall refiner pipeline as one has not been created.' )
26602679
2661-         return  self ._recall_refiner_pipeline ()
2680+         return  self ._recall_secondary_pipeline ()
26622681
26632682    def  _lazy_init_pipeline (self , args : DiffusionArguments ):
26642683
@@ -2703,7 +2722,7 @@ def _lazy_init_pipeline(self, args: DiffusionArguments):
27032722        self ._pipeline_type  =  pipeline_type 
27042723
27052724        self ._recall_main_pipeline  =  None 
2706-         self ._recall_refiner_pipeline  =  None 
2725+         self ._recall_secondary_pipeline  =  None 
27072726
27082727        if  self ._parsed_adetailer_detector_uris :
27092728            pipeline_type  =  _enums .PipelineType .INPAINT 
@@ -2739,7 +2758,7 @@ def _lazy_init_pipeline(self, args: DiffusionArguments):
27392758            creation_result  =  self ._recall_main_pipeline ()
27402759            self ._pipeline  =  creation_result .pipeline 
27412760
2742-             self ._recall_s_cascade_decoder_pipeline  =  _pipelines .TorchPipelineFactory (
2761+             self ._recall_secondary_pipeline  =  _pipelines .TorchPipelineFactory (
27432762                model_path = self ._parsed_s_cascade_decoder_uri .model ,
27442763                model_type = _enums .ModelType .TORCH_S_CASCADE_DECODER ,
27452764                pipeline_type = _enums .PipelineType .TXT2IMG ,
@@ -2764,7 +2783,7 @@ def _lazy_init_pipeline(self, args: DiffusionArguments):
27642783                model_cpu_offload = self ._second_model_cpu_offload ,
27652784                sequential_cpu_offload = self ._second_model_sequential_offload )
27662785
2767-             creation_result  =  self ._recall_s_cascade_decoder_pipeline ()
2786+             creation_result  =  self ._recall_secondary_pipeline ()
27682787            self ._s_cascade_decoder_pipeline  =  creation_result .pipeline 
27692788
27702789        elif  self ._sdxl_refiner_uri  is  not None :
@@ -2822,7 +2841,7 @@ def _lazy_init_pipeline(self, args: DiffusionArguments):
28222841            else :
28232842                refiner_extra_modules  =  self ._second_model_extra_modules 
28242843
2825-             self ._recall_refiner_pipeline  =  _pipelines .TorchPipelineFactory (
2844+             self ._recall_secondary_pipeline  =  _pipelines .TorchPipelineFactory (
28262845                model_path = self ._parsed_sdxl_refiner_uri .model ,
28272846                model_type = _enums .ModelType .TORCH_SDXL ,
28282847                pipeline_type = refiner_pipeline_type ,
@@ -2848,7 +2867,7 @@ def _lazy_init_pipeline(self, args: DiffusionArguments):
28482867                model_cpu_offload = self ._second_model_cpu_offload ,
28492868                sequential_cpu_offload = self ._second_model_sequential_offload 
28502869            )
2851-             self ._sdxl_refiner_pipeline  =  self ._recall_refiner_pipeline ().pipeline 
2870+             self ._sdxl_refiner_pipeline  =  self ._recall_secondary_pipeline ().pipeline 
28522871        else :
28532872            self ._recall_main_pipeline  =  _pipelines .TorchPipelineFactory (
28542873                model_path = self ._model_path ,
@@ -3189,7 +3208,8 @@ def __call__(self, args: DiffusionArguments | None = None, **kwargs) -> Pipeline
31893208            result  =  self ._call_torch (pipeline_args = pipeline_args ,
31903209                                      user_args = copy_args )
31913210
3192-         DiffusionPipelineWrapper .__LAST_CALLED  =  self 
3211+         DiffusionPipelineWrapper .__LAST_RECALL_PIPELINE  =  self ._recall_main_pipeline 
3212+         DiffusionPipelineWrapper .__LAST_RECALL_SECONDARY_PIPELINE  =  self ._recall_secondary_pipeline 
31933213
31943214        return  result 
31953215
0 commit comments