Buckets:
| import{s as De,o as Ee,n as qe}from"../chunks/scheduler.53228c21.js";import{S as Ke,i as Ne,e as c,s as a,c as f,h as ze,a as p,d as n,b as i,f as ee,g as _,j as M,k as G,l as d,m as s,n as h,t as x,o as b,p as y}from"../chunks/index.100fac89.js";import{C as Ve}from"../chunks/CopyLLMTxtMenu.133e28e0.js";import{D as fe}from"../chunks/Docstring.f8721f67.js";import{C as He}from"../chunks/CodeBlock.d30a6509.js";import{E as We}from"../chunks/ExampleCodeBlock.24511344.js";import{H as _e,E as Qe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d8195636.js";function Se(V){let l,F="Examples:",u,r,m;return r=new He({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmx1eDJQaXBlbGluZSUwQSUwQXBpcGUlMjAlM0QlMjBGbHV4MlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJibGFjay1mb3Jlc3QtbGFicyUyRkZMVVguMi1kZXYlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwY2F0JTIwaG9sZGluZyUyMGElMjBzaWduJTIwdGhhdCUyMHNheXMlMjBoZWxsbyUyMHdvcmxkJTIyJTBBJTIzJTIwRGVwZW5kaW5nJTIwb24lMjB0aGUlMjB2YXJpYW50JTIwYmVpbmclMjB1c2VkJTJDJTIwdGhlJTIwcGlwZWxpbmUlMjBjYWxsJTIwd2lsbCUyMHNsaWdodGx5JTIwdmFyeS4lMEElMjMlMjBSZWZlciUyMHRvJTIwdGhlJTIwcGlwZWxpbmUlMjBkb2N1bWVudGF0aW9uJTIwZm9yJTIwbW9yZSUyMGRldGFpbHMuJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q1MCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEMi41KS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJmbHV4LnBuZyUyMik=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Flux2Pipeline | |
| <span class="hljs-meta">>>> </span>pipe = Flux2Pipeline.from_pretrained(<span class="hljs-string">"black-forest-labs/FLUX.2-dev"</span>, torch_dtype=torch.bfloat16) | |
| <span class="hljs-meta">>>> </span>pipe.to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>prompt = <span class="hljs-string">"A cat holding a sign that says hello world"</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Depending on the variant being used, the pipeline call will slightly vary.</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Refer to the pipeline documentation for more details.</span> | |
| <span class="hljs-meta">>>> </span>image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>, guidance_scale=<span class="hljs-number">2.5</span>).images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>image.save(<span class="hljs-string">"flux.png"</span>)`,wrap:!1}}),{c(){l=c("p"),l.textContent=F,u=a(),f(r.$$.fragment)},l(o){l=p(o,"P",{"data-svelte-h":!0}),M(l)!=="svelte-kvfsh7"&&(l.textContent=F),u=i(o),_(r.$$.fragment,o)},m(o,g){s(o,l,g),s(o,u,g),h(r,o,g),m=!0},p:qe,i(o){m||(x(r.$$.fragment,o),m=!0)},o(o){b(r.$$.fragment,o),m=!1},d(o){o&&(n(l),n(u)),y(r,o)}}}function Ae(V){let l,F="Examples:",u,r,m;return r=new He({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmx1eDJLbGVpblBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMEZsdXgyS2xlaW5QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZGTFVYLjIta2xlaW4tYmFzZS05QiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpJTBBcGlwZS50byglMjJjdWRhJTIyKSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBjYXQlMjBob2xkaW5nJTIwYSUyMHNpZ24lMjB0aGF0JTIwc2F5cyUyMGhlbGxvJTIwd29ybGQlMjIlMEElMjMlMjBEZXBlbmRpbmclMjBvbiUyMHRoZSUyMHZhcmlhbnQlMjBiZWluZyUyMHVzZWQlMkMlMjB0aGUlMjBwaXBlbGluZSUyMGNhbGwlMjB3aWxsJTIwc2xpZ2h0bHklMjB2YXJ5LiUwQSUyMyUyMFJlZmVyJTIwdG8lMjB0aGUlMjBwaXBlbGluZSUyMGRvY3VtZW50YXRpb24lMjBmb3IlMjBtb3JlJTIwZGV0YWlscy4lMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q0LjApLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmZsdXgyX291dHB1dC5wbmclMjIp",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Flux2KleinPipeline | |
| <span class="hljs-meta">>>> </span>pipe = Flux2KleinPipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"black-forest-labs/FLUX.2-klein-base-9B"</span>, torch_dtype=torch.bfloat16 | |
| <span class="hljs-meta">... </span>) | |
| <span class="hljs-meta">>>> </span>pipe.to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>prompt = <span class="hljs-string">"A cat holding a sign that says hello world"</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Depending on the variant being used, the pipeline call will slightly vary.</span> | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Refer to the pipeline documentation for more details.</span> | |
| <span class="hljs-meta">>>> </span>image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>, guidance_scale=<span class="hljs-number">4.0</span>).images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>image.save(<span class="hljs-string">"flux2_output.png"</span>)`,wrap:!1}}),{c(){l=c("p"),l.textContent=F,u=a(),f(r.$$.fragment)},l(o){l=p(o,"P",{"data-svelte-h":!0}),M(l)!=="svelte-kvfsh7"&&(l.textContent=F),u=i(o),_(r.$$.fragment,o)},m(o,g){s(o,l,g),s(o,u,g),h(r,o,g),m=!0},p:qe,i(o){m||(x(r.$$.fragment,o),m=!0)},o(o){b(r.$$.fragment,o),m=!1},d(o){o&&(n(l),n(u)),y(r,o)}}}function Xe(V){let l,F,u,r,m,o,g,ne,I,Pe='<img alt="LoRA" src="https://img.shields.io/badge/LoRA-d8b4fe?style=flat"/> <img alt="MPS" src="https://img.shields.io/badge/MPS-000000?style=flat&logo=apple&logoColor=white%22"/>',oe,U,ke='Flux.2 is the recent series of image generation models from Black Forest Labs, preceded by the <a href="./flux">Flux.1</a> series. It is an entirely new model with a new architecture and pre-training done from scratch!',se,B,Ie='Original model checkpoints for Flux can be found <a href="https://huggingface.co/black-forest-labs" rel="nofollow">here</a>. Original inference code can be found <a href="https://github.com/black-forest-labs/flux2" rel="nofollow">here</a>.',ae,j,je='<p>Flux2 can be quite expensive to run on consumer hardware devices. However, you can perform a suite of optimizations to run it faster and in a more memory-friendly manner. Check out <a href="https://huggingface.co/blog/sd3#memory-optimizations-for-sd3" rel="nofollow">this section</a> for more details. Additionally, Flux can benefit from quantization for memory efficiency with a trade-off in inference latency. Refer to <a href="https://huggingface.co/blog/quanto-diffusers" rel="nofollow">this blog post</a> to learn more.</p> <p><a href="../../optimization/cache">Caching</a> may also speed up inference by storing and reusing intermediate outputs.</p>',ie,Z,le,W,Ce=`Flux.2 can potentially generate better better outputs with better prompts. We can “upsample” | |
| an input prompt by setting the <code>caption_upsample_temperature</code> argument in the pipeline call arguments. | |
| The <a href="https://github.com/black-forest-labs/flux2/blob/5a5d316b1b42f6b59a8c9194b77c8256be848432/src/flux2/text_encoder.py#L140" rel="nofollow">official implementation</a> recommends this value to be 0.15.`,re,q,ce,w,H,he,Q,Le="The Flux2 pipeline for text-to-image generation.",xe,S,Je='Reference: <a href="https://bfl.ai/blog/flux-2" rel="nofollow">https://bfl.ai/blog/flux-2</a>',be,$,D,ye,A,Ge="Function invoked when calling the pipeline for generation.",we,C,pe,E,de,v,K,ve,X,Ue="The Flux2 Klein pipeline for text-to-image generation.",Me,Y,Be=`Reference: | |
| <a href="https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence" rel="nofollow">https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence</a>`,Te,P,N,Fe,O,Ze="Function invoked when calling the pipeline for generation.",$e,L,me,z,ue,te,ge;return m=new Ve({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),g=new _e({props:{title:"Flux2",local:"flux2",headingTag:"h1"}}),Z=new _e({props:{title:"Caption upsampling",local:"caption-upsampling",headingTag:"h2"}}),q=new _e({props:{title:"Flux2Pipeline",local:"diffusers.Flux2Pipeline",headingTag:"h2"}}),H=new fe({props:{name:"class diffusers.Flux2Pipeline",anchor:"diffusers.Flux2Pipeline",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLFlux2"},{name:"text_encoder",val:": Mistral3ForConditionalGeneration"},{name:"tokenizer",val:": AutoProcessor"},{name:"transformer",val:": Flux2Transformer2DModel"}],parametersDescription:[{anchor:"diffusers.Flux2Pipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_12249/en/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel">Flux2Transformer2DModel</a>) — | |
| Conditional Transformer (MMDiT) architecture to denoise the encoded image latents.`,name:"transformer"},{anchor:"diffusers.Flux2Pipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_12249/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) — | |
| A scheduler to be used in combination with <code>transformer</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.Flux2Pipeline.vae",description:`<strong>vae</strong> (<code>AutoencoderKLFlux2</code>) — | |
| Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.Flux2Pipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>Mistral3ForConditionalGeneration</code>) — | |
| <a href="https://huggingface.co/docs/transformers/en/model_doc/mistral3#transformers.Mistral3ForConditionalGeneration" rel="nofollow">Mistral3ForConditionalGeneration</a>`,name:"text_encoder"},{anchor:"diffusers.Flux2Pipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>AutoProcessor</code>) — | |
| Tokenizer of class | |
| <a href="https://huggingface.co/docs/transformers/en/model_doc/pixtral#transformers.PixtralProcessor" rel="nofollow">PixtralProcessor</a>.`,name:"tokenizer"}],source:"https://github.com/huggingface/diffusers/blob/vr_12249/src/diffusers/pipelines/flux2/pipeline_flux2.py#L251"}}),D=new fe({props:{name:"__call__",anchor:"diffusers.Flux2Pipeline.__call__",parameters:[{name:"image",val:": typing.Union[typing.List[PIL.Image.Image], PIL.Image.Image, NoneType] = None"},{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"sigmas",val:": typing.Optional[typing.List[float]] = None"},{name:"guidance_scale",val:": typing.Optional[float] = 4.0"},{name:"num_images_per_prompt",val:": int = 1"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"callback_on_step_end",val:": typing.Optional[typing.Callable[[int, int, typing.Dict], NoneType]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": typing.List[str] = ['latents']"},{name:"max_sequence_length",val:": int = 512"},{name:"text_encoder_out_layers",val:": typing.Tuple[int] = (10, 20, 30)"},{name:"caption_upsample_temperature",val:": float = None"}],parametersDescription:[{anchor:"diffusers.Flux2Pipeline.__call__.image",description:`<strong>image</strong> (<code>torch.Tensor</code>, <code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>List[torch.Tensor]</code>, <code>List[PIL.Image.Image]</code>, or <code>List[np.ndarray]</code>) — | |
| <code>Image</code>, numpy array or tensor representing an image batch to be used as the starting point. For both | |
| numpy array and pytorch tensor, the expected value range is between <code>[0, 1]</code> If it’s a tensor or a list | |
| or tensors, the expected shape should be <code>(B, C, H, W)</code> or <code>(C, H, W)</code>. If it is a numpy array or a | |
| list of arrays, the expected shape should be <code>(B, H, W, C)</code> or <code>(H, W, C)</code> It can also accept image | |
| latents as <code>image</code>, but if passing latents directly it is not encoded again.`,name:"image"},{anchor:"diffusers.Flux2Pipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>. | |
| instead.`,name:"prompt"},{anchor:"diffusers.Flux2Pipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) — | |
| Embedded guiddance scale is enabled by setting <code>guidance_scale</code> > 1. Higher <code>guidance_scale</code> encourages | |
| a model to generate images more aligned with <code>prompt</code> at the expense of lower image quality.</p> | |
| <p>Guidance-distilled models approximates true classifer-free guidance for <code>guidance_scale</code> > 1. Refer to | |
| the <a href="https://huggingface.co/papers/2210.03142" rel="nofollow">paper</a> to learn more.`,name:"guidance_scale"},{anchor:"diffusers.Flux2Pipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) — | |
| The height in pixels of the generated image. This is set to 1024 by default for the best results.`,name:"height"},{anchor:"diffusers.Flux2Pipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) — | |
| The width in pixels of the generated image. This is set to 1024 by default for the best results.`,name:"width"},{anchor:"diffusers.Flux2Pipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) — | |
| The number of denoising steps. More denoising steps usually lead to a higher quality image at the | |
| expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.Flux2Pipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>List[float]</code>, <em>optional</em>) — | |
| Custom sigmas to use for the denoising process with schedulers which support a <code>sigmas</code> argument in | |
| their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is passed | |
| will be used.`,name:"sigmas"},{anchor:"diffusers.Flux2Pipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) — | |
| The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.Flux2Pipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) — | |
| One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a> | |
| to make generation deterministic.`,name:"generator"},{anchor:"diffusers.Flux2Pipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image | |
| generation. Can be used to tweak the same generation with different prompts. If not provided, a latents | |
| tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.Flux2Pipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not | |
| provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.Flux2Pipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"pil"</code>) — | |
| The output format of the generate image. Choose between | |
| <a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.Flux2Pipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to return a <code>~pipelines.qwenimage.QwenImagePipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.Flux2Pipeline.__call__.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) — | |
| A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under | |
| <code>self.processor</code> in | |
| <a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"attention_kwargs"},{anchor:"diffusers.Flux2Pipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) — | |
| A function that calls at the end of each denoising steps during the inference. The function is called | |
| with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a list of all tensors as specified by | |
| <code>callback_on_step_end_tensor_inputs</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.Flux2Pipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List</code>, <em>optional</em>) — | |
| The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the list | |
| will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables listed in the | |
| <code>._callback_tensor_inputs</code> attribute of your pipeline class.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.Flux2Pipeline.__call__.max_sequence_length",description:"<strong>max_sequence_length</strong> (<code>int</code> defaults to 512) — Maximum sequence length to use with the <code>prompt</code>.",name:"max_sequence_length"},{anchor:"diffusers.Flux2Pipeline.__call__.text_encoder_out_layers",description:`<strong>text_encoder_out_layers</strong> (<code>Tuple[int]</code>) — | |
| Layer indices to use in the <code>text_encoder</code> to derive the final prompt embeddings.`,name:"text_encoder_out_layers"},{anchor:"diffusers.Flux2Pipeline.__call__.caption_upsample_temperature",description:`<strong>caption_upsample_temperature</strong> (<code>float</code>) — | |
| When specified, we will try to perform caption upsampling for potentially improved outputs. We | |
| recommend setting it to 0.15 if caption upsampling is to be performed.`,name:"caption_upsample_temperature"}],source:"https://github.com/huggingface/diffusers/blob/vr_12249/src/diffusers/pipelines/flux2/pipeline_flux2.py#L743",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~pipelines.flux2.Flux2PipelineOutput</code> if | |
| <code>return_dict</code> is True, otherwise a <code>tuple</code>. When returning a tuple, the first element is a list with the | |
| generated images.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~pipelines.flux2.Flux2PipelineOutput</code> or <code>tuple</code></p> | |
| `}}),C=new We({props:{anchor:"diffusers.Flux2Pipeline.__call__.example",$$slots:{default:[Se]},$$scope:{ctx:V}}}),E=new _e({props:{title:"Flux2KleinPipeline",local:"diffusers.Flux2KleinPipeline",headingTag:"h2"}}),K=new fe({props:{name:"class diffusers.Flux2KleinPipeline",anchor:"diffusers.Flux2KleinPipeline",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLFlux2"},{name:"text_encoder",val:": Qwen3ForCausalLM"},{name:"tokenizer",val:": Qwen2TokenizerFast"},{name:"transformer",val:": Flux2Transformer2DModel"},{name:"is_distilled",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.Flux2KleinPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_12249/en/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel">Flux2Transformer2DModel</a>) — | |
| Conditional Transformer (MMDiT) architecture to denoise the encoded image latents.`,name:"transformer"},{anchor:"diffusers.Flux2KleinPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_12249/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) — | |
| A scheduler to be used in combination with <code>transformer</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.Flux2KleinPipeline.vae",description:`<strong>vae</strong> (<code>AutoencoderKLFlux2</code>) — | |
| Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.Flux2KleinPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>Qwen3ForCausalLM</code>) — | |
| <a href="https://huggingface.co/docs/transformers/en/model_doc/qwen3#transformers.Qwen3ForCausalLM" rel="nofollow">Qwen3ForCausalLM</a>`,name:"text_encoder"},{anchor:"diffusers.Flux2KleinPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>Qwen2TokenizerFast</code>) — | |
| Tokenizer of class | |
| <a href="https://huggingface.co/docs/transformers/en/model_doc/qwen2#transformers.Qwen2TokenizerFast" rel="nofollow">Qwen2TokenizerFast</a>.`,name:"tokenizer"}],source:"https://github.com/huggingface/diffusers/blob/vr_12249/src/diffusers/pipelines/flux2/pipeline_flux2_klein.py#L155"}}),N=new fe({props:{name:"__call__",anchor:"diffusers.Flux2KleinPipeline.__call__",parameters:[{name:"image",val:": typing.Union[typing.List[PIL.Image.Image], PIL.Image.Image, NoneType] = None"},{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"sigmas",val:": typing.Optional[typing.List[float]] = None"},{name:"guidance_scale",val:": typing.Optional[float] = 4.0"},{name:"num_images_per_prompt",val:": int = 1"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"callback_on_step_end",val:": typing.Optional[typing.Callable[[int, int, typing.Dict], NoneType]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": typing.List[str] = ['latents']"},{name:"max_sequence_length",val:": int = 512"},{name:"text_encoder_out_layers",val:": typing.Tuple[int] = (9, 18, 27)"}],parametersDescription:[{anchor:"diffusers.Flux2KleinPipeline.__call__.image",description:`<strong>image</strong> (<code>torch.Tensor</code>, <code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>List[torch.Tensor]</code>, <code>List[PIL.Image.Image]</code>, or <code>List[np.ndarray]</code>) — | |
| <code>Image</code>, numpy array or tensor representing an image batch to be used as the starting point. For both | |
| numpy array and pytorch tensor, the expected value range is between <code>[0, 1]</code> If it’s a tensor or a list | |
| or tensors, the expected shape should be <code>(B, C, H, W)</code> or <code>(C, H, W)</code>. If it is a numpy array or a | |
| list of arrays, the expected shape should be <code>(B, H, W, C)</code> or <code>(H, W, C)</code> It can also accept image | |
| latents as <code>image</code>, but if passing latents directly it is not encoded again.`,name:"image"},{anchor:"diffusers.Flux2KleinPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>. | |
| instead.`,name:"prompt"},{anchor:"diffusers.Flux2KleinPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) — | |
| Guidance scale as defined in <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-Free Diffusion | |
| Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of equation 2. | |
| of <a href="https://huggingface.co/papers/2205.11487" rel="nofollow">Imagen Paper</a>. Guidance scale is enabled by setting | |
| <code>guidance_scale > 1</code>. Higher guidance scale encourages to generate images that are closely linked to | |
| the text <code>prompt</code>, usually at the expense of lower image quality. For step-wise distilled models, | |
| <code>guidance_scale</code> is ignored.`,name:"guidance_scale"},{anchor:"diffusers.Flux2KleinPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) — | |
| The height in pixels of the generated image. This is set to 1024 by default for the best results.`,name:"height"},{anchor:"diffusers.Flux2KleinPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) — | |
| The width in pixels of the generated image. This is set to 1024 by default for the best results.`,name:"width"},{anchor:"diffusers.Flux2KleinPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) — | |
| The number of denoising steps. More denoising steps usually lead to a higher quality image at the | |
| expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.Flux2KleinPipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>List[float]</code>, <em>optional</em>) — | |
| Custom sigmas to use for the denoising process with schedulers which support a <code>sigmas</code> argument in | |
| their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is passed | |
| will be used.`,name:"sigmas"},{anchor:"diffusers.Flux2KleinPipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) — | |
| The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.Flux2KleinPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) — | |
| One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a> | |
| to make generation deterministic.`,name:"generator"},{anchor:"diffusers.Flux2KleinPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image | |
| generation. Can be used to tweak the same generation with different prompts. If not provided, a latents | |
| tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.Flux2KleinPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not | |
| provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.Flux2KleinPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated negative text embeddings. Note that "" is used as the negative prompt in this pipeline. | |
| If not provided, will be generated from "".`,name:"negative_prompt_embeds"},{anchor:"diffusers.Flux2KleinPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"pil"</code>) — | |
| The output format of the generate image. Choose between | |
| <a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.Flux2KleinPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to return a <code>~pipelines.qwenimage.QwenImagePipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.Flux2KleinPipeline.__call__.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) — | |
| A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under | |
| <code>self.processor</code> in | |
| <a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"attention_kwargs"},{anchor:"diffusers.Flux2KleinPipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) — | |
| A function that calls at the end of each denoising steps during the inference. The function is called | |
| with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a list of all tensors as specified by | |
| <code>callback_on_step_end_tensor_inputs</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.Flux2KleinPipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List</code>, <em>optional</em>) — | |
| The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the list | |
| will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables listed in the | |
| <code>._callback_tensor_inputs</code> attribute of your pipeline class.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.Flux2KleinPipeline.__call__.max_sequence_length",description:"<strong>max_sequence_length</strong> (<code>int</code> defaults to 512) — Maximum sequence length to use with the <code>prompt</code>.",name:"max_sequence_length"},{anchor:"diffusers.Flux2KleinPipeline.__call__.text_encoder_out_layers",description:`<strong>text_encoder_out_layers</strong> (<code>Tuple[int]</code>) — | |
| Layer indices to use in the <code>text_encoder</code> to derive the final prompt embeddings.`,name:"text_encoder_out_layers"}],source:"https://github.com/huggingface/diffusers/blob/vr_12249/src/diffusers/pipelines/flux2/pipeline_flux2_klein.py#L607",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~pipelines.flux2.Flux2PipelineOutput</code> if | |
| <code>return_dict</code> is True, otherwise a <code>tuple</code>. When returning a tuple, the first element is a list with the | |
| generated images.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~pipelines.flux2.Flux2PipelineOutput</code> or <code>tuple</code></p> | |
| `}}),L=new We({props:{anchor:"diffusers.Flux2KleinPipeline.__call__.example",$$slots:{default:[Ae]},$$scope:{ctx:V}}}),z=new Qe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/flux2.md"}}),{c(){l=c("meta"),F=a(),u=c("p"),r=a(),f(m.$$.fragment),o=a(),f(g.$$.fragment),ne=a(),I=c("div"),I.innerHTML=Pe,oe=a(),U=c("p"),U.innerHTML=ke,se=a(),B=c("p"),B.innerHTML=Ie,ae=a(),j=c("blockquote"),j.innerHTML=je,ie=a(),f(Z.$$.fragment),le=a(),W=c("p"),W.innerHTML=Ce,re=a(),f(q.$$.fragment),ce=a(),w=c("div"),f(H.$$.fragment),he=a(),Q=c("p"),Q.textContent=Le,xe=a(),S=c("p"),S.innerHTML=Je,be=a(),$=c("div"),f(D.$$.fragment),ye=a(),A=c("p"),A.textContent=Ge,we=a(),f(C.$$.fragment),pe=a(),f(E.$$.fragment),de=a(),v=c("div"),f(K.$$.fragment),ve=a(),X=c("p"),X.textContent=Ue,Me=a(),Y=c("p"),Y.innerHTML=Be,Te=a(),P=c("div"),f(N.$$.fragment),Fe=a(),O=c("p"),O.textContent=Ze,$e=a(),f(L.$$.fragment),me=a(),f(z.$$.fragment),ue=a(),te=c("p"),this.h()},l(e){const t=ze("svelte-u9bgzb",document.head);l=p(t,"META",{name:!0,content:!0}),t.forEach(n),F=i(e),u=p(e,"P",{}),ee(u).forEach(n),r=i(e),_(m.$$.fragment,e),o=i(e),_(g.$$.fragment,e),ne=i(e),I=p(e,"DIV",{class:!0,"data-svelte-h":!0}),M(I)!=="svelte-1elo7hh"&&(I.innerHTML=Pe),oe=i(e),U=p(e,"P",{"data-svelte-h":!0}),M(U)!=="svelte-1togc7r"&&(U.innerHTML=ke),se=i(e),B=p(e,"P",{"data-svelte-h":!0}),M(B)!=="svelte-otikoq"&&(B.innerHTML=Ie),ae=i(e),j=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),M(j)!=="svelte-79zmu7"&&(j.innerHTML=je),ie=i(e),_(Z.$$.fragment,e),le=i(e),W=p(e,"P",{"data-svelte-h":!0}),M(W)!=="svelte-1r5tu3c"&&(W.innerHTML=Ce),re=i(e),_(q.$$.fragment,e),ce=i(e),w=p(e,"DIV",{class:!0});var T=ee(w);_(H.$$.fragment,T),he=i(T),Q=p(T,"P",{"data-svelte-h":!0}),M(Q)!=="svelte-1hjjsby"&&(Q.textContent=Le),xe=i(T),S=p(T,"P",{"data-svelte-h":!0}),M(S)!=="svelte-a2p6bq"&&(S.innerHTML=Je),be=i(T),$=p(T,"DIV",{class:!0});var k=ee($);_(D.$$.fragment,k),ye=i(k),A=p(k,"P",{"data-svelte-h":!0}),M(A)!=="svelte-v78lg8"&&(A.textContent=Ge),we=i(k),_(C.$$.fragment,k),k.forEach(n),T.forEach(n),pe=i(e),_(E.$$.fragment,e),de=i(e),v=p(e,"DIV",{class:!0});var J=ee(v);_(K.$$.fragment,J),ve=i(J),X=p(J,"P",{"data-svelte-h":!0}),M(X)!=="svelte-186p0nz"&&(X.textContent=Ue),Me=i(J),Y=p(J,"P",{"data-svelte-h":!0}),M(Y)!=="svelte-1m90spa"&&(Y.innerHTML=Be),Te=i(J),P=p(J,"DIV",{class:!0});var R=ee(P);_(N.$$.fragment,R),Fe=i(R),O=p(R,"P",{"data-svelte-h":!0}),M(O)!=="svelte-v78lg8"&&(O.textContent=Ze),$e=i(R),_(L.$$.fragment,R),R.forEach(n),J.forEach(n),me=i(e),_(z.$$.fragment,e),ue=i(e),te=p(e,"P",{}),ee(te).forEach(n),this.h()},h(){G(l,"name","hf:doc:metadata"),G(l,"content",Ye),G(I,"class","flex flex-wrap space-x-1"),G(j,"class","tip"),G($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){d(document.head,l),s(e,F,t),s(e,u,t),s(e,r,t),h(m,e,t),s(e,o,t),h(g,e,t),s(e,ne,t),s(e,I,t),s(e,oe,t),s(e,U,t),s(e,se,t),s(e,B,t),s(e,ae,t),s(e,j,t),s(e,ie,t),h(Z,e,t),s(e,le,t),s(e,W,t),s(e,re,t),h(q,e,t),s(e,ce,t),s(e,w,t),h(H,w,null),d(w,he),d(w,Q),d(w,xe),d(w,S),d(w,be),d(w,$),h(D,$,null),d($,ye),d($,A),d($,we),h(C,$,null),s(e,pe,t),h(E,e,t),s(e,de,t),s(e,v,t),h(K,v,null),d(v,ve),d(v,X),d(v,Me),d(v,Y),d(v,Te),d(v,P),h(N,P,null),d(P,Fe),d(P,O),d(P,$e),h(L,P,null),s(e,me,t),h(z,e,t),s(e,ue,t),s(e,te,t),ge=!0},p(e,[t]){const T={};t&2&&(T.$$scope={dirty:t,ctx:e}),C.$set(T);const k={};t&2&&(k.$$scope={dirty:t,ctx:e}),L.$set(k)},i(e){ge||(x(m.$$.fragment,e),x(g.$$.fragment,e),x(Z.$$.fragment,e),x(q.$$.fragment,e),x(H.$$.fragment,e),x(D.$$.fragment,e),x(C.$$.fragment,e),x(E.$$.fragment,e),x(K.$$.fragment,e),x(N.$$.fragment,e),x(L.$$.fragment,e),x(z.$$.fragment,e),ge=!0)},o(e){b(m.$$.fragment,e),b(g.$$.fragment,e),b(Z.$$.fragment,e),b(q.$$.fragment,e),b(H.$$.fragment,e),b(D.$$.fragment,e),b(C.$$.fragment,e),b(E.$$.fragment,e),b(K.$$.fragment,e),b(N.$$.fragment,e),b(L.$$.fragment,e),b(z.$$.fragment,e),ge=!1},d(e){e&&(n(F),n(u),n(r),n(o),n(ne),n(I),n(oe),n(U),n(se),n(B),n(ae),n(j),n(ie),n(le),n(W),n(re),n(ce),n(w),n(pe),n(de),n(v),n(me),n(ue),n(te)),n(l),y(m,e),y(g,e),y(Z,e),y(q,e),y(H),y(D),y(C),y(E,e),y(K),y(N),y(L),y(z,e)}}}const Ye='{"title":"Flux2","local":"flux2","sections":[{"title":"Caption upsampling","local":"caption-upsampling","sections":[],"depth":2},{"title":"Flux2Pipeline","local":"diffusers.Flux2Pipeline","sections":[],"depth":2},{"title":"Flux2KleinPipeline","local":"diffusers.Flux2KleinPipeline","sections":[],"depth":2}],"depth":1}';function Oe(V){return Ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class it extends Ke{constructor(l){super(),Ne(this,l,Oe,Xe,De,{})}}export{it as component}; | |
Xet Storage Details
- Size:
- 37.7 kB
- Xet hash:
- 871b6a1faa67ab96387b5d7951362266d785cf11f211d36ec98bb3213f74950d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.