restore ability to convert SDXL checkpoints to diffusers

This commit is contained in:
Lincoln Stein 2023-07-26 23:28:58 -04:00
parent d4d4d749f2
commit 77946bfea5
2 changed files with 2 additions and 5 deletions

View File

@ -112,16 +112,12 @@ class StableDiffusionXLModel(DiffusersModel):
# The convert script adapted from the diffusers package uses # The convert script adapted from the diffusers package uses
# strings for the base model type. To avoid making too many # strings for the base model type. To avoid making too many
# source code changes, we simply translate here # source code changes, we simply translate here
model_base_to_model_type = {BaseModelType.StableDiffusionXL: 'SDXL',
BaseModelType.StableDiffusionXLRefiner: 'SDXL-Refiner',
}
if isinstance(config, cls.CheckpointConfig): if isinstance(config, cls.CheckpointConfig):
from invokeai.backend.model_management.models.stable_diffusion import _convert_ckpt_and_cache from invokeai.backend.model_management.models.stable_diffusion import _convert_ckpt_and_cache
return _convert_ckpt_and_cache( return _convert_ckpt_and_cache(
version=base_model, version=base_model,
model_config=config, model_config=config,
output_path=output_path, output_path=output_path,
model_type=model_base_to_model_type[base_model],
use_safetensors=False, # corrupts sdxl models for some reason use_safetensors=False, # corrupts sdxl models for some reason
) )
else: else:

View File

@ -272,8 +272,9 @@ def _convert_ckpt_and_cache(
model_base_to_model_type = {BaseModelType.StableDiffusion1: 'FrozenCLIPEmbedder', model_base_to_model_type = {BaseModelType.StableDiffusion1: 'FrozenCLIPEmbedder',
BaseModelType.StableDiffusion2: 'FrozenOpenCLIPEmbedder', BaseModelType.StableDiffusion2: 'FrozenOpenCLIPEmbedder',
BaseModelType.StableDiffusionXL: 'SDXL',
BaseModelType.StableDiffusionXLRefiner: 'SDXL-Refiner',
} }
logger.info(f'Converting {weights} to diffusers format') logger.info(f'Converting {weights} to diffusers format')
with SilenceWarnings(): with SilenceWarnings():
convert_ckpt_to_diffusers( convert_ckpt_to_diffusers(