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

Record the model_variant in t2i and clip_vision configs #5989

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

lstein
Copy link
Collaborator

@lstein lstein commented Mar 19, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Community Node Submission

Have you discussed this change with the InvokeAI team?

  • Yes
  • No

Have you updated all relevant documentation?

  • Yes
  • No

Description

Diffuser models downloaded from huggingface have repo variants, including the commonly-used fp16 variant. Both T2I and clip_vision models can have fp16 variants, but at some point during the model manager refactor the base for their pydantic config models was moved from DiffusersConfigBase to a simpler base. Hence fp16 models would not load. This PR corrects the problem.

It also adds defensive code to the diffusers loading method. If a repo variant is requested but not available, the loader will attempt to load the default version. This will have the effect of protecting against a family of potential edge cases in which the user has renamed a model, cloned a huggingface repo, overwritten a weights file, or is going back and forth between different versions of InvokeAI while using the same models directory.

Related Tickets & Documents

  • Related Issue #
  • Closes #

QA Instructions, Screenshots, Recordings

  1. Install a T2I model from huggingface. Example: TencentARC/t2i-adapter-lineart-sdxl-1.0
  2. Confirm the existence of models/sdxl/t2i_adapter/lineart-sdxl.0/diffusion_pytorch_model.fp16.safetensors
  3. Run a generation using this T2I adapter.

Merge Plan

Merge when approved.

Added/updated tests?

  • Yes
  • No : correct testing requires presence of a large model file

[optional] Are there any post deployment tasks we need to perform?

- Move base of t2i and clip_vision config models to DiffusersBase, which contains
  a field to record the model variant (e.g. "fp16")
- This restore the ability to load fp16 t2i and clip_vision models
- Also add defensive coding to load the vanilla model when the fp16 model
  has been replaced (or more likely, user's preferences changed since installation)
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files labels Mar 19, 2024
Copy link
Collaborator

@psychedelicious psychedelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I think that was my fault. Thanks for fixing

@lstein lstein enabled auto-merge (squash) March 19, 2024 20:06
@lstein lstein merged commit c87497f into main Mar 19, 2024
14 checks passed
@lstein lstein deleted the lstein/bugfix/record-variant-in-t2i-config branch March 19, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend PRs that change backend files python PRs that change python files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants