Buckets:

download
raw
44.5 kB
import"../chunks/DsnmJJEf.js";import{i as K,h as O,H as l,a as s,D as t,E as $,s as ee}from"../chunks/BLbO27j4.js";import{p as le,o as se,s as e,f as oe,a as Y,b as te,c as a,d as V,n as o,r as n}from"../chunks/jDjavuwI.js";const ae='{"title":"FLUX.3","local":"flux3","sections":[{"title":"Prompt upsampling","local":"prompt-upsampling","sections":[],"depth":2},{"title":"Image-to-image","local":"image-to-image","sections":[],"depth":2},{"title":"Layout control","local":"layout-control","sections":[],"depth":2},{"title":"Guidance scale","local":"guidance-scale","sections":[],"depth":2},{"title":"Step-distilled model","local":"step-distilled-model","sections":[],"depth":2},{"title":"Reproducible generation","local":"reproducible-generation","sections":[],"depth":2},{"title":"Workflows","local":"workflows","sections":[],"depth":2},{"title":"Memory","local":"memory","sections":[],"depth":2},{"title":"Single-file loading","local":"single-file-loading","sections":[],"depth":2},{"title":"Flux3ModularPipeline","local":"diffusers.Flux3ModularPipeline","sections":[],"depth":2},{"title":"Flux3AutoBlocks","local":"diffusers.Flux3AutoBlocks","sections":[],"depth":2},{"title":"Flux3DistilledAutoBlocks","local":"diffusers.Flux3DistilledAutoBlocks","sections":[],"depth":2},{"title":"Flux3DistilledModularPipeline","local":"diffusers.Flux3DistilledModularPipeline","sections":[],"depth":2}],"depth":1}';var ne=V('<meta name="hf:doc:metadata"/>'),ie=V(`<p></p> <!> <p>FLUX.3 is an image generation model from Black Forest Labs: a single transformer (<a href="/docs/diffusers/pr_15046/en/api/models/flux3_transformer#diffusers.Flux3Transformer2DModel">Flux3Transformer2DModel</a>) generates images from a text prompt, alone or together with one or more reference images. Text conditioning comes from Qwen3-VL, and images use the FLUX.2 packed autoencoder (<code>AutoencoderKLFlux2</code>).</p> <p>FLUX.3 ships as a modular pipeline. Prompting matters: the model responds best to full scene captions that describe the subject, composition, lighting, and atmosphere. Black Forest Labs provides a <a href="https://huggingface.co/black-forest-labs/flux-3-image-klein-pup" rel="nofollow">prompt upsampler</a> that expands short prompts automatically; see <a href="#prompt-upsampling">Prompt upsampling</a>. Get started with a text-to-image generation:</p> <!> <p><code>prompt</code> is the only required input: the pipeline carries the recommended sampling settings (50 steps, guidance scale 3.5, scheduler shift 6.93) and generates 1024 x 1024 images by default. It takes one prompt per call; use <code>num_images_per_prompt</code> for several images of the same prompt.</p> <!> <p>The prompt upsampler, <a href="https://huggingface.co/black-forest-labs/flux-3-image-klein-pup" rel="nofollow">black-forest-labs/flux-3-image-klein-pup</a>, turns the user prompt, together with the reference images when editing, into a full scene caption. It is a separate model; run it with Transformers and pass its output as <code>prompt</code>:</p> <!> <p>For an edit, pass the same reference images to both: <code>pipe(prompt=upsample(instruction, [image]), image=image, ...)</code>. The upsampler also writes the <a href="#layout-control">layout</a> captions from a list of boxes; see its model card.</p> <!> <p>Pass one or more reference images with <code>image</code>. Every reference keeps its own resolution (center-cropped to the 16-pixel grid; references above 16 megapixels are downscaled first), and the generation size defaults to one megapixel at the first reference’s aspect ratio. Describe the <em>target</em> image as a complete caption of the reference with your edit folded in, rather than a one-line instruction, or let the <a href="#prompt-upsampling">prompt upsampler</a> write it from the instruction and the references:</p> <!> <p>With several references, refer to them in the prompt as <code>&lt;ref_image_0&gt;</code>, <code>&lt;ref_image_1&gt;</code>, … in the order they are passed to <code>image</code>:</p> <!> <p>Pass <code>height</code> and/or <code>width</code> to override the derived size.</p> <!> <p>To place content explicitly, tag regions in the caption with <code>&lt;id&gt;</code> and append a JSON list of regions to the prompt. Each region has an <code>id</code>, a <code>bbox</code> of <code>[y0, x0, y1, x1]</code> (top-left and bottom-right corners, origin top-left) normalized to 0-1000 on both axes so it is independent of the output size, and a <code>desc</code>:</p> <!> <p>When editing, each region names its source reference with <code>from</code> (for example <code>"ref_image_0"</code>), where it is in that image with <code>src_bbox</code>, and where it should end up with <code>tgt_bbox</code>. Equal boxes keep a region in place:</p> <!> <!> <p>The pipeline applies classifier-free guidance through its <code>guider</code> component and does not take a <code>guidance_scale</code> argument at call time. The default guider is <a href="/docs/diffusers/pr_15046/en/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance">ClassifierFreeGuidance</a> with <code>guidance_scale=3.5</code>, the recommended setting for both workflows. To change it, create an updated copy of the guider:</p> <!> <p>See the <a href="../../using-diffusers/guiders">guiders guide</a> to switch to a different guidance method.</p> <!> <p>The step-distilled checkpoint generates in 16 steps without classifier-free guidance. Its transformer is a flow map: at every step it is told the current timestep and the one the step jumps to. It loads like the base model (the repo’s <code>modular_model_index.json</code> resolves to <a href="/docs/diffusers/pr_15046/en/api/pipelines/flux3#diffusers.Flux3DistilledModularPipeline">Flux3DistilledModularPipeline</a> and <a href="/docs/diffusers/pr_15046/en/api/pipelines/flux3#diffusers.Flux3DistilledAutoBlocks">Flux3DistilledAutoBlocks</a>); the pipeline has no <code>guider</code> and does not take <code>negative_prompt</code>:</p> <!> <p>It serves the same two workflows as the base model. <code>num_inference_steps</code> defaults to 16; the model is trained for 4 to 16 steps.</p> <!> <p>A <code>generator</code> fixes the noise the pipeline draws (see <a href="../../using-diffusers/reusing_seeds">Reproducibility</a>). To reuse noise drawn elsewhere, pass it as <code>latents</code> with shape <code>(batch_size, 128, height // 16, width // 16)</code>. For example, the <a href="https://github.com/black-forest-labs/flux-3" rel="nofollow">BFL implementation</a> draws its noise as image tokens on the CPU and casts it to bf16; this reproduces its sample for a given seed:</p> <!> <!> <p>The pipeline serves two workflows, <code>text2image</code> and <code>image_conditioned</code>; the one that runs is picked by the inputs (<code>image</code> selects image-to-image). <a href="/docs/diffusers/pr_15046/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained">from_pretrained()</a> can also build a pipeline for one workflow with the <code>workflow</code> argument, which then only expects and loads the components that workflow needs:</p> <!> <!> <p>Loading everything in bf16 takes about 20 GB of weights (the transformer is 5.5B parameters, the Qwen3-VL-4B text encoder 4B), with the image VAE in fp32. For GPUs with less memory, enable component offloading:</p> <!> <!> <p><a href="/docs/diffusers/pr_15046/en/api/models/flux3_transformer#diffusers.Flux3Transformer2DModel">Flux3Transformer2DModel</a> loads the transformer straight from a Black Forest Labs model package with <a href="/docs/diffusers/pr_15046/en/api/loaders/single_file#diffusers.loaders.FromOriginalModelMixin.from_single_file">from_single_file()</a>. The package <code>config.json</code> is not read; pass the diffusers config with <code>config</code> and <code>subfolder</code>.</p> <!> <p>Load the other components by name first: <a href="/docs/diffusers/pr_15046/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components">load_components()</a> without <code>names</code> would also load the transformer from the pipeline repo.</p> <p>Loading the FP8r and NVFP4 single-file checkpoints are also supported. Both load through the same call with a <a href="/docs/diffusers/pr_15046/en/api/quantization#diffusers.BFLQuantizationConfig">BFLQuantizationConfig</a>. See the <a href="../../quantization/bfl">BFL quantization guide</a> for the kernel requirements of each scheme.</p> <!> <p>When loading the step-distilled checkpoints, we need their
configs (<code>flow_map=True</code>):</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A ModularPipeline for FLUX.3.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Auto blocks that perform text-to-image and image-to-image generation using FLUX.3.</p> <p>Supported workflows:</p> <ul><li><code>text2image</code>: requires <code>prompt</code></li> <li><code>image_conditioned</code>: requires <code>prompt</code>, <code>image</code></li></ul> <p>Components:
text_encoder (<code>Qwen3VLForConditionalGeneration</code>) tokenizer (<code>AutoProcessor</code>) image_processor
(<code>Flux3ImageProcessor</code>) vae (<code>AutoencoderKLFlux2</code>) transformer (<code>Flux3Transformer2DModel</code>) scheduler
(<code>FlowMatchEulerDiscreteScheduler</code>) guider (<code>ClassifierFreeGuidance</code>)</p> <p>Inputs:
prompt (<code>str</code>):
The prompt to guide the generation (one prompt per call)
negative_prompt (<code>str</code>, <em>optional</em>):
The prompt not to guide the generation
max_sequence_length (<code>int</code>, <em>optional</em>, defaults to 8192):
Maximum number of prompt tokens; longer prompts are truncated.
text_encoder_out_layers (<code>tuple</code>, <em>optional</em>, defaults to (4, 8, 12, 16, 20, 24, 28, 32)):
Indices of the text-encoder hidden layers whose states are stacked to form the text embeddings
image (<code>Image | list</code>, <em>optional</em>):
The reference image or images to condition the generation on; each keeps its own resolution
(center-cropped to the 16-pixel grid)
num_images_per_prompt (<code>int</code>, <em>optional</em>, defaults to 1):
The number of images to generate per prompt.
image_cond_latents (<code>list</code>, <em>optional</em>):
Normalized packed latents of the reference images, one tensor of shape (B, C, height_i//16, width_i//16)
per image
height (<code>int</code>, <em>optional</em>, defaults to None or 1024, depending on the workflow):
The height in pixels of the generated image; defaults to the first reference image’s aspect ratio at the
default area
width (<code>int</code>, <em>optional</em>, defaults to None or 1024, depending on the workflow):
The width in pixels of the generated image; defaults to the first reference image’s aspect ratio at the
default area
latents (<code>Tensor</code>):
Pre-generated noisy latents for image generation.
generator (<code>Generator</code>, <em>optional</em>):
Torch generator for deterministic generation.
num_inference_steps (<code>int</code>):
The number of denoising steps.
timesteps (<code>Tensor</code>):
Timesteps for the denoising process. (overrides <code>num_inference_steps</code> when provided)
sigmas (<code>list</code>, <em>optional</em>):
Custom sigmas for the denoising process. (overrides <code>num_inference_steps</code> when provided)
*<em>denoiser_input_fields (<code>None</code>,</em>optional<em>):
conditional model inputs for the denoiser: e.g. prompt_embeds, negative_prompt_embeds, etc.
attention_kwargs (<code>dict</code>,</em>optional<em>):
Additional kwargs for attention processors.
output_type (<code>str</code>,</em>optional*, defaults to pil):
Output format: ‘pil’, ‘np’, ‘pt’.</p> <p>Outputs:
images (<code>list</code>):
Generated images.
latents (<code>Tensor</code>):
Denoised latents.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Auto blocks that perform text-to-image and image-to-image generation using the step-distilled FLUX.3 model (16
steps, no classifier-free guidance).</p> <p>Supported workflows:</p> <ul><li><code>text2image</code>: requires <code>prompt</code></li> <li><code>image_conditioned</code>: requires <code>prompt</code>, <code>image</code></li></ul> <p>Components:
text_encoder (<code>Qwen3VLForConditionalGeneration</code>) tokenizer (<code>AutoProcessor</code>) image_processor
(<code>Flux3ImageProcessor</code>) vae (<code>AutoencoderKLFlux2</code>) transformer (<code>Flux3Transformer2DModel</code>) scheduler
(<code>FlowMatchEulerDiscreteScheduler</code>)</p> <p>Inputs:
prompt (<code>str</code>):
The prompt to guide the generation (one prompt per call)
max_sequence_length (<code>int</code>, <em>optional</em>, defaults to 8192):
Maximum number of prompt tokens; longer prompts are truncated.
text_encoder_out_layers (<code>tuple</code>, <em>optional</em>, defaults to (4, 8, 12, 16, 20, 24, 28, 32)):
Indices of the text-encoder hidden layers whose states are stacked to form the text embeddings
image (<code>Image | list</code>, <em>optional</em>):
The reference image or images to condition the generation on; each keeps its own resolution
(center-cropped to the 16-pixel grid)
num_images_per_prompt (<code>int</code>, <em>optional</em>, defaults to 1):
The number of images to generate per prompt.
image_cond_latents (<code>list</code>, <em>optional</em>):
Normalized packed latents of the reference images, one tensor of shape (B, C, height_i//16, width_i//16)
per image
height (<code>int</code>, <em>optional</em>, defaults to None or 1024, depending on the workflow):
The height in pixels of the generated image; defaults to the first reference image’s aspect ratio at the
default area
width (<code>int</code>, <em>optional</em>, defaults to None or 1024, depending on the workflow):
The width in pixels of the generated image; defaults to the first reference image’s aspect ratio at the
default area
latents (<code>Tensor</code>):
Pre-generated noisy latents for image generation.
generator (<code>Generator</code>, <em>optional</em>):
Torch generator for deterministic generation.
num_inference_steps (<code>int</code>):
The number of denoising steps.
timesteps (<code>Tensor</code>):
Timesteps for the denoising process. (overrides <code>num_inference_steps</code> when provided)
sigmas (<code>list</code>, <em>optional</em>):
Custom sigmas for the denoising process. (overrides <code>num_inference_steps</code> when provided)
*<em>denoiser_input_fields (<code>None</code>,</em>optional<em>):
conditional model inputs for the denoiser: e.g. prompt_embeds, negative_prompt_embeds, etc.
output_type (<code>str</code>,</em>optional*, defaults to pil):
Output format: ‘pil’, ‘np’, ‘pt’.</p> <p>Outputs:
images (<code>list</code>):
Generated images.
latents (<code>Tensor</code>):
Denoised latents.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A ModularPipeline for the step-distilled FLUX.3 model (16 steps, no classifier-free guidance).</p></div> <!> <p></p>`,1);function ce(E,z){le(z,!1),se(()=>{new URLSearchParams(window.location.search).get("fw")}),K();var c=ie();O("hchutw",X=>{var R=ne();ee(R,"content",ae),Y(X,R)});var M=e(oe(c),2);l(M,{title:"FLUX.3",local:"flux3",headingTag:"h1"});var m=e(M,6);s(m,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTW9kdWxhclBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyME1vZHVsYXJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4tYmFzZSUyMiklMEFwaXBlLmxvYWRfY29tcG9uZW50cyhkdHlwZSUzRCU3QiUyMnZhZSUyMiUzQSUyMHRvcmNoLmZsb2F0MzIlMkMlMjAlMjJkZWZhdWx0JTIyJTNBJTIwdG9yY2guYmZsb2F0MTYlN0QpJTBBcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlM0QoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyQSUyMHdpZGUtYW5nbGUlMjB3aWxkbGlmZSUyMHBob3RvZ3JhcGglMjBvZiUyMGElMjByZWQlMjBmb3glMjBzdGFuZGluZyUyMGFsZXJ0JTIwaW4lMjBhJTIwc25vdy1jb3ZlcmVkJTIwZm9yZXN0JTIwJTIyJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY2xlYXJpbmclMjBhdCUyMGdvbGRlbiUyMGhvdXIuJTIwVGhlJTIwZm94JTIwaXMlMjBjZW50ZXJlZCUyMGluJTIwdGhlJTIwZnJhbWUlMkMlMjBpdHMlMjB0aGljayUyMG9yYW5nZSUyMHdpbnRlciUyMGNvYXQlMjAlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJjb250cmFzdGluZyUyMHdpdGglMjB0aGUlMjBmcmVzaCUyMHdoaXRlJTIwc25vdyUyQyUyMGJyZWF0aCUyMHZpc2libGUlMjBpbiUyMHRoZSUyMGNvbGQlMjBhaXIuJTIwU25vdy1sYWRlbiUyMHBpbmUlMjAlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0cmVlcyUyMGZpbGwlMjB0aGUlMjBzb2Z0bHklMjBibHVycmVkJTIwYmFja2dyb3VuZCUyQyUyMGFuZCUyMGxvdyUyMHdhcm0lMjBzdW5saWdodCUyMHJha2VzJTIwYWNyb3NzJTIwdGhlJTIwc2NlbmUlMjAlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJmcm9tJTIwdGhlJTIwbGVmdCUyQyUyMGNhc3RpbmclMjBsb25nJTIwYmx1ZSUyMHNoYWRvd3MuJTIyJTBBJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvcigpLm1hbnVhbF9zZWVkKDApJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0JTNEJTIyaW1hZ2VzJTIyJTJDJTBBKSU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmZveC5wbmclMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ModularPipeline
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
pipe.load_components(dtype={<span class="hljs-string">&quot;vae&quot;</span>: torch.float32, <span class="hljs-string">&quot;default&quot;</span>: torch.bfloat16})
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
image = pipe(
prompt=(
<span class="hljs-string">&quot;A wide-angle wildlife photograph of a red fox standing alert in a snow-covered forest &quot;</span>
<span class="hljs-string">&quot;clearing at golden hour. The fox is centered in the frame, its thick orange winter coat &quot;</span>
<span class="hljs-string">&quot;contrasting with the fresh white snow, breath visible in the cold air. Snow-laden pine &quot;</span>
<span class="hljs-string">&quot;trees fill the softly blurred background, and low warm sunlight rakes across the scene &quot;</span>
<span class="hljs-string">&quot;from the left, casting long blue shadows.&quot;</span>
),
generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>),
output=<span class="hljs-string">&quot;images&quot;</span>,
)[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;fox.png&quot;</span>)`,lang:"python",wrap:!1});var u=e(m,4);l(u,{title:"Prompt upsampling",local:"prompt-upsampling",headingTag:"h2"});var h=e(u,4);s(h,{code:"aW1wb3J0JTIwanNvbiUwQSUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGhmX2h1Yl9kb3dubG9hZCUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvUHJvY2Vzc29yJTJDJTIwUXdlbjNfNUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUwQSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4tcHVwJTIyJTBBcHJvY2Vzc29yJTIwJTNEJTIwQXV0b1Byb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQpJTBBdXBzYW1wbGVyJTIwJTNEJTIwUXdlbjNfNUZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbi5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjBkdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpLmV2YWwoKSUwQXN5c3RlbV9wcm9tcHRzJTIwJTNEJTIwanNvbi5sb2FkKG9wZW4oaGZfaHViX2Rvd25sb2FkKG1vZGVsX2lkJTJDJTIwJTIyc3lzdGVtX3Byb21wdHMuanNvbiUyMikpKSUwQSUwQSUwQWRlZiUyMHVwc2FtcGxlKHByb21wdCUyQyUyMGltYWdlcyUzRCgpKSUzQSUwQSUyMCUyMCUyMCUyMGlmJTIwaW1hZ2VzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGV4dCUyMCUzRCUyMCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJSZWZlcmVuY2UlMjBpbWFnZXMlMjBmb2xsb3clMjBpbiUyMG9yZGVyJTIwKHRoZSUyMGZpcnN0JTIwaW1hZ2UlMkMlMjB0aGUlMjBzZWNvbmQlMjBpbWFnZSUyQyUyMC4uLikuJTVDbiUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGYlMjJVc2VyJTIwcmVxdWVzdCUzQSUyMCU3QnByb21wdCU3RCU1Q25PdXRwdXQlMjB0aGUlMjBjYXB0aW9uLiUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjb250ZW50JTIwJTNEJTIwJTVCJTdCJTIydHlwZSUyMiUzQSUyMCUyMmltYWdlJTIyJTJDJTIwJTIyaW1hZ2UlMjIlM0ElMjBpbWFnZSU3RCUyMGZvciUyMGltYWdlJTIwaW4lMjBpbWFnZXMlNUQlMjAlMkIlMjAlNUIlN0IlMjJ0eXBlJTIyJTNBJTIwJTIydGV4dCUyMiUyQyUyMCUyMnRleHQlMjIlM0ElMjB0ZXh0JTdEJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWVzc2FnZXMlMjAlM0QlMjAlNUIlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMHN5c3RlbV9wcm9tcHRzJTVCJTIyaTJpJTIyJTVEJTdEJTJDJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwY29udGVudCU3RCU1RCUwQSUyMCUyMCUyMCUyMGVsc2UlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtZXNzYWdlcyUyMCUzRCUyMCU1QiU3QiUyMnJvbGUlMjIlM0ElMjAlMjJzeXN0ZW0lMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwc3lzdGVtX3Byb21wdHMlNUIlMjJ0MmklMjIlNUQlN0QlMkMlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjBwcm9tcHQlN0QlNUQlMEElMjAlMjAlMjAlMjBpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IuYXBwbHlfY2hhdF90ZW1wbGF0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtZXNzYWdlcyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFkZF9nZW5lcmF0aW9uX3Byb21wdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b2tlbml6ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZW5hYmxlX3RoaW5raW5nJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjApLnRvKHVwc2FtcGxlci5kZXZpY2UpJTBBJTIwJTIwJTIwJTIwd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG91dHB1dCUyMCUzRCUyMHVwc2FtcGxlci5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMzU4NCUyQyUyMGRvX3NhbXBsZSUzREZhbHNlKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHByb2Nlc3Nvci5kZWNvZGUob3V0cHV0JTVCMCUyQyUyMGlucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RC5zaGFwZSU1QjElNUQlMjAlM0ElNUQlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSkuc3RyaXAoKSUwQSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlM0R1cHNhbXBsZSglMjJBbiUyMGFzdHJvbmF1dCUyMHJpZGluZyUyMGElMjBob3JzZSUyMiklMkMlMjBvdXRwdXQlM0QlMjJpbWFnZXMlMjIpJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> hf_hub_download
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor, Qwen3_5ForConditionalGeneration
model_id = <span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-pup&quot;</span>
processor = AutoProcessor.from_pretrained(model_id)
upsampler = Qwen3_5ForConditionalGeneration.from_pretrained(model_id, dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;auto&quot;</span>).<span class="hljs-built_in">eval</span>()
system_prompts = json.load(<span class="hljs-built_in">open</span>(hf_hub_download(model_id, <span class="hljs-string">&quot;system_prompts.json&quot;</span>)))
<span class="hljs-keyword">def</span> <span class="hljs-title function_">upsample</span>(<span class="hljs-params">prompt, images=(<span class="hljs-params"></span>)</span>):
<span class="hljs-keyword">if</span> images:
text = (
<span class="hljs-string">&quot;Reference images follow in order (the first image, the second image, ...).\\n&quot;</span>
<span class="hljs-string">f&quot;User request: <span class="hljs-subst">{prompt}</span>\\nOutput the caption.&quot;</span>
)
content = [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;image&quot;</span>, <span class="hljs-string">&quot;image&quot;</span>: image} <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> images] + [{<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;text&quot;</span>: text}]
messages = [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: system_prompts[<span class="hljs-string">&quot;i2i&quot;</span>]}, {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: content}]
<span class="hljs-keyword">else</span>:
messages = [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: system_prompts[<span class="hljs-string">&quot;t2i&quot;</span>]}, {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: prompt}]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=<span class="hljs-literal">True</span>,
tokenize=<span class="hljs-literal">True</span>,
return_dict=<span class="hljs-literal">True</span>,
return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
enable_thinking=<span class="hljs-literal">False</span>,
).to(upsampler.device)
<span class="hljs-keyword">with</span> torch.no_grad():
output = upsampler.generate(**inputs, max_new_tokens=<span class="hljs-number">3584</span>, do_sample=<span class="hljs-literal">False</span>)
<span class="hljs-keyword">return</span> processor.decode(output[<span class="hljs-number">0</span>, inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape[<span class="hljs-number">1</span>] :], skip_special_tokens=<span class="hljs-literal">True</span>).strip()
image = pipe(prompt=upsample(<span class="hljs-string">&quot;An astronaut riding a horse&quot;</span>), output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1});var y=e(h,4);l(y,{title:"Image-to-image",local:"image-to-image",headingTag:"h2"});var J=e(y,4);s(J,{code:"bmlnaHQlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJUaGUlMjBzYW1lJTIwcmVkJTIwZm94JTIwaW4lMjB0aGUlMjBzYW1lJTIwc25vdy1jb3ZlcmVkJTIwZm9yZXN0JTIwY2xlYXJpbmclMkMlMjBub3clMjBhdCUyMG5pZ2h0JTIwdW5kZXIlMjBhJTIwZnVsbCUyMG1vb24lM0ElMjAlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJjb29sJTIwYmx1ZSUyMG1vb25saWdodCUyQyUyMGRlZXAlMjBzaGFkb3dzJTJDJTIwc3RhcnMlMjB2aXNpYmxlJTIwdGhyb3VnaCUyMHRoZSUyMHBpbmUlMjBicmFuY2hlcyUyQyUyMHRoZSUyMGZveCdzJTIwZXllcyUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmNhdGNoaW5nJTIwdGhlJTIwbGlnaHQuJTIyJTBBJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMGltYWdlJTNEaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0R0b3JjaC5HZW5lcmF0b3IoKS5tYW51YWxfc2VlZCgwKSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dCUzRCUyMmltYWdlcyUyMiUyQyUwQSklNUIwJTVE",highlighted:`night = pipe(
prompt=(
<span class="hljs-string">&quot;The same red fox in the same snow-covered forest clearing, now at night under a full moon: &quot;</span>
<span class="hljs-string">&quot;cool blue moonlight, deep shadows, stars visible through the pine branches, the fox&#x27;s eyes &quot;</span>
<span class="hljs-string">&quot;catching the light.&quot;</span>
),
image=image,
generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>),
output=<span class="hljs-string">&quot;images&quot;</span>,
)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1});var g=e(J,4);s(g,{code:"Y29tYmluZWQlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCUyMlRoZSUyMGZveCUyMGZyb20lMjAlM0NyZWZfaW1hZ2VfMCUzRSUyMHNpdHRpbmclMjBvbiUyMHRoZSUyMHdvb2RlbiUyMGJlbmNoJTIwZnJvbSUyMCUzQ3JlZl9pbWFnZV8xJTNFJTJDJTIwaW4lMjB0aGUlMjBzYW1lJTIwc25vd3klMjBjbGVhcmluZy4lMjIlMkMlMEElMjAlMjAlMjAlMjBpbWFnZSUzRCU1QmltYWdlJTJDJTIwYmVuY2glNUQlMkMlMEElMjAlMjAlMjAlMjBoZWlnaHQlM0Q3NjglMkMlMEElMjAlMjAlMjAlMjB3aWR0aCUzRDEzNjAlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXQlM0QlMjJpbWFnZXMlMjIlMkMlMEEpJTVCMCU1RA==",highlighted:`combined = pipe(
prompt=<span class="hljs-string">&quot;The fox from &lt;ref_image_0&gt; sitting on the wooden bench from &lt;ref_image_1&gt;, in the same snowy clearing.&quot;</span>,
image=[image, bench],
height=<span class="hljs-number">768</span>,
width=<span class="hljs-number">1360</span>,
output=<span class="hljs-string">&quot;images&quot;</span>,
)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1});var U=e(g,4);l(U,{title:"Layout control",local:"layout-control",headingTag:"h2"});var T=e(U,4);s(T,{code:"cHJvbXB0JTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMk1pbmltYWxpc3QlMjBncmFwaGljJTIwaWxsdXN0cmF0aW9uJTIwZmVhdHVyaW5nJTIwYSUyMGJsYWNrJTIwc2lsaG91ZXR0ZSUyMG9mJTIwYSUyMHBlcnNvbiUyMCUzQ3NpbGhvdWV0dGVfMSUzRSUyMGNlbnRlcmVkJTIwYWdhaW5zdCUyMGElMjAlMjIlMEElMjAlMjAlMjAlMjAlMjJzb2xpZCUyQyUyMHZpYnJhbnQlMjBjaGFydHJldXNlJTIwYmFja2dyb3VuZCUyMCUzQ2JhY2tncm91bmRfMSUzRS4lMjAlMjIlMEElMjAlMjAlMjAlMjAnJTVCJTdCJTIyaWQlMjIlM0ElMjAlMjJiYWNrZ3JvdW5kXzElMjIlMkMlMjAlMjJiYm94JTIyJTNBJTIwJTVCMCUyQyUyMDAlMkMlMjAxMDAwJTJDJTIwMTAwMCU1RCUyQyUyMCUyMmRlc2MlMjIlM0ElMjAlMjJBJTIwZmxhdCUyMGZpZWxkJTIwb2YlMjBuZW9uJTIweWVsbG93LWdyZWVuLiUyMiU3RCUyQyUyMCclMEElMjAlMjAlMjAlMjAnJTdCJTIyaWQlMjIlM0ElMjAlMjJzaWxob3VldHRlXzElMjIlMkMlMjAlMjJiYm94JTIyJTNBJTIwJTVCMTUwJTJDJTIwMTUwJTJDJTIwODUwJTJDJTIwODUwJTVEJTJDJTIwJTIyZGVzYyUyMiUzQSUyMCUyMkElMjBibGFjayUyMHNpbGhvdWV0dGUlMjBvZiUyMGElMjBwZXJzb24lMjBpbiUyMG1vdGlvbi4lMjIlN0QlNUQnJTBBKQ==",highlighted:`prompt = (
<span class="hljs-string">&quot;Minimalist graphic illustration featuring a black silhouette of a person &lt;silhouette_1&gt; centered against a &quot;</span>
<span class="hljs-string">&quot;solid, vibrant chartreuse background &lt;background_1&gt;. &quot;</span>
<span class="hljs-string">&#x27;[{&quot;id&quot;: &quot;background_1&quot;, &quot;bbox&quot;: [0, 0, 1000, 1000], &quot;desc&quot;: &quot;A flat field of neon yellow-green.&quot;}, &#x27;</span>
<span class="hljs-string">&#x27;{&quot;id&quot;: &quot;silhouette_1&quot;, &quot;bbox&quot;: [150, 150, 850, 850], &quot;desc&quot;: &quot;A black silhouette of a person in motion.&quot;}]&#x27;</span>
)`,lang:"python",wrap:!1});var j=e(T,4);s(j,{code:"cHJvbXB0JTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMkluJTIwJTNDcmVmX2ltYWdlXzAlM0UlMkMlMjBtb3ZlJTIwdGhlJTIwa25pZ2h0JTIwZmlndXJlJTIwJTNDa25pZ2h0XzElM0UlMjB1cHdhcmRzJTIwYW5kJTIwdG8lMjB0aGUlMjBsZWZ0LiUyMEtlZXAlMjB0aGUlMjByZXN0JTIwb2YlMjB0aGUlMjBpbWFnZSUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMnVuY2hhbmdlZCUyQyUyMHByZXNlcnZpbmclMjB0aGUlMjBiYWNrZHJvcCUyMCUzQ2JhY2tkcm9wXzElM0UuJTIwJTIyJTBBJTIwJTIwJTIwJTIwJyU1QiU3QiUyMmlkJTIyJTNBJTIwJTIya25pZ2h0XzElMjIlMkMlMjAlMjJmcm9tJTIyJTNBJTIwJTIycmVmX2ltYWdlXzAlMjIlMkMlMjAlMjJzcmNfYmJveCUyMiUzQSUyMCU1QjUwMCUyQyUyMDE1MCUyQyUyMDg1MCUyQyUyMDM1MCU1RCUyQyUyMCUyMnRndF9iYm94JTIyJTNBJTIwJTVCMTk0JTJDJTIwNTUlMkMlMjA1NDQlMkMlMjAyNTUlNUQlMkMlMjAnJTBBJTIwJTIwJTIwJTIwJyUyMmRlc2MlMjIlM0ElMjAlMjJBJTIwbWluaWF0dXJlJTIwYW1pZ3VydW1pJTIwa25pZ2h0JTIwY3JvY2hldGVkJTIwZnJvbSUyMGdyZXklMjB5YXJuLiUyMiU3RCUyQyUyMCclMEElMjAlMjAlMjAlMjAnJTdCJTIyaWQlMjIlM0ElMjAlMjJiYWNrZHJvcF8xJTIyJTJDJTIwJTIyZnJvbSUyMiUzQSUyMCUyMnJlZl9pbWFnZV8wJTIyJTJDJTIwJTIyc3JjX2Jib3glMjIlM0ElMjAlNUIwJTJDJTIwMCUyQyUyMDEwMDAlMkMlMjAxMDAwJTVEJTJDJTIwJTIydGd0X2Jib3glMjIlM0ElMjAlNUIwJTJDJTIwMCUyQyUyMDEwMDAlMkMlMjAxMDAwJTVEJTJDJTIwJyUwQSUyMCUyMCUyMCUyMCclMjJkZXNjJTIyJTNBJTIwJTIyQSUyMHNvZnQlMkMlMjBvdXQtb2YtZm9jdXMlMjBiYWNrZHJvcCUyMG9mJTIwa25pdHRlZCUyMHlhcm4uJTIyJTdEJTVEJyUwQSklMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0RrbmlnaHQlMkMlMjBvdXRwdXQlM0QlMjJpbWFnZXMlMjIpJTVCMCU1RA==",highlighted:`prompt = (
<span class="hljs-string">&quot;In &lt;ref_image_0&gt;, move the knight figure &lt;knight_1&gt; upwards and to the left. Keep the rest of the image &quot;</span>
<span class="hljs-string">&quot;unchanged, preserving the backdrop &lt;backdrop_1&gt;. &quot;</span>
<span class="hljs-string">&#x27;[{&quot;id&quot;: &quot;knight_1&quot;, &quot;from&quot;: &quot;ref_image_0&quot;, &quot;src_bbox&quot;: [500, 150, 850, 350], &quot;tgt_bbox&quot;: [194, 55, 544, 255], &#x27;</span>
<span class="hljs-string">&#x27;&quot;desc&quot;: &quot;A miniature amigurumi knight crocheted from grey yarn.&quot;}, &#x27;</span>
<span class="hljs-string">&#x27;{&quot;id&quot;: &quot;backdrop_1&quot;, &quot;from&quot;: &quot;ref_image_0&quot;, &quot;src_bbox&quot;: [0, 0, 1000, 1000], &quot;tgt_bbox&quot;: [0, 0, 1000, 1000], &#x27;</span>
<span class="hljs-string">&#x27;&quot;desc&quot;: &quot;A soft, out-of-focus backdrop of knitted yarn.&quot;}]&#x27;</span>
)
image = pipe(prompt=prompt, image=knight, output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1});var f=e(j,2);l(f,{title:"Guidance scale",local:"guidance-scale",headingTag:"h2"});var w=e(f,4);s(w,{code:"cGlwZS5ndWlkZXIlMjAlM0QlMjBwaXBlLmd1aWRlci5uZXcoZ3VpZGFuY2Vfc2NhbGUlM0Q1LjAp",highlighted:'pipe.guider = pipe.guider.new(guidance_scale=<span class="hljs-number">5.0</span>)',lang:"python",wrap:!1});var b=e(w,4);l(b,{title:"Step-distilled model",local:"step-distilled-model",headingTag:"h2"});var I=e(b,4);s(I,{code:"cGlwZSUyMCUzRCUyME1vZHVsYXJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4lMjIpJTBBcGlwZS5sb2FkX2NvbXBvbmVudHMoZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiklMEFwaXBlLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKHByb21wdCUzRHByb21wdCUyQyUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvcigpLm1hbnVhbF9zZWVkKDApJTJDJTIwb3V0cHV0JTNEJTIyaW1hZ2VzJTIyKSU1QjAlNUQ=",highlighted:`pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein&quot;</span>)
pipe.load_components(dtype=torch.bfloat16)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
image = pipe(prompt=prompt, generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>), output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1});var Z=e(I,4);l(Z,{title:"Reproducible generation",local:"reproducible-generation",headingTag:"h2"});var k=e(Z,4);s(k,{code:"aGVpZ2h0JTJDJTIwd2lkdGglMjAlM0QlMjAxMDI0JTJDJTIwMTAyNCUwQWglMkMlMjB3JTIwJTNEJTIwaGVpZ2h0JTIwJTJGJTJGJTIwMTYlMkMlMjB3aWR0aCUyMCUyRiUyRiUyMDE2JTBBJTBBbm9pc2UlMjAlM0QlMjB0b3JjaC5yYW5kbigoaCUyMColMjB3JTJDJTIwMTI4KSUyQyUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvcigpLm1hbnVhbF9zZWVkKDApKS50byh0b3JjaC5iZmxvYXQxNiklMEFsYXRlbnRzJTIwJTNEJTIwbm9pc2UuVC5yZXNoYXBlKDElMkMlMjAxMjglMkMlMjBoJTJDJTIwdyklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwbGF0ZW50cyUzRGxhdGVudHMlMkMlMjBoZWlnaHQlM0RoZWlnaHQlMkMlMjB3aWR0aCUzRHdpZHRoJTJDJTIwb3V0cHV0JTNEJTIyaW1hZ2VzJTIyKSU1QjAlNUQ=",highlighted:`height, width = <span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>
h, w = height // <span class="hljs-number">16</span>, width // <span class="hljs-number">16</span>
noise = torch.randn((h * w, <span class="hljs-number">128</span>), generator=torch.Generator().manual_seed(<span class="hljs-number">0</span>)).to(torch.bfloat16)
latents = noise.T.reshape(<span class="hljs-number">1</span>, <span class="hljs-number">128</span>, h, w)
image = pipe(prompt=prompt, latents=latents, height=height, width=width, output=<span class="hljs-string">&quot;images&quot;</span>)[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1});var B=e(k,2);l(B,{title:"Workflows",local:"workflows",headingTag:"h2"});var C=e(B,4);s(C,{code:"ZnJvbSUyMGRpZmZ1c2Vycy5tb2R1bGFyX3BpcGVsaW5lcyUyMGltcG9ydCUyMEZsdXgzQXV0b0Jsb2NrcyUwQSUwQXByaW50KEZsdXgzQXV0b0Jsb2NrcygpLmF2YWlsYWJsZV93b3JrZmxvd3MpJTBBJTIzJTIwJTVCJTIydGV4dDJpbWFnZSUyMiUyQyUyMCUyMmltYWdlX2NvbmRpdGlvbmVkJTIyJTVEJTBBJTBBdDJpJTIwJTNEJTIwTW9kdWxhclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJibGFjay1mb3Jlc3QtbGFicyUyRmZsdXgtMy1pbWFnZS1rbGVpbi1iYXNlJTIyJTJDJTIwd29ya2Zsb3clM0QlMjJ0ZXh0MmltYWdlJTIyKSUwQXByaW50KHQyaS5ibG9ja3MuZG9jKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers.modular_pipelines <span class="hljs-keyword">import</span> Flux3AutoBlocks
<span class="hljs-built_in">print</span>(Flux3AutoBlocks().available_workflows)
<span class="hljs-comment"># [&quot;text2image&quot;, &quot;image_conditioned&quot;]</span>
t2i = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>, workflow=<span class="hljs-string">&quot;text2image&quot;</span>)
<span class="hljs-built_in">print</span>(t2i.blocks.doc)`,lang:"python",wrap:!1});var W=e(C,2);l(W,{title:"Memory",local:"memory",headingTag:"h2"});var _=e(W,4);s(_,{code:"cGlwZSUyMCUzRCUyME1vZHVsYXJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4tYmFzZSUyMiklMEFwaXBlLmxvYWRfY29tcG9uZW50cyhkdHlwZSUzRCU3QiUyMnZhZSUyMiUzQSUyMHRvcmNoLmZsb2F0MzIlMkMlMjAlMjJkZWZhdWx0JTIyJTNBJTIwdG9yY2guYmZsb2F0MTYlN0QpJTBBcGlwZS5lbmFibGVfYXV0b19jcHVfb2ZmbG9hZChkZXZpY2UlM0QlMjJjdWRhJTIyKQ==",highlighted:`pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
pipe.load_components(dtype={<span class="hljs-string">&quot;vae&quot;</span>: torch.float32, <span class="hljs-string">&quot;default&quot;</span>: torch.bfloat16})
pipe.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>)`,lang:"python",wrap:!1});var G=e(_,2);l(G,{title:"Single-file loading",local:"single-file-loading",headingTag:"h2"});var A=e(G,4);s(A,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmx1eDNUcmFuc2Zvcm1lcjJETW9kZWwlMkMlMjBNb2R1bGFyUGlwZWxpbmUlMEElMEF0cmFuc2Zvcm1lciUyMCUzRCUyMEZsdXgzVHJhbnNmb3JtZXIyRE1vZGVsLmZyb21fc2luZ2xlX2ZpbGUoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmJsYWNrLWZvcmVzdC1sYWJzJTJGZmx1eC0zLWltYWdlLWtsZWluLWJhc2UlMkZibG9iJTJGbWFpbiUyRm1vZGVsLnNhZmV0ZW5zb3JzJTIyJTJDJTBBJTIwJTIwJTIwJTIwY29uZmlnJTNEJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4tYmFzZSUyMiUyQyUwQSUyMCUyMCUyMCUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTBBJTIwJTIwJTIwJTIwZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSklMEElMEFwaXBlJTIwJTNEJTIwTW9kdWxhclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJibGFjay1mb3Jlc3QtbGFicyUyRmZsdXgtMy1pbWFnZS1rbGVpbi1iYXNlJTIyKSUwQXBpcGUubG9hZF9jb21wb25lbnRzKGR0eXBlJTNEJTdCJTIydmFlJTIyJTNBJTIwdG9yY2guZmxvYXQzMiUyQyUyMCUyMmRlZmF1bHQlMjIlM0ElMjB0b3JjaC5iZmxvYXQxNiU3RCklMEFwaXBlLnVwZGF0ZV9jb21wb25lbnRzKHRyYW5zZm9ybWVyJTNEdHJhbnNmb3JtZXIpJTBBcGlwZS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Flux3Transformer2DModel, ModularPipeline
transformer = Flux3Transformer2DModel.from_single_file(
<span class="hljs-string">&quot;https://huggingface.co/black-forest-labs/flux-3-image-klein-base/blob/main/model.safetensors&quot;</span>,
config=<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>,
subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
dtype=torch.bfloat16,
)
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>)
pipe.load_components(dtype={<span class="hljs-string">&quot;vae&quot;</span>: torch.float32, <span class="hljs-string">&quot;default&quot;</span>: torch.bfloat16})
pipe.update_components(transformer=transformer)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)`,lang:"python",wrap:!1});var v=e(A,6);s(v,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEJGTFF1YW50aXphdGlvbkNvbmZpZyUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwRmx1eDNUcmFuc2Zvcm1lcjJETW9kZWwuZnJvbV9zaW5nbGVfZmlsZSglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4tYmFzZSUyRmJsb2IlMkZtYWluJTJGdmFyaWFudHMlMkZudmZwNCUyRm1vZGVsLnNhZmV0ZW5zb3JzJTIyJTJDJTBBJTIwJTIwJTIwJTIwY29uZmlnJTNEJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4tYmFzZSUyMiUyQyUwQSUyMCUyMCUyMCUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTBBJTIwJTIwJTIwJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzREJGTFF1YW50aXphdGlvbkNvbmZpZyhjb21wdXRlX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYpJTJDJTBBJTIwJTIwJTIwJTIwZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> BFLQuantizationConfig
transformer = Flux3Transformer2DModel.from_single_file(
<span class="hljs-string">&quot;https://huggingface.co/black-forest-labs/flux-3-image-klein-base/blob/main/variants/nvfp4/model.safetensors&quot;</span>,
config=<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein-base&quot;</span>,
subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
quantization_config=BFLQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)`,lang:"python",wrap:!1});var x=e(v,4);s(x,{code:"dHJhbnNmb3JtZXIlMjAlM0QlMjBGbHV4M1RyYW5zZm9ybWVyMkRNb2RlbC5mcm9tX3NpbmdsZV9maWxlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZibGFjay1mb3Jlc3QtbGFicyUyRmZsdXgtMy1pbWFnZS1rbGVpbiUyRmJsb2IlMkZtYWluJTJGdmFyaWFudHMlMkZudmZwNCUyRm1vZGVsLnNhZmV0ZW5zb3JzJTIyJTJDJTBBJTIwJTIwJTIwJTIwY29uZmlnJTNEJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZmbHV4LTMtaW1hZ2Uta2xlaW4lMjIlMkMlMEElMjAlMjAlMjAlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUwQSUyMCUyMCUyMCUyMHF1YW50aXphdGlvbl9jb25maWclM0RCRkxRdWFudGl6YXRpb25Db25maWcoY29tcHV0ZV9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUyQyUwQSUyMCUyMCUyMCUyMGR0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMEEp",highlighted:`transformer = Flux3Transformer2DModel.from_single_file(
<span class="hljs-string">&quot;https://huggingface.co/black-forest-labs/flux-3-image-klein/blob/main/variants/nvfp4/model.safetensors&quot;</span>,
config=<span class="hljs-string">&quot;black-forest-labs/flux-3-image-klein&quot;</span>,
subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
quantization_config=BFLQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)`,lang:"python",wrap:!1});var N=e(x,2);l(N,{title:"Flux3ModularPipeline",local:"diffusers.Flux3ModularPipeline",headingTag:"h2"});var i=e(N,2),S=a(i);t(S,{name:"class diffusers.Flux3ModularPipeline",anchor:"diffusers.Flux3ModularPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_15046/src/diffusers/modular_pipelines/flux3/modular_pipeline.py#L24",parameters:[{name:"blocks",val:": diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None"},{name:"pretrained_model_name_or_path",val:": str | os.PathLike | None = None"},{name:"components_manager",val:": diffusers.modular_pipelines.components_manager.ComponentsManager | None = None"},{name:"collection",val:": str | None = None"},{name:"workflow",val:": str | None = None"},{name:"modular_config_dict",val:": dict[str, typing.Any] | None = None"},{name:"config_dict",val:": dict[str, typing.Any] | None = None"},{name:"**kwargs",val:""}]}),o(2),n(i);var Q=e(i,2);l(Q,{title:"Flux3AutoBlocks",local:"diffusers.Flux3AutoBlocks",headingTag:"h2"});var r=e(Q,2),H=a(r);t(H,{name:"class diffusers.Flux3AutoBlocks",anchor:"diffusers.Flux3AutoBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_15046/src/diffusers/modular_pipelines/flux3/modular_blocks_flux3.py#L329",parameters:[]}),o(12),n(r);var q=e(r,2);l(q,{title:"Flux3DistilledAutoBlocks",local:"diffusers.Flux3DistilledAutoBlocks",headingTag:"h2"});var d=e(q,2),D=a(d);t(D,{name:"class diffusers.Flux3DistilledAutoBlocks",anchor:"diffusers.Flux3DistilledAutoBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_15046/src/diffusers/modular_pipelines/flux3/modular_blocks_flux3_distilled.py#L256",parameters:[]}),o(12),n(d);var F=e(d,2);l(F,{title:"Flux3DistilledModularPipeline",local:"diffusers.Flux3DistilledModularPipeline",headingTag:"h2"});var p=e(F,2),L=a(p);t(L,{name:"class diffusers.Flux3DistilledModularPipeline",anchor:"diffusers.Flux3DistilledModularPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_15046/src/diffusers/modular_pipelines/flux3/modular_pipeline.py#L52",parameters:[{name:"blocks",val:": diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None"},{name:"pretrained_model_name_or_path",val:": str | os.PathLike | None = None"},{name:"components_manager",val:": diffusers.modular_pipelines.components_manager.ComponentsManager | None = None"},{name:"collection",val:": str | None = None"},{name:"workflow",val:": str | None = None"},{name:"modular_config_dict",val:": dict[str, typing.Any] | None = None"},{name:"config_dict",val:": dict[str, typing.Any] | None = None"},{name:"**kwargs",val:""}]}),o(2),n(p);var P=e(p,2);$(P,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/flux3.md"}),o(2),Y(E,c),te()}export{ce as component};

Xet Storage Details

Size:
44.5 kB
·
Xet hash:
c8df69153d0fbd76b261d5e7a8c228aca869297bde1db220a8b602704c8e8d30

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.