ComfyUI-FluxTrainer

ComfyUI-FluxTrainer
★ 1,122

训练LoRALyCORISComfyUI
在ComfyUI内执行LoRA训练并实验性支持LyCORIS,可直接使用相同模型与环境进行微调与设置对比。
💡 在ComfyUI中直接训练和调试LoRA/LyCORIS微调模型
🍴 102 Forks💻 Python🔄 2025-04-02
📦
网盘下载
复制链接后前往夸克网盘下载
https://pan.quark.cn/s/b45acaa3411d
📦 requirements.txt
accelerate>=0.33.0
numpy<=1.26.4
transformers>=4.44.0
diffusers>=0.25.0
ftfy>=6.1.1
opencv-python>=4.7.0.68
einops>=0.7.0
bitsandbytes>=0.43.3
prodigyopt>=1.0
lion-pytorch>=0.0.6
safetensors>=0.4.4
altair>=4.2.2
toml>=0.10.2
voluptuous>=0.13.1
huggingface-hub>=0.24.5
#
for
Image
utils
imagesize>=1.4.1
rich>=13.7.0
came_pytorch
matplotlib
#
for
T5XXL
tokenizer
(SD3/FLUX)
sentencepiece>=0.2.0
protobuf
Screenshot 2024-08-21 020207
📄 README

ComfyUI Flux Trainer

Wrapper for slightly modified kohya’s training scripts: https://github.com/kohya-ss/sd-scripts

Including code from: https://github.com/KohakuBlueleaf/Lycoris

And https://github.com/LoganBooker/prodigy-plus-schedule-free

DISCLAIMER:

I have very little previous experience in training anything, Flux is basically first model I’ve been inspired to learn. Previously I’ve only trained AnimateDiff Motion Loras, and built similar training nodes for it.

DO NOT ASK ME FOR TRAINING ADVICE

I can not emphasize this enough, this repository is not for raising questions related to the training itself, that would be better done to kohya’s repo. Even so keep in mind my implementation may have mistakes.

The default settings aren’t necessarily any good, they are just the last (out of many) I’ve tried and worked for my dataset.

THIS IS EXPERIMENTAL

Both these nodes and the underlaying implementation by kohya is work in progress and expected to change.

Installation

  • Clone this repo into custom_nodes folder.
  • Install dependencies: pip install -r requirements.txt
  • or if you use the portable install, run this in ComfyUI_windows_portable -folder:

    python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-FluxTrainer\requirements.txt

    In addition torch version 2.4.0 or higher is highly recommended.

    Example workflow for LoRA training can be found in the examples folder, it utilizes additional nodes from:

    https://github.com/kijai/ComfyUI-KJNodes

    And some (optional) debugging nodes from:

    https://github.com/rgthree/rgthree-comfy

    For LoRA training the models need to be the normal fp8 or fp16 versions, also make sure the VAE is the non-diffusers version:

    https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/ae.safetensors

    For full model training the fp16 version of the main model needs to be used.

    Why train in ComfyUI?

  • Familiar UI (obviously only if you are a Comfy user already)
  • You can use same models you use for inference
  • You can use same python environment, I faced no incompabilities
  • You can build workflows to compare settings etc.
  • Currently supports LoRA training, and untested full finetune with code from kohya’s scripts: https://github.com/kohya-ss/sd-scripts

    Experimental support for LyCORIS training has been added as well, using code from: https://github.com/KohakuBlueleaf/Lycoris