Instructions to use black-forest-labs/FLUX.1-Kontext-dev with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use black-forest-labs/FLUX.1-Kontext-dev with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Diffusion Single File
How to use black-forest-labs/FLUX.1-Kontext-dev with Diffusion Single File:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Inference
- Notebooks
- Google Colab
- Kaggle
pipe.to("cuda") runs super slow, is it expected?
The pipe = FluxKontextPipeline.from_pretrained(..., torch_dtype=torch.bfloat16) takes a few minutes, while pipe.to("cuda") takes about half an hour (or even more). I'm running the code on an nvidia-h100-80g card.
Is this normal? Do we have some way to accelerate this procedure?
update: it seems only the first time of to("cuda") takes a lot of time. Run the code again and it only takes seconds. Though I'm not sure what the cause is
On my H100 card it doesn't take too much time. Could you share what diffusers version you're using? Also, since this issue seems to be related to the diffusers library, could you please close this discussion and open an issue to the Diffusers repository, instead?
On my H100 card it doesn't take too much time. Could you share what
diffusersversion you're using? Also, since this issue seems to be related to thediffuserslibrary, could you please close this discussion and open an issue to the Diffusers repository, instead?
the version is diffusers-0.35.0.dev0