fix img2img interrogate

This commit is contained in:
Vladimir Mandic
2023-12-30 08:08:41 -05:00
parent 8db8b643ab
commit 176b341bdf
7 changed files with 16 additions and 8 deletions
+4 -2
View File
@@ -80,12 +80,13 @@ class InterrogateModels:
self.create_fake_fairscale()
import models.blip # pylint: disable=no-name-in-module
model_path = os.path.join(paths.models_path, "BLIP")
shared.log.debug(f'Loading interrogate model: type=BLIP folder={model_path}')
download_name='model_base_caption_capfilt_large.pth',
shared.log.debug(f'Model interrogate load: type=BLiP model={download_name} path={model_path}')
files = modelloader.load_models(
model_path=model_path,
model_url='https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model_base_caption_capfilt_large.pth',
ext_filter=[".pth"],
download_name='model_base_caption_capfilt_large.pth',
download_name=download_name,
)
blip_model = models.blip.blip_decoder(pretrained=files[0], image_size=blip_image_eval_size, vit='base', med_config=os.path.join(paths.paths["BLIP"], "configs", "med_config.json")) # pylint: disable=c-extension-no-member
blip_model.eval()
@@ -93,6 +94,7 @@ class InterrogateModels:
return blip_model
def load_clip_model(self):
shared.log.debug(f'Model interrogate load: type=CLiP model={clip_model_name} path={shared.opts.clip_models_path}')
import clip
if self.running_on_cpu:
model, preprocess = clip.load(clip_model_name, device="cpu", download_root=shared.opts.clip_models_path)
+3 -3
View File
@@ -217,14 +217,14 @@ def process_diffusers(p: StableDiffusionProcessing):
if 'prompt' in possible:
if hasattr(model, 'text_encoder') and 'prompt_embeds' in possible and len(p.prompt_embeds) > 0 and p.prompt_embeds[0] is not None:
args['prompt_embeds'] = p.prompt_embeds[0]
if 'XL' in model.__class__.__name__:
args['pooled_prompt_embeds'] = p.positive_pooleds[0]
if 'XL' in model.__class__.__name__ and len(getattr(p, 'negative_pooleds', [])) > 0:
args['pooled_prompt_embeds'] = p.negative_pooleds[0]
else:
args['prompt'] = prompts
if 'negative_prompt' in possible:
if hasattr(model, 'text_encoder') and 'negative_prompt_embeds' in possible and len(p.negative_embeds) > 0 and p.negative_embeds[0] is not None:
args['negative_prompt_embeds'] = p.negative_embeds[0]
if 'XL' in model.__class__.__name__:
if 'XL' in model.__class__.__name__ and len(getattr(p, 'negative_pooleds', [])) > 0:
args['negative_pooled_prompt_embeds'] = p.negative_pooleds[0]
else:
args['negative_prompt'] = negative_prompts
+1
View File
@@ -111,6 +111,7 @@ def parse_style(styles):
def process_interrogate(interrogation_function, mode, ii_input_files, ii_input_dir, ii_output_dir, *ii_singles):
mode = int(mode)
if mode in {0, 1, 3, 4}:
return [interrogation_function(ii_singles[mode]), None]
if mode == 2: