Ctrlora implementation : Easy solution to train a controlnet with < 1000 examples · Issue #9713 · huggingface/diffusers · GitHub
Skip to content

Ctrlora implementation : Easy solution to train a controlnet with < 1000 examples #9713

Open

Description

@mamad-sd

Model/Pipeline/Scheduler description

Authors of the paper trained a base controlnet (with a new architecture if I'm not mistaken) on 9 different conditions to allow finetuning on new conditions easily using a LoRA rank 128. This method allows finetuning a novel condition using less than 1000 examples with less than 24GB of VRAM in a few hours.
The potential is really high and for having trained a new unseen condition myself, I can confirm it works pretty well (even though my dataset has 5K examples but I did train it quickly using only a 3090 GPU).

The only problem is that the training and inference code seems to be done on the old stable diffusion code and it may be difficult to port it to diffusers.

Anyone interested in implementing the training and inference code in diffusers ? License is Apache-2.0 license

Open source status

  • The model implementation is available.
  • The model weights are available (Only relevant if addition is not a scheduler).

Provide useful links for the implementation

Ctrlora repo : https://github.com/xyfJASON/ctrlora
Ctrlora paper : https://arxiv.org/abs/2410.09400

Activity

  1. sayakpaul commented on Nov 1, 2024

    @sayakpaul
    Member

    I think this could just be about:

    1. Initialize ControlNetModel from the pretrained UNet with the from_unet() method.
    2. Call add_adapter() on the model with the respective LoRA params. For this ControlNetModel needs to also subclass from PeftLoaderMixin.
    3. Train the model.

    The pre-trained LoRAs are here:
    https://huggingface.co/xyfJASON/ctrlora/tree/main/ctrlora-loras/base-conditions

    So, for inference and support loading these,

    1. We convert the LoRA state dict into a form that can be loaded into a ControlNetModel just like we do for the UNet:
    2. Now, this ControlNetModel can be used with the pipeline we have for ControlNets.

    Would you maybe like to give this a try? Happy to guide.

    Cc: @asomoza

  2. github-actions commented on Nov 25, 2024

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

    Please note that issues that do not follow the contributing guidelines are likely to be ignored.

  3. jloveric commented on Feb 4, 2025

    @jloveric

    Is this being implemented as part of this PR? #10686

  4. lavinal712 commented on Feb 5, 2025

    @lavinal712
    Contributor

    Ctrlora has new modules that ControlNet cannot support.

  5. github-actions commented on Mar 2, 2025

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

    Please note that issues that do not follow the contributing guidelines are likely to be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions