Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around missing core conversion model issue #5947

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions invokeai/backend/model_manager/convert_ckpt_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@
CONVERT_MODEL_ROOT = InvokeAIAppConfig.get_config().models_path / "core/convert"


def install_dependencies():
"""
Check for, and install, missing model dependencies.
"""
conversion_models = [
"clip-vit-large-patch14",
"CLIP-ViT-H-14-laion2B-s32B-b79K",
"stable-diffusion-2-clip",
"stable-diffusion-safety-checker",
"CLIP-ViT-bigG-14-laion2B-39B-b160k",
"bert-base-uncased",
]
if any(not (CONVERT_MODEL_ROOT / x).exists() for x in conversion_models):
logger.warning("Installing missing core safetensor conversion models")
from invokeai.backend.install.invokeai_configure import download_conversion_models # noqa

download_conversion_models()


def shave_segments(path, n_shave_prefix_segments=1):
"""
Removes segments. Positive values shave the first segments, negative shave the last segments.
Expand Down Expand Up @@ -1697,6 +1716,8 @@ def download_controlnet_from_original_ckpt(


def convert_ldm_vae_to_diffusers(checkpoint, vae_config: DictConfig, image_size: int) -> AutoencoderKL:
install_dependencies()

vae_config = create_vae_diffusers_config(vae_config, image_size=image_size)

converted_vae_checkpoint = convert_ldm_vae_checkpoint(checkpoint, vae_config)
Expand All @@ -1717,6 +1738,7 @@ def convert_ckpt_to_diffusers(
and in addition a path-like object indicating the location of the desired diffusers
model to be written.
"""
install_dependencies()
pipe = download_from_original_stable_diffusion_ckpt(checkpoint_path, **kwargs)

# TO DO: save correct repo variant
Expand All @@ -1736,6 +1758,7 @@ def convert_controlnet_to_diffusers(
and in addition a path-like object indicating the location of the desired diffusers
model to be written.
"""
install_dependencies()
pipe = download_controlnet_from_original_ckpt(checkpoint_path, **kwargs)

# TO DO: save correct repo variant
Expand Down