Skip to content

Support for Flux Controls + Flex.2 #692

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

stduhpf
Copy link
Contributor

@stduhpf stduhpf commented May 26, 2025

cont #679

Models

Flux Controls:

https://huggingface.co/black-forest-labs/FLUX.1-Canny-dev
https://huggingface.co/black-forest-labs/FLUX.1-Depth-dev

Flux models with built-in controlnet-like conditionning suport (depth or canny depending on the model)

Flex.2 (preview)

https://huggingface.co/ostris/Flex.2-preview

Pruned and de-distilled opensource Flux model with support for inpainting and controlnet-like conditionning (line, pose and depth all supported by a single model).

Usage

To enable control image conditionning, use the --control-image argument (same as when using a control net). You can also use --control-strength to change how much effect the control image should have.

@stduhpf stduhpf force-pushed the concat-controls branch 2 times, most recently from d8eadb7 to 22ab6f0 Compare May 26, 2025 17:36
@stduhpf stduhpf marked this pull request as ready for review May 26, 2025 17:46
stduhpf added 5 commits May 27, 2025 00:16
cosxl: smol cleanup

CosXL: fix schedule choice

Rename EDMVDenoiser

Avoid inf for EDMVDenoiser + discrete schedule

make parametrization flags public

Fix CosXL with empty negative prompts

Instruct-p2p support

support 2 conditionings cfg

Do not re-encode the exact same image twice

pix2pix: fixes for 2-cfg

Fix pix2pix latent inputs + improve inpainting a bit + fix naming

prepare for other pix2pix-like models

Support sdxl ip2p

CoxXL edit: fix reference image embeddings

Support 2-cond cfg properly in cli

fix typo in help

Support masks for ip2p models
@stduhpf stduhpf force-pushed the concat-controls branch from 22ab6f0 to bb30633 Compare May 26, 2025 22:46
@idostyle
Copy link
Contributor

idostyle commented May 27, 2025

(To change the strength of the control, you can try playing around with the --img-cfg-scale, but this makes inference 3x slower, and without apg, it might produce poor results with the flux control models)

Might be specific to Flex.2-preview unfortunately:
Should be able to control the strength directly (for Flex.2-preview) by scaling the control latents as it is done in the custom pipeline: https://huggingface.co/ostris/Flex.2-preview/blob/main/pipeline.py#L262-L263

@stduhpf
Copy link
Contributor Author

stduhpf commented May 27, 2025

Might be specific to Flex.2-preview unfortunately: Should be able to control the strength directly (for Flex.2-preview) by scaling the control latents as it is done in the custom pipeline: https://huggingface.co/ostris/Flex.2-preview/blob/main/pipeline.py#L262-L263

The same trick seems to work well with flux canny too, even though in the diffusers implementation, there's no way to set control strength. Not sure how Flux depth will handle scaled latents though, I haven't tested it yet, but I don't think it will work.

Edit: it seems to work too.

@iwr-redmond
Copy link

Will this PR make it easier to support SDXL control LoRAs in the future?

https://huggingface.co/stabilityai/control-lora

@stduhpf
Copy link
Contributor Author

stduhpf commented May 28, 2025

Will this PR make it easier to support SDXL control LoRAs in the future?

https://huggingface.co/stabilityai/control-lora

Yes, some of the changes from this PR will help support the control LoRAs (both for SDXL and flux), but there's still quite a lot of work on the LoRA implementation side for these to function (need support for Lora bias, allowing mismatched dimensions between Lora and model weights... Plus the Loras are loaded late into the pipeline, after the control inputs are prepared)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants