Skip to content

add check to ensure CLIP is embedded before saving to prevent crash during LoRA extraction#1343

Merged
mcmonkey4eva merged 1 commit intomcmonkeyprojects:masterfrom
GlenCarpenter:klein-lora
Apr 13, 2026
Merged

add check to ensure CLIP is embedded before saving to prevent crash during LoRA extraction#1343
mcmonkey4eva merged 1 commit intomcmonkeyprojects:masterfrom
GlenCarpenter:klein-lora

Conversation

@GlenCarpenter
Copy link
Copy Markdown
Contributor

@GlenCarpenter GlenCarpenter commented Apr 12, 2026

#1330

This provides a safeguard in the Python code to ensure base_model_clip and other_model_clip are set before extracting the embedded CLIP.
Flux Checkpoints in the Stable-Diffusion directory are treated as regular checkpoints, and the check for doClip is based on the directory structure:

// in ComfyUIWebAPI.cs
bool doClip = !baseModelData.IsDiffusionModelsFormat && !otherModelData.IsDiffusionModelsFormat

...
...

// in T2IModel.cs
public bool IsDiffusionModelsFormat
    {
        get
        {
            string cleaned = OriginatingFolderPath.Replace('\\', '/').TrimEnd('/').ToLowerFast();
            return cleaned.EndsWithFast("/unet") || cleaned.EndsWithFast("/diffusion_models"); // Hacky but it works for now
        }
    }

It seems like a long term goal would be to check whether or not checkpoints in the Stable-Diffusion directory contain an embedded text encoder, and what that text encoder is (like CLIP or T5). As far as I know that is not reliably present in checkpoint metadata.

@mcmonkey4eva mcmonkey4eva merged commit e0c1da4 into mcmonkeyprojects:master Apr 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants