fix blipdiffusion

This commit is contained in:
Vladimir Mandic
2024-01-27 08:53:17 -05:00
parent 0bfb17ba72
commit e6a1946e06
3 changed files with 19 additions and 1 deletions
+5
View File
@@ -128,6 +128,11 @@ As of this release, default backend is set to **diffusers** as its more feature
- [FreeInit](https://tianxingwu.github.io/pages/FreeInit/) for **AnimateDiff**
- greatly improves temporal consistency of generated outputs
- all options are available in animateddiff script
- [SalesForce BlipDiffusion](https://huggingface.co/docs/diffusers/api/pipelines/blip_diffusion)
- model can be used to replace anything in an image
- requires input image
- last word in prompt and negative prompt will be used as source and target subjects
- sampler must be set to default before loading the model
- **Improvements**
- **ui**
- check version and **update** SD.Next via UI
+10
View File
@@ -189,6 +189,16 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
'width': p.width if hasattr(p, 'width') else None,
'height': p.height if hasattr(p, 'height') else None,
}
if model.__class__.__name__ == 'BlipDiffusionPipeline':
if len(getattr(p, 'init_images', [])) == 0:
shared.log.error('BLiP diffusion requires init image')
return task_args
task_args = {
'reference_image': p.init_images[0],
'source_subject_category': getattr(p, 'negative_prompt', '').split()[-1],
'target_subject_category': getattr(p, 'prompt', '').split()[-1],
'output_type': 'pil',
}
debug(f'Diffusers task specific args: {task_args}')
return task_args
@@ -269,7 +269,10 @@ class EmbeddingDatabase:
if loaded_embeddings.get(embedding.name, None) == embedding:
continue
self.skipped_embeddings[embedding.name] = embedding
debug(f"TI Loading: Text Encoder total embeddings={shared.sd_model.text_encoder.get_input_embeddings().weight.data.shape[0]}")
try:
debug(f"TI Loading: Text Encoder total embeddings={shared.sd_model.text_encoder.get_input_embeddings().weight.data.shape[0]}")
except Exception:
pass
if model_type == 'SDXL':
debug(f"TI Loading: Text Encoder 2 total embeddings={shared.sd_model.text_encoder_2.get_input_embeddings().weight.data.shape[0]}")
return len(self.word_embeddings) - _loaded_pre