Skip to content

Commit 30f7602

Browse files
committed
handle pipeline class switch error
Signed-off-by: Vladimir Mandic <[email protected]>
1 parent c11952a commit 30f7602

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- zluda force sync
2727
- fix torch import on compile
2828
- infotext parser force delimiter before params
29+
- handle pipeline class switch errors
2930

3031
## Update for 2025-02-18
3132

modules/face/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ def run(self, p: processing.StableDiffusionProcessing, mode, input_images, reswa
143143
from modules.face.photomaker import photo_maker
144144
photo_maker(p, app=app, input_images=input_images, model=pm_model, trigger=pm_trigger, strength=pm_strength, start=pm_start)
145145
elif mode == 'InstantID':
146+
if hasattr(p, 'init_images') and p.init_images is not None and len(p.init_images) > 0:
147+
shared.log.warning('Face: InstantID with init image not supported')
148+
input_images += p.init_images
146149
from modules.face.insightface import get_app
147150
app=get_app('antelopev2')
148151
from modules.face.instantid import instant_id # instantid creates pipeline and triggers original process_images

modules/face/instantid_model.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,15 @@ def _encode_prompt_image_emb(self, prompt_image_emb, device, dtype, do_classifie
528528
else:
529529
prompt_image_emb = torch.tensor(prompt_image_emb)
530530

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

534533
if do_classifier_free_guidance:
535534
prompt_image_emb = torch.cat([torch.zeros_like(prompt_image_emb), prompt_image_emb], dim=0)
536535
else:
537536
prompt_image_emb = torch.cat([prompt_image_emb], dim=0)
538537

538+
prompt_image_emb = prompt_image_emb.to(device=device, dtype=dtype)
539+
self.image_proj_model = self.image_proj_model.to(device=device, dtype=dtype)
539540
prompt_image_emb = self.image_proj_model(prompt_image_emb)
540541
return prompt_image_emb
541542

modules/sd_models.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def set_diffuser_pipe(pipe, new_pipe_type):
760760
'StableVideoDiffusionPipeline',
761761
'PixelSmithXLPipeline',
762762
'PhotoMakerStableDiffusionXLPipeline',
763+
'StableDiffusionXLInstantIDPipeline',
763764
]
764765

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

832-
# if pipe.__class__ == new_pipe.__class__:
833-
# return pipe
834+
if new_pipe is None:
835+
return pipe
834836
new_pipe.sd_checkpoint_info = sd_checkpoint_info
835837
new_pipe.sd_model_checkpoint = sd_model_checkpoint
836838
new_pipe.embedding_db = embedding_db

0 commit comments

Comments
 (0)