Skip to content

[feat] Add ostris / Flex.2-preview pipeline #11485

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 13 commits into
base: main
Choose a base branch
from

Conversation

victolee0
Copy link
Contributor

@victolee0 victolee0 commented May 3, 2025

What does this PR do?

Fixes #11394 (issue)

Before submitting

Who can review?

@yiyixuxu @asomoza

Example code

import torch
from diffusers import Flex2Pipeline
from diffusers.utils import load_image

name_or_path = "ostris/Flex.2-preview"

inpaint_image = load_image("https://ostris.com/wp-content/uploads/2025/04/dog.jpg")
inpaint_mask = load_image("https://ostris.com/wp-content/uploads/2025/04/dog_mask.jpg")
control_image = load_image("https://ostris.com/wp-content/uploads/2025/04/dog_depth.jpg")

dtype = torch.bfloat16

pipe = Flex2Pipeline.from_pretrained(
     name_or_path,
     torch_dtype=dtype
 ).to("cuda")

image = pipe(
     prompt="A white friendly robotic dog sitting on a bench",
     inpaint_image=inpaint_image,
     inpaint_mask=inpaint_mask,
     control_image=control_image,
     control_strength=0.5,
     control_stop=0.33,
     height=1024,
     width=1024,
     guidance_scale=3.5,
     num_inference_steps=50,
     generator=torch.Generator("cpu").manual_seed(42)
 ).images[0]
image.save(f"robot_dog.png")

Result:

robot_dog

Official Example:

image

@victolee0 victolee0 changed the title [WIP] Add ostris / Flex.2-preview pipeline [feat] Add ostris / Flex.2-preview pipeline May 3, 2025
@tin2tin
Copy link

tin2tin commented May 3, 2025

Very cool. Haven't tested it yet. Does it automatically detect the type of control image is input (ex. OpenPose, canny or depth)?

@victolee0
Copy link
Contributor Author

@tin2tin No, you must manually select the correct type that matches your specific input image.

@tin2tin
Copy link

tin2tin commented May 3, 2025

How/where do you set that? In the ex. It's depth, but it could have been ex. Canny as well?

@nitinmukesh
Copy link

nitinmukesh commented May 3, 2025

@tin2tin

It's very complex, took me 5 days. I just finished integrating, you can refer my repo for code tomorrow but it's custom pipeline based and you can replace with diffusers pipeline.

image


image

@nitinmukesh
Copy link

nitinmukesh commented May 3, 2025

How/where do you set that? In the ex. It's depth, but it could have been ex. Canny as well?

You don't have to specify that, it automatically determines it.
control_image can have Line, Pose, Depth.

@victolee0
Copy link
Contributor Author

Oh, I misunderstood the question. sry

@nitinmukesh
Copy link

@victolee0
Copy link
Contributor Author

cc @yiyixuxu @asomoza

@asomoza
Copy link
Member

asomoza commented May 6, 2025

Hi @victolee0 and thanks for your contribution, I really like what @jaretburkett and Flex wants to do but the current model is an Early access preview release which means that we should probably wait for the full release.

Also I see two more issues with this PR:

  • This pipeline is the custom pipeline that the author published with the model right? If it is, then the priority for adding this goes to the model author unless they don't want to.
  • Flex uses Flux as a base (with some modifications) and probably it's just going to be just this pipeline which I'm not sure that needs a whole directory and maybe it can go in the Flux one. Not sure about this and also we're going to have the same problem with chroma. What do you think @yiyixuxu?

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