CoolFace
Modelpublic

diffusers/flux2-modular

sourceHugging Faceupdated 10mo agoView on Hugging Face
1likes7downloads
README.md43 linesDownload Raw Back to root
1---2pipeline_tag: text-to-image3library_name: diffusers4---5## Setup6 7Install the latest version of `diffusers`8 9```shell10pip install git+https://github.com/huggingface/diffusers.git11```12 13Login to your Hugging Face account14 15```shell16hf auth login17```18 19## How to use20 21The following code snippet demonstrates how to use the [Flux2](https://huggingface.co/black-forest-labs/FLUX.2-dev) modular pipeline with a remote text encoder and group offloading. It requires approximately 8GB of VRAM and 64GB of CPU RAM to generate an image.22 23```python24import torch25from diffusers.modular_pipelines.flux2 import ALL_BLOCKS26from diffusers.modular_pipelines import SequentialPipelineBlocks27 28blocks = SequentialPipelineBlocks.from_blocks_dict(ALL_BLOCKS['remote'])29pipe = blocks.init_pipeline("diffusers/flux2-modular")30pipe.load_components(torch_dtype=torch.bfloat16, device_map="cpu")31pipe.vae.to("cuda")32pipe.transformer.enable_group_offload(33    offload_type="leaf_level",34    onload_device=torch.device("cuda"),35    offload_device=torch.device("cpu"),36    use_stream=True,37    low_cpu_mem_usage=True,38)39 40prompt = "a photo of a cat"41output = pipe(prompt=prompt, num_inference_steps=28, output="images")42output[0].save("flux2-modular.png")43```