fix pag with batch count

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2024-12-22 17:38:51 -05:00
parent 6d3d23bddd
commit b15cf4adae
3 changed files with 14 additions and 11 deletions
+11 -10
View File
@@ -12,29 +12,29 @@ def apply(p: processing.StableDiffusionProcessing): # pylint: disable=arguments-
global orig_pipeline # pylint: disable=global-statement
if not shared.native:
return None
c = shared.sd_model.__class__ if shared.sd_loaded else None
if c == StableDiffusionPAGPipeline or c == StableDiffusionXLPAGPipeline:
unapply()
cls = shared.sd_model.__class__ if shared.sd_loaded else None
if cls == StableDiffusionPAGPipeline or cls == StableDiffusionXLPAGPipeline:
cls = unapply()
if p.pag_scale == 0:
return
if 'PAG' in shared.sd_model.__class__.__name__:
if 'PAG' in cls.__name__:
pass
elif detect.is_sd15(c):
elif detect.is_sd15(cls):
if sd_models.get_diffusers_task(shared.sd_model) != sd_models.DiffusersTaskType.TEXT_2_IMAGE:
shared.log.warning(f'PAG: pipeline={c} not implemented')
shared.log.warning(f'PAG: pipeline={cls.__name__} not implemented')
return None
orig_pipeline = shared.sd_model
shared.sd_model = sd_models.switch_pipe(StableDiffusionPAGPipeline, shared.sd_model)
elif detect.is_sdxl(c):
elif detect.is_sdxl(cls):
if sd_models.get_diffusers_task(shared.sd_model) != sd_models.DiffusersTaskType.TEXT_2_IMAGE:
shared.log.warning(f'PAG: pipeline={c} not implemented')
shared.log.warning(f'PAG: pipeline={cls.__name__} not implemented')
return None
orig_pipeline = shared.sd_model
shared.sd_model = sd_models.switch_pipe(StableDiffusionXLPAGPipeline, shared.sd_model)
elif detect.is_f1(c):
elif detect.is_f1(cls):
p.task_args['true_cfg_scale'] = p.pag_scale
else:
shared.log.warning(f'PAG: pipeline={c} required={StableDiffusionPipeline.__name__}')
shared.log.warning(f'PAG: pipeline={cls.__name__} required={StableDiffusionPipeline.__name__}')
return None
p.task_args['pag_scale'] = p.pag_scale
@@ -54,3 +54,4 @@ def unapply():
if orig_pipeline is not None:
shared.sd_model = orig_pipeline
orig_pipeline = None
return shared.sd_model.__class__