Skip to content

Commit

Permalink
handle pipeline class switch error
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Mandic <[email protected]>
  • Loading branch information
vladmandic committed Feb 24, 2025
1 parent c11952a commit 30f7602
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- zluda force sync
- fix torch import on compile
- infotext parser force delimiter before params
- handle pipeline class switch errors

## Update for 2025-02-18

Expand Down
2 changes: 1 addition & 1 deletion extensions-builtin/sd-extension-chainner
3 changes: 3 additions & 0 deletions modules/face/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def run(self, p: processing.StableDiffusionProcessing, mode, input_images, reswa
from modules.face.photomaker import photo_maker
photo_maker(p, app=app, input_images=input_images, model=pm_model, trigger=pm_trigger, strength=pm_strength, start=pm_start)
elif mode == 'InstantID':
if hasattr(p, 'init_images') and p.init_images is not None and len(p.init_images) > 0:
shared.log.warning('Face: InstantID with init image not supported')
input_images += p.init_images
from modules.face.insightface import get_app
app=get_app('antelopev2')
from modules.face.instantid import instant_id # instantid creates pipeline and triggers original process_images
Expand Down
3 changes: 2 additions & 1 deletion modules/face/instantid_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,15 @@ def _encode_prompt_image_emb(self, prompt_image_emb, device, dtype, do_classifie
else:
prompt_image_emb = torch.tensor(prompt_image_emb)

prompt_image_emb = prompt_image_emb.to(device=device, dtype=dtype)
prompt_image_emb = prompt_image_emb.reshape([1, -1, self.image_proj_model_in_features])

if do_classifier_free_guidance:
prompt_image_emb = torch.cat([torch.zeros_like(prompt_image_emb), prompt_image_emb], dim=0)
else:
prompt_image_emb = torch.cat([prompt_image_emb], dim=0)

prompt_image_emb = prompt_image_emb.to(device=device, dtype=dtype)
self.image_proj_model = self.image_proj_model.to(device=device, dtype=dtype)
prompt_image_emb = self.image_proj_model(prompt_image_emb)
return prompt_image_emb

Expand Down
6 changes: 4 additions & 2 deletions modules/sd_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ def set_diffuser_pipe(pipe, new_pipe_type):
'StableVideoDiffusionPipeline',
'PixelSmithXLPipeline',
'PhotoMakerStableDiffusionXLPipeline',
'StableDiffusionXLInstantIDPipeline',
]

has_errors = False
Expand Down Expand Up @@ -828,9 +829,10 @@ def set_diffuser_pipe(pipe, new_pipe_type):
except Exception as e: # pylint: disable=unused-variable
shared.log.warning(f'Pipeline class set failed: type={new_pipe_type} pipeline={cls} {e}')
has_errors = True
return pipe

# if pipe.__class__ == new_pipe.__class__:
# return pipe
if new_pipe is None:
return pipe
new_pipe.sd_checkpoint_info = sd_checkpoint_info
new_pipe.sd_model_checkpoint = sd_model_checkpoint
new_pipe.embedding_db = embedding_db
Expand Down

0 comments on commit 30f7602

Please sign in to comment.