The following code snippet demonstrates how to use the
Flux2
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.
import torch
from diffusers.modular_pipelines.flux2 import ALL_BLOCKS
from diffusers.modular_pipelines import SequentialPipelineBlocks
blocks = SequentialPipelineBlocks.from_blocks_dict(ALL_BLOCKS['remote'])
pipe = blocks.init_pipeline("diffusers/flux2-modular")
pipe.load_components(torch_dtype=torch.bfloat16, device_map="cpu")
pipe.vae.to("cuda")
pipe.transformer.enable_group_offload(
offload_type="leaf_level",
onload_device=torch.device("cuda"),
offload_device=torch.device("cpu"),
use_stream=True,
low_cpu_mem_usage=True,
)
prompt = "a photo of a cat"
output = pipe(prompt=prompt, num_inference_steps=28, output="images")
output[0].save("flux2-modular.png")
Runs of diffusers flux2-modular on huggingface.co
0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs
More Information About flux2-modular huggingface.co Model
flux2-modular huggingface.co
flux2-modular huggingface.co is an AI model on huggingface.co that provides flux2-modular's model effect (), which can be used instantly with this diffusers flux2-modular model. huggingface.co supports a free trial of the flux2-modular model, and also provides paid use of the flux2-modular. Support call flux2-modular model through api, including Node.js, Python, http.
flux2-modular huggingface.co is an online trial and call api platform, which integrates flux2-modular's modeling effects, including api services, and provides a free online trial of flux2-modular, you can try flux2-modular online for free by clicking the link below.
diffusers flux2-modular online free url in huggingface.co:
flux2-modular is an open source model from GitHub that offers a free installation service, and any user can find flux2-modular on GitHub to install. At the same time, huggingface.co provides the effect of flux2-modular install, users can directly use flux2-modular installed effect in huggingface.co for debugging and trial. It also supports api for free installation.