diff --git a/modules/control/run.py b/modules/control/run.py index 2f2eb0cfc..4e13681fe 100644 --- a/modules/control/run.py +++ b/modules/control/run.py @@ -546,19 +546,21 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg if input_type == 1: debug_log('Control Init image: same as control') init_image = input_image - elif inits is None: + elif inits is None or len(inits) == 0: debug_log('Control Init image: none') init_image = None - elif isinstance(inits[i], str): + elif len(inits) > i and isinstance(inits[i], str): debug_log(f'Control: init image: {inits[i]}') try: init_image = Image.open(inits[i]) except Exception as e: log.error(f'Control: image open failed: path={inits[i]} type=init error={e}') continue - else: + elif len(inits) > i: debug_log(f'Control Init image: {i % len(inits) + 1} of {len(inits)}') init_image = inits[i % len(inits)] + else: + init_image = None if video is not None and index % (video_skip_frames + 1) != 0: index += 1 continue diff --git a/modules/model_quant.py b/modules/model_quant.py index 63ab5cf07..b57c29582 100644 --- a/modules/model_quant.py +++ b/modules/model_quant.py @@ -611,7 +611,7 @@ def sdnq_quantize_model(model, op=None, sd_model=None, do_gc: bool = True, weigh if quantized_matmul_dtype is None: quantized_matmul_dtype = "auto" # set for logging - log.debug(f'Quantization: module="{op if op is not None else model.__class__}" type=sdnq mode=post dtype={weights_dtype} matmul_dtype={quantized_matmul_dtype} matmul={shared.opts.sdnq_use_quantized_matmul} svd={shared.opts.sdnq_use_svd}dynamic={shared.opts.sdnq_use_dynamic_quantization}:group={shared.opts.sdnq_quantize_weights_group_size}:rank={shared.opts.sdnq_svd_rank}:steps={shared.opts.sdnq_svd_steps}:loss={shared.opts.sdnq_dynamic_loss_threshold} quant_conv={shared.opts.sdnq_quantize_conv_layers} matmul_conv={shared.opts.sdnq_use_quantized_matmul_conv} fp32={shared.opts.sdnq_dequantize_fp32} gpu={shared.opts.sdnq_quantize_with_gpu} device={quantization_device} return={return_device} map={shared.opts.device_map} non_blocking={shared.opts.diffusers_offload_nonblocking} modules_skip={modules_to_not_convert} modules_dtype={modules_dtype_dict}') + log.debug(f'Quantization: module="{op if op is not None else model.__class__}" type=sdnq mode=post dtype={weights_dtype} matmul_dtype={quantized_matmul_dtype} matmul={shared.opts.sdnq_use_quantized_matmul} svd={shared.opts.sdnq_use_svd} dynamic={shared.opts.sdnq_use_dynamic_quantization}:group={shared.opts.sdnq_quantize_weights_group_size}:rank={shared.opts.sdnq_svd_rank}:steps={shared.opts.sdnq_svd_steps}:loss={shared.opts.sdnq_dynamic_loss_threshold} quant_conv={shared.opts.sdnq_quantize_conv_layers} matmul_conv={shared.opts.sdnq_use_quantized_matmul_conv} fp32={shared.opts.sdnq_dequantize_fp32} gpu={shared.opts.sdnq_quantize_with_gpu} device={quantization_device} return={return_device} map={shared.opts.device_map} non_blocking={shared.opts.diffusers_offload_nonblocking} modules_skip={modules_to_not_convert} modules_dtype={modules_dtype_dict}') return model diff --git a/modules/processing_prompt.py b/modules/processing_prompt.py index 98849b7a3..c689ef7ef 100644 --- a/modules/processing_prompt.py +++ b/modules/processing_prompt.py @@ -139,7 +139,7 @@ def set_prompt(p, if 'prompt_attention_mask' in possible: args['prompt_attention_mask'] = prompt_attention_masks - if 'negative_prompt' in possible: + if 'negative_prompt' in possible and prompt_parser_diffusers.embedder is not None: debug_log(f'Prompt set embeds: negative={negative_prompts}') negative_embeds = prompt_parser_diffusers.embedder('negative_prompt_embeds') negative_pooled_embeds = prompt_parser_diffusers.embedder('negative_pooleds') diff --git a/modules/prompt_parser_diffusers.py b/modules/prompt_parser_diffusers.py index 05d84e01f..46b195baa 100644 --- a/modules/prompt_parser_diffusers.py +++ b/modules/prompt_parser_diffusers.py @@ -517,18 +517,15 @@ def prepare_embedding_providers(pipe, clip_skip) -> list[EmbeddingsProvider]: no_mask_provider = EmbeddingsProvider(padding_attention_mask_value=1 if "sote" in pipe.sd_checkpoint_info.name.lower() else 0, tokenizer=pipe.prior_pipe.tokenizer, text_encoder=pipe.prior_pipe.text_encoder, **embedding_args) embeddings_providers.append(no_mask_provider) elif getattr(pipe, "tokenizer", None) is not None and getattr(pipe, "text_encoder", None) is not None: - if pipe.text_encoder.__class__.__name__.startswith('CLIP'): - sd_models.move_model(pipe.text_encoder, devices.device, force=True) + sd_models.move_model(pipe.text_encoder, devices.device, force=True) provider = EmbeddingsProvider(tokenizer=pipe.tokenizer, text_encoder=pipe.text_encoder, **embedding_args) embeddings_providers.append(provider) if getattr(pipe, "tokenizer_2", None) is not None and getattr(pipe, "text_encoder_2", None) is not None: - if pipe.text_encoder_2.__class__.__name__.startswith('CLIP'): - sd_models.move_model(pipe.text_encoder_2, devices.device, force=True) + sd_models.move_model(pipe.text_encoder_2, devices.device, force=True) provider = EmbeddingsProvider(tokenizer=pipe.tokenizer_2, text_encoder=pipe.text_encoder_2, **embedding_args) embeddings_providers.append(provider) if getattr(pipe, "tokenizer_3", None) is not None and getattr(pipe, "text_encoder_3", None) is not None: - if pipe.text_encoder_3.__class__.__name__.startswith('CLIP'): - sd_models.move_model(pipe.text_encoder_3, devices.device, force=True) + sd_models.move_model(pipe.text_encoder_3, devices.device, force=True) provider = EmbeddingsProvider(tokenizer=pipe.tokenizer_3, text_encoder=pipe.text_encoder_3, **embedding_args) embeddings_providers.append(provider) return embeddings_providers diff --git a/modules/sd_models.py b/modules/sd_models.py index 77497af51..db8996c28 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -17,7 +17,7 @@ from modules.shared_helpers import walk_files from modules.modeldata import model_data from modules.sd_checkpoint import CheckpointInfo, select_checkpoint, list_models, checkpoint_titles, get_closest_checkpoint_match, update_model_hashes, write_metadata, checkpoints_list # pylint: disable=unused-import from modules.sd_offload import get_module_names, disable_offload, set_diffuser_offload, apply_balanced_offload, set_accelerate # pylint: disable=unused-import -from modules.sd_models_utils import NoWatermark, get_signature, path_to_repo, apply_function_to_model, read_state_dict, get_state_dict_from_checkpoint # pylint: disable=unused-import +from modules.sd_models_utils import NoWatermark, get_signature, get_call, path_to_repo, apply_function_to_model, read_state_dict, get_state_dict_from_checkpoint # pylint: disable=unused-import model_dir = "Stable-diffusion"