Skip to content

Commit

Permalink
fix pulid
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Mandic <[email protected]>
  • Loading branch information
vladmandic committed Jan 5, 2025
1 parent 3047f92 commit 669799b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion modules/processing_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions modules/processing_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion modules/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 669799b

Please sign in to comment.