InvokeAI
InvokeAI copied to clipboard
Allow embeddings and loras to have different names
Summary
Currently LoRA folders will only named if they're named precisely pytorch_lora_weights.bin or pytorch_lora_weights.safetensors, and embedding folders will only load if they're named "learned_embeds.bin". This PR is an attempt to support different lora/embedding types if they are installed as a folder. Even though we have this naming convention for the files in the folder, our backend supports many more types of models for embeddings, and loras seem to be rarely named "correctly" in Huggingface.
QA Instructions
Test this by copying one of your already existing embeddings into a folder under the same directory in your models. Ensure it's scanned correctly on startup and is usable forgeneration.
Merge Plan
Can be merged if approved by code owners. @lstein may know some reason why we had this naming requirement. If so, we can look for different ways to handle this.
I've totally lost track of all the model probing pathways at this point, but I see that learned_embeds and pytorch_lora_weights are still hard-coded in several places. Do those not conflict with this change?
I've totally lost track of all the model probing pathways at this point, but I see that
learned_embedsandpytorch_lora_weightsare still hard-coded in several places. Do those not conflict with this change?
Yeah this PR loads all Lora and embedding as checkpoint single file models. This bypasses all of the checks post install since they're tied to folder models.
If you install a model while passing in the model type, that also bypasses the strict naming requirements. Currently there's no way to do that in the UI but the import api call accepts it.
All said though, I'm not sure if there's unexpected consequences to treating a "diffuser lora/ti" as a single checkpoint model. I couldn't find examples of models requiring a config.json on huggingface
Indeed most of these are just single file checkpoints, but HuggingFace gives them the same file name. The enclosing folder name is used during probing to get a name for the model and to prevent path collisions.
@brandonrising Are you still working on this?
@brandonrising Are you still working on this?
Yeah it seemed like an issue that could only really come up from manual manipulation of the models directory, so it's fallen down my priority list. I think we can just safely close this PR unless you see value in it somewhere.
@brandonrising Are you still working on this?
Yeah it seemed like an issue that could only really come up from manual manipulation of the models directory, so it's fallen down my priority list. I think we can just safely close this PR unless you see value in it somewhere.
As in, models can't even be installed with different names without manual intervention currently. We probably want to find some way to support different filenames, but it seems like this isn't the right way