-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(LoRA): support AI Toolkit LoRA for FLUX #8071
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
43e4b2e
to
0ca7a05
Compare
keturn
commented
Jun 1, 2025
invokeai/backend/patches/lora_conversions/flux_aitoolkit_lora_conversion_utils.py
Show resolved
Hide resolved
to avoid disrupting already-working LoRA
This could use more inputs to test with; I've only tested this on a couple files from a single author. If anyone has a LoRA collection you can use something like this script to find which ones might be applicable: #!/usr/bin/env python
# coding: utf-8
import os
from dataclasses import dataclass
from pathlib import Path
import safetensors
INVOKEAI_ROOT = Path(os.environ.get("INVOKEAI_ROOT", "/PATH/TO/InvokeAI"))
lora_dirname = INVOKEAI_ROOT / "models" / "flux" / "lora"
lora_filenames = list(lora_dirname.glob("*.safetensors"))
@dataclass
class LoraField:
name: str
ai_toolkit_metadata: bool = False
diffusion_model_key: bool = False
def inspect_lora(lora_path):
with safetensors.safe_open(lora_path, "torch") as f:
return LoraField(
name=lora_path.stem,
ai_toolkit_metadata="ai-toolkit" in (f.metadata() or {}).get("software", ""),
diffusion_model_key=any(k.startswith("diffusion_model.") for k in f.keys())
)
records = [inspect_lora(lora_filename) for lora_filename in lora_filenames]
matching = [r for r in records if r.ai_toolkit_metadata or r.diffusion_model_key]
print("name\tmetadata\tdiffusion_model_key")
for record in matching:
print(f"{record.name}\t{record.ai_toolkit_metadata}\t{record.diffusion_model_key}") |
@jazzhaiku please review. |
jazzhaiku
approved these changes
Jun 16, 2025
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
python-tests
PRs that change python tests
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
https://github.com/ostris/ai-toolkit is "an all in one training suite for diffusion models."
and I guess LoRA saved by it don't look exactly like the ones we support already.
Related Issues / Discussions
QA Instructions
Merge Plan
N/A
Checklist
What's New
copy (if doing a release after this PR)