From 669799bfccc8d615ca1befc9f4079dbafcb5f776 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sun, 5 Jan 2025 08:13:41 -0500 Subject: [PATCH] fix pulid Signed-off-by: Vladimir Mandic --- modules/processing_args.py | 4 +++- modules/processing_callbacks.py | 13 +++++++++---- modules/progress.py | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/processing_args.py b/modules/processing_args.py index 32fac0b17..529971d5c 100644 --- a/modules/processing_args.py +++ b/modules/processing_args.py @@ -109,8 +109,10 @@ def set_pipeline_args(p, model, prompts:list, negative_prompts:list, prompts_2:t if hasattr(model, "set_progress_bar_config"): model.set_progress_bar_config(bar_format='Progress {rate_fmt}{postfix} {bar} {percentage:3.0f}% {n_fmt}/{total_fmt} {elapsed} {remaining} ' + '\x1b[38;5;71m' + desc, ncols=80, colour='#327fba') args = {} + has_vae = hasattr(model, 'vae') or (hasattr(model, 'pipe') and hasattr(model.pipe, 'vae')) if hasattr(model, 'pipe') and not hasattr(model, 'no_recurse'): # recurse model = model.pipe + has_vae = has_vae or hasattr(model, 'vae') signature = inspect.signature(type(model).__call__, follow_wrapped=True) possible = list(signature.parameters) @@ -233,7 +235,7 @@ def set_pipeline_args(p, model, prompts:list, negative_prompts:list, prompts_2:t if sd_models.get_diffusers_task(model) == sd_models.DiffusersTaskType.TEXT_2_IMAGE: args['latents'] = p.init_latent if 'output_type' in possible: - if not hasattr(model, 'vae'): + if not has_vae: kwargs['output_type'] = 'np' # only set latent if model has vae # model specific diff --git a/modules/processing_callbacks.py b/modules/processing_callbacks.py index a9c6fbcf7..d3e57818b 100644 --- a/modules/processing_callbacks.py +++ b/modules/processing_callbacks.py @@ -27,7 +27,7 @@ def prompt_callback(step, kwargs): assert prompt_embeds.shape == kwargs['prompt_embeds'].shape, f"prompt_embed shape mismatch {kwargs['prompt_embeds'].shape} {prompt_embeds.shape}" kwargs['prompt_embeds'] = prompt_embeds except Exception as e: - debug_callback(f"Callback: {e}") + debug_callback(f"Callback: type=prompt {e}") return kwargs @@ -115,11 +115,16 @@ def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict = {} shared.state.current_latent = kwargs['latents'] shared.state.current_noise_pred = current_noise_pred - if hasattr(pipe, "scheduler") and hasattr(pipe.scheduler, "sigmas") and hasattr(pipe.scheduler, "step_index"): - shared.state.current_sigma = pipe.scheduler.sigmas[pipe.scheduler.step_index - 1] - shared.state.current_sigma_next = pipe.scheduler.sigmas[pipe.scheduler.step_index] + if hasattr(pipe, "scheduler") and hasattr(pipe.scheduler, "sigmas") and hasattr(pipe.scheduler, "step_index") and pipe.scheduler.step_index is not None: + try: + shared.state.current_sigma = pipe.scheduler.sigmas[pipe.scheduler.step_index-1] + shared.state.current_sigma_next = pipe.scheduler.sigmas[pipe.scheduler.step_index] + except Exception: + pass except Exception as e: shared.log.error(f'Callback: {e}') + # from modules import errors + # errors.display(e, 'Callback') if shared.cmd_opts.profile and shared.profiler is not None: shared.profiler.step() t1 = time.time() diff --git a/modules/progress.py b/modules/progress.py index bc3e5500c..f6b47f1c0 100644 --- a/modules/progress.py +++ b/modules/progress.py @@ -80,7 +80,7 @@ def progressapi(req: ProgressRequest): id_live_preview = req.id_live_preview live_preview = None updated = shared.state.set_current_image() - debug_log(f'Preview: job={shared.state.job} active={active} progress={current}/{total} step={shared.state.current_image_sampling_step}/{shared.state.sampling_step} request={id_live_preview} last={shared.state.id_live_preview} enabled={shared.opts.live_previews_enable} job={shared.state.preview_job} updated={updated} image={shared.state.current_image} elapsed={elapsed:.3f}') + debug_log(f'Preview: job={shared.state.job} active={active} progress={current}/{total} step={shared.state.current_image_sampling_step}/{step_x}/{step_y} request={id_live_preview} last={shared.state.id_live_preview} enabled={shared.opts.live_previews_enable} job={shared.state.preview_job} updated={updated} image={shared.state.current_image} elapsed={elapsed:.3f}') if not active: return InternalProgressResponse(job=shared.state.job, active=active, queued=queued, paused=paused, completed=completed, id_live_preview=-1, debug=debug, textinfo="Queued..." if queued else "Waiting...") if shared.opts.live_previews_enable and (shared.state.id_live_preview != id_live_preview) and (shared.state.current_image is not None):