Buckets:
| import"../chunks/DsnmJJEf.js";import{i as S,h as F,H as s,a as i,D as n,E as D,s as L}from"../chunks/BtE7mKSK.js";import{p as A,o as K,s as e,f as h,a as d,b as O,c as a,d as f,r as t,n as W}from"../chunks/jDjavuwI.js";import{E as N}from"../chunks/SrSJA0zO.js";const $='{"title":"HunyuanImage2.1","local":"hunyuanimage21","sections":[{"title":"HunyuanImage-2.1","local":"hunyuanimage-21","sections":[],"depth":2},{"title":"HunyuanImage-2.1-Distilled","local":"hunyuanimage-21-distilled","sections":[],"depth":2},{"title":"HunyuanImagePipeline","local":"diffusers.HunyuanImagePipeline","sections":[],"depth":2},{"title":"HunyuanImageRefinerPipeline","local":"diffusers.HunyuanImageRefinerPipeline","sections":[],"depth":2},{"title":"HunyuanImagePipelineOutput","local":"diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput","sections":[],"depth":2}],"depth":1}';var ee=f('<meta name="hf:doc:metadata"/>'),R=f("<p>Examples:</p> <!>",1),ne=f('<p></p> <!> <p>HunyuanImage-2.1 is a 17B text-to-image model that is capable of generating 2K (2048 x 2048) resolution images</p> <p>HunyuanImage-2.1 comes in the following variants:</p> <table><thead><tr><th align="center">model type</th><th align="center">model id</th></tr></thead><tbody><tr><td align="center">HunyuanImage-2.1</td><td align="center"><a href="https://huggingface.co/hunyuanvideo-community/HunyuanImage-2.1-Diffusers" rel="nofollow">hunyuanvideo-community/HunyuanImage-2.1-Diffusers</a></td></tr><tr><td align="center">HunyuanImage-2.1-Distilled</td><td align="center"><a href="https://huggingface.co/hunyuanvideo-community/HunyuanImage-2.1-Distilled-Diffusers" rel="nofollow">hunyuanvideo-community/HunyuanImage-2.1-Distilled-Diffusers</a></td></tr><tr><td align="center">HunyuanImage-2.1-Refiner</td><td align="center"><a href="https://huggingface.co/hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers" rel="nofollow">hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers</a></td></tr></tbody></table> <blockquote><p>[!TIP][Caching](../../optimization/cache) may also speed up inference by storing and reusing intermediate outputs.</p></blockquote> <!> <p>HunyuanImage-2.1 applies <a href="https://huggingface.co/papers/2410.02416" rel="nofollow">Adaptive Projected Guidance (APG)</a> combined with Classifier-Free Guidance (CFG) in the denoising loop. <code>HunyuanImagePipeline</code> has a <code>guider</code> component (read more about <a href="../../using-diffusers/guiders">Guider</a>) and does not take a <code>guidance_scale</code> parameter at runtime. To change guider-related parameters, e.g., <code>guidance_scale</code>, you can update the <code>guider</code> configuration instead.</p> <!> <p>You can inspect the <code>guider</code> object:</p> <!> <p>To update the guider with a different configuration, use the <code>new()</code> method. For example, to generate an image with <code>guidance_scale=5.0</code> while keeping all other default guidance parameters:</p> <!> <!> <p>use <code>distilled_guidance_scale</code> with the guidance-distilled checkpoint,</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>The HunyuanImage pipeline for text-to-image generation.</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>Function invoked when calling the pipeline for generation.</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"><!></div></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>The HunyuanImage pipeline for text-to-image generation.</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>Function invoked when calling the pipeline for generation.</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"><!></div></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>Output class for HunyuanImage pipelines.</p></div> <!> <p></p>',1);function ie(C,V){A(V,!1),K(()=>{new URLSearchParams(window.location.search).get("fw")}),S();var y=ne();F("16ehmo8",o=>{var l=ee();L(l,"content",$),d(o,l)});var b=e(h(y),2);s(b,{title:"HunyuanImage2.1",local:"hunyuanimage21",headingTag:"h1"});var w=e(b,10);s(w,{title:"HunyuanImage-2.1",local:"hunyuanimage-21",headingTag:"h2"});var M=e(w,4);i(M,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSHVueXVhbkltYWdlUGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwSHVueXVhbkltYWdlUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmh1bnl1YW52aWRlby1jb21tdW5pdHklMkZIdW55dWFuSW1hZ2UtMi4xLURpZmZ1c2VycyUyMiUyQyUyMCUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpJTBBcGlwZSUyMCUzRCUyMHBpcGUudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> HunyuanImagePipeline | |
| pipe = HunyuanImagePipeline.from_pretrained( | |
| <span class="hljs-string">"hunyuanvideo-community/HunyuanImage-2.1-Diffusers"</span>, | |
| torch_dtype=torch.bfloat16 | |
| ) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>)`,lang:"python",wrap:!1});var I=e(M,4);i(I,{code:"cGlwZS5ndWlkZXIlMEE=",highlighted:`<span class="hljs-meta">>>> </span>pipe.guider | |
| AdaptiveProjectedMixGuidance { | |
| <span class="hljs-string">"_class_name"</span>: <span class="hljs-string">"AdaptiveProjectedMixGuidance"</span>, | |
| <span class="hljs-string">"_diffusers_version"</span>: <span class="hljs-string">"0.36.0.dev0"</span>, | |
| <span class="hljs-string">"adaptive_projected_guidance_momentum"</span>: -<span class="hljs-number">0.5</span>, | |
| <span class="hljs-string">"adaptive_projected_guidance_rescale"</span>: <span class="hljs-number">10.0</span>, | |
| <span class="hljs-string">"adaptive_projected_guidance_scale"</span>: <span class="hljs-number">10.0</span>, | |
| <span class="hljs-string">"adaptive_projected_guidance_start_step"</span>: <span class="hljs-number">5</span>, | |
| <span class="hljs-string">"enabled"</span>: true, | |
| <span class="hljs-string">"eta"</span>: <span class="hljs-number">0.0</span>, | |
| <span class="hljs-string">"guidance_rescale"</span>: <span class="hljs-number">0.0</span>, | |
| <span class="hljs-string">"guidance_scale"</span>: <span class="hljs-number">3.5</span>, | |
| <span class="hljs-string">"start"</span>: <span class="hljs-number">0.0</span>, | |
| <span class="hljs-string">"stop"</span>: <span class="hljs-number">1.0</span>, | |
| <span class="hljs-string">"use_original_formulation"</span>: false | |
| } | |
| State: | |
| step: <span class="hljs-literal">None</span> | |
| num_inference_steps: <span class="hljs-literal">None</span> | |
| timestep: <span class="hljs-literal">None</span> | |
| count_prepared: <span class="hljs-number">0</span> | |
| enabled: <span class="hljs-literal">True</span> | |
| num_conditions: <span class="hljs-number">2</span> | |
| momentum_buffer: <span class="hljs-literal">None</span> | |
| is_apg_enabled: <span class="hljs-literal">False</span> | |
| is_cfg_enabled: <span class="hljs-literal">True</span>`,lang:"py",wrap:!1});var v=e(I,4);i(v,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSHVueXVhbkltYWdlUGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwSHVueXVhbkltYWdlUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmh1bnl1YW52aWRlby1jb21tdW5pdHklMkZIdW55dWFuSW1hZ2UtMi4xLURpZmZ1c2VycyUyMiUyQyUyMCUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpJTBBcGlwZSUyMCUzRCUyMHBpcGUudG8oJTIyY3VkYSUyMiklMEElMEElMjMlMjBVcGRhdGUlMjB0aGUlMjBndWlkZXIlMjBjb25maWd1cmF0aW9uJTBBcGlwZS5ndWlkZXIlMjAlM0QlMjBwaXBlLmd1aWRlci5uZXcoZ3VpZGFuY2Vfc2NhbGUlM0Q1LjApJTBBJTBBcHJvbXB0JTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMkElMjBjdXRlJTJDJTIwY2FydG9vbi1zdHlsZSUyMGFudGhyb3BvbW9ycGhpYyUyMHBlbmd1aW4lMjBwbHVzaCUyMHRveSUyMHdpdGglMjBmbHVmZnklMjBmdXIlMkMlMjBzdGFuZGluZyUyMGluJTIwYSUyMHBhaW50aW5nJTIwc3R1ZGlvJTJDJTIwJTIyJTBBJTIwJTIwJTIwJTIwJTIyd2VhcmluZyUyMGElMjByZWQlMjBrbml0dGVkJTIwc2NhcmYlMjBhbmQlMjBhJTIwcmVkJTIwYmVyZXQlMjB3aXRoJTIwdGhlJTIwd29yZCUyMCdUZW5jZW50JyUyMG9uJTIwaXQlMkMlMjBob2xkaW5nJTIwYSUyMHBhaW50YnJ1c2glMjB3aXRoJTIwYSUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMmZvY3VzZWQlMjBleHByZXNzaW9uJTIwYXMlMjBpdCUyMHBhaW50cyUyMGFuJTIwb2lsJTIwcGFpbnRpbmclMjBvZiUyMHRoZSUyME1vbmElMjBMaXNhJTJDJTIwcmVuZGVyZWQlMjBpbiUyMGElMjBwaG90b3JlYWxpc3RpYyUyMHBob3RvZ3JhcGhpYyUyMHN0eWxlLiUyMiUwQSklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTIwJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwJTJDJTIwJTBBJTIwJTIwJTIwJTIwaGVpZ2h0JTNEMjA0OCUyQyUyMCUwQSUyMCUyMCUyMCUyMHdpZHRoJTNEMjA0OCUyQyUwQSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyaW1hZ2UucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> HunyuanImagePipeline | |
| pipe = HunyuanImagePipeline.from_pretrained( | |
| <span class="hljs-string">"hunyuanvideo-community/HunyuanImage-2.1-Diffusers"</span>, | |
| torch_dtype=torch.bfloat16 | |
| ) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-comment"># Update the guider configuration</span> | |
| pipe.guider = pipe.guider.new(guidance_scale=<span class="hljs-number">5.0</span>) | |
| prompt = ( | |
| <span class="hljs-string">"A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, "</span> | |
| <span class="hljs-string">"wearing a red knitted scarf and a red beret with the word 'Tencent' on it, holding a paintbrush with a "</span> | |
| <span class="hljs-string">"focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."</span> | |
| ) | |
| image = pipe( | |
| prompt=prompt, | |
| num_inference_steps=<span class="hljs-number">50</span>, | |
| height=<span class="hljs-number">2048</span>, | |
| width=<span class="hljs-number">2048</span>, | |
| ).images[<span class="hljs-number">0</span>] | |
| image.save(<span class="hljs-string">"image.png"</span>)`,lang:"py",wrap:!1});var T=e(v,2);s(T,{title:"HunyuanImage-2.1-Distilled",local:"hunyuanimage-21-distilled",headingTag:"h2"});var U=e(T,4);i(U,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSHVueXVhbkltYWdlUGlwZWxpbmUlMEFwaXBlJTIwJTNEJTIwSHVueXVhbkltYWdlUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmh1bnl1YW52aWRlby1jb21tdW5pdHklMkZIdW55dWFuSW1hZ2UtMi4xLURpc3RpbGxlZC1EaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUlMjAlM0QlMjBwaXBlLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMkElMjBjdXRlJTJDJTIwY2FydG9vbi1zdHlsZSUyMGFudGhyb3BvbW9ycGhpYyUyMHBlbmd1aW4lMjBwbHVzaCUyMHRveSUyMHdpdGglMjBmbHVmZnklMjBmdXIlMkMlMjBzdGFuZGluZyUyMGluJTIwYSUyMHBhaW50aW5nJTIwc3R1ZGlvJTJDJTIwJTIyJTBBJTIwJTIwJTIwJTIwJTIyd2VhcmluZyUyMGElMjByZWQlMjBrbml0dGVkJTIwc2NhcmYlMjBhbmQlMjBhJTIwcmVkJTIwYmVyZXQlMjB3aXRoJTIwdGhlJTIwd29yZCUyMCdUZW5jZW50JyUyMG9uJTIwaXQlMkMlMjBob2xkaW5nJTIwYSUyMHBhaW50YnJ1c2glMjB3aXRoJTIwYSUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMmZvY3VzZWQlMjBleHByZXNzaW9uJTIwYXMlMjBpdCUyMHBhaW50cyUyMGFuJTIwb2lsJTIwcGFpbnRpbmclMjBvZiUyMHRoZSUyME1vbmElMjBMaXNhJTJDJTIwcmVuZGVyZWQlMjBpbiUyMGElMjBwaG90b3JlYWxpc3RpYyUyMHBob3RvZ3JhcGhpYyUyMHN0eWxlLiUyMiUwQSklMEElMEFvdXQlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q4JTJDJTBBJTIwJTIwJTIwJTIwZGlzdGlsbGVkX2d1aWRhbmNlX3NjYWxlJTNEMy4yNSUyQyUwQSUyMCUyMCUyMCUyMGhlaWdodCUzRDIwNDglMkMlMEElMjAlMjAlMjAlMjB3aWR0aCUzRDIwNDglMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEEpLmltYWdlcyU1QjAlNUQlMEE=",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> HunyuanImagePipeline | |
| pipe = HunyuanImagePipeline.from_pretrained(<span class="hljs-string">"hunyuanvideo-community/HunyuanImage-2.1-Distilled-Diffusers"</span>, torch_dtype=torch.bfloat16) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>) | |
| prompt = ( | |
| <span class="hljs-string">"A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, "</span> | |
| <span class="hljs-string">"wearing a red knitted scarf and a red beret with the word 'Tencent' on it, holding a paintbrush with a "</span> | |
| <span class="hljs-string">"focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."</span> | |
| ) | |
| out = pipe( | |
| prompt, | |
| num_inference_steps=<span class="hljs-number">8</span>, | |
| distilled_guidance_scale=<span class="hljs-number">3.25</span>, | |
| height=<span class="hljs-number">2048</span>, | |
| width=<span class="hljs-number">2048</span>, | |
| generator=generator, | |
| ).images[<span class="hljs-number">0</span>] | |
| `,lang:"py",wrap:!1});var j=e(U,2);s(j,{title:"HunyuanImagePipeline",local:"diffusers.HunyuanImagePipeline",headingTag:"h2"});var p=e(j,2),k=a(p);n(k,{name:"class diffusers.HunyuanImagePipeline",anchor:"diffusers.HunyuanImagePipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14192/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage.py#L160",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLHunyuanImage"},{name:"text_encoder",val:": Qwen2_5_VLForConditionalGeneration"},{name:"tokenizer",val:": Qwen2Tokenizer"},{name:"text_encoder_2",val:": T5EncoderModel"},{name:"tokenizer_2",val:": ByT5Tokenizer"},{name:"transformer",val:": HunyuanImageTransformer2DModel"},{name:"guider",val:": AdaptiveProjectedMixGuidance | None = None"},{name:"ocr_guider",val:": AdaptiveProjectedMixGuidance | None = None"}],parametersDescription:[{anchor:"diffusers.HunyuanImagePipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_14192/en/api/models/hunyuanimage_transformer_2d#diffusers.HunyuanImageTransformer2DModel">HunyuanImageTransformer2DModel</a>) — | |
| Conditional Transformer (MMDiT) architecture to denoise the encoded image latents.`,name:"transformer"},{anchor:"diffusers.HunyuanImagePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_14192/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.HunyuanImagePipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/pr_14192/en/api/models/autoencoder_kl_hunyuanimage#diffusers.AutoencoderKLHunyuanImage">AutoencoderKLHunyuanImage</a>) — | |
| Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.HunyuanImagePipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>Qwen2.5-VL-7B-Instruct</code>) — | |
| <a href="https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct" rel="nofollow">Qwen2.5-VL-7B-Instruct</a>, specifically the | |
| <a href="https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct" rel="nofollow">Qwen2.5-VL-7B-Instruct</a> variant.`,name:"text_encoder"},{anchor:"diffusers.HunyuanImagePipeline.tokenizer",description:"<strong>tokenizer</strong> (<code>Qwen2Tokenizer</code>) — Tokenizer of class [Qwen2Tokenizer].",name:"tokenizer"},{anchor:"diffusers.HunyuanImagePipeline.text_encoder_2",description:`<strong>text_encoder_2</strong> (<code>T5EncoderModel</code>) — | |
| <a href="https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel" rel="nofollow">T5EncoderModel</a> | |
| variant.`,name:"text_encoder_2"},{anchor:"diffusers.HunyuanImagePipeline.tokenizer_2",description:"<strong>tokenizer_2</strong> (<code>ByT5Tokenizer</code>) — Tokenizer of class [ByT5Tokenizer]",name:"tokenizer_2"},{anchor:"diffusers.HunyuanImagePipeline.guider",description:`<strong>guider</strong> (<code>AdaptiveProjectedMixGuidance</code>) — | |
| [AdaptiveProjectedMixGuidance]to be used to guide the image generation.`,name:"guider"},{anchor:"diffusers.HunyuanImagePipeline.ocr_guider",description:`<strong>ocr_guider</strong> (<code>AdaptiveProjectedMixGuidance</code>, <em>optional</em>) — | |
| [AdaptiveProjectedMixGuidance] to be used to guide the image generation when text rendering is needed.`,name:"ocr_guider"}]});var c=e(k,4),J=a(c);n(J,{name:"__call__",anchor:"diffusers.HunyuanImagePipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14192/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage.py#L504",parameters:[{name:"prompt",val:": str | list[str] = None"},{name:"negative_prompt",val:": str | list[str] = None"},{name:"height",val:": int | None = None"},{name:"width",val:": int | None = None"},{name:"num_inference_steps",val:": int = 50"},{name:"distilled_guidance_scale",val:": float | None = 3.25"},{name:"sigmas",val:": list[float] | None = None"},{name:"num_images_per_prompt",val:": int = 1"},{name:"generator",val:": torch.Generator | list[torch.Generator] | None = None"},{name:"latents",val:": torch.Tensor | None = None"},{name:"prompt_embeds",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds_mask",val:": torch.Tensor | None = None"},{name:"prompt_embeds_2",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask_2",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds_2",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds_mask_2",val:": torch.Tensor | None = None"},{name:"output_type",val:": str | None = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": dict[str, Any] | None = None"},{name:"callback_on_step_end",val:": Callable[[int, int], None] | None = None"},{name:"callback_on_step_end_tensor_inputs",val:": list[str] = ['latents']"}],parametersDescription:[{anchor:"diffusers.HunyuanImagePipeline.__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.HunyuanImagePipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| The prompt or prompts not to guide the image generation. If not defined and negative_prompt_embeds is | |
| not provided, will use an empty negative prompt. Ignored when not using guidance. ).`,name:"negative_prompt"},{anchor:"diffusers.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__call__.distilled_guidance_scale",description:`<strong>distilled_guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to None) — | |
| A guidance scale value for guidance distilled models. Unlike the traditional classifier-free guidance | |
| where the guidance scale is applied during inference through noise prediction rescaling, guidance | |
| distilled models take the guidance scale directly as an input parameter during forward pass. Guidance | |
| is enabled by setting <code>distilled_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 | |
| guidance distilled models, this parameter is required. For non-distilled models, this parameter will be | |
| ignored.`,name:"distilled_guidance_scale"},{anchor:"diffusers.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__call__.prompt_embeds_mask",description:`<strong>prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings mask. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. | |
| If not provided, text embeddings mask will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds_mask"},{anchor:"diffusers.HunyuanImagePipeline.__call__.prompt_embeds_2",description:`<strong>prompt_embeds_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings for ocr. Can be used to easily tweak text inputs, <em>e.g.</em> prompt | |
| weighting. If not provided, text embeddings for ocr will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds_2"},{anchor:"diffusers.HunyuanImagePipeline.__call__.prompt_embeds_mask_2",description:`<strong>prompt_embeds_mask_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings mask for ocr. Can be used to easily tweak text inputs, <em>e.g.</em> prompt | |
| weighting. If not provided, text embeddings mask for ocr will be generated from <code>prompt</code> input | |
| argument.`,name:"prompt_embeds_mask_2"},{anchor:"diffusers.HunyuanImagePipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt | |
| weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input | |
| argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.HunyuanImagePipeline.__call__.negative_prompt_embeds_mask",description:`<strong>negative_prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated negative text embeddings mask. Can be used to easily tweak text inputs, <em>e.g.</em> prompt | |
| weighting. If not provided, negative text embeddings mask will be generated from <code>negative_prompt</code> | |
| input argument.`,name:"negative_prompt_embeds_mask"},{anchor:"diffusers.HunyuanImagePipeline.__call__.negative_prompt_embeds_2",description:`<strong>negative_prompt_embeds_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated negative text embeddings for ocr. Can be used to easily tweak text inputs, <em>e.g.</em> prompt | |
| weighting. If not provided, negative text embeddings for ocr will be generated from <code>negative_prompt</code> | |
| input argument.`,name:"negative_prompt_embeds_2"},{anchor:"diffusers.HunyuanImagePipeline.__call__.negative_prompt_embeds_mask_2",description:`<strong>negative_prompt_embeds_mask_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated negative text embeddings mask for ocr. Can be used to easily tweak text inputs, <em>e.g.</em> | |
| prompt weighting. If not provided, negative text embeddings mask for ocr will be generated from | |
| <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds_mask_2"},{anchor:"diffusers.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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.HunyuanImagePipeline.__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"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~pipelines.hunyuan_image.HunyuanImagePipelineOutput</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.hunyuan_image.HunyuanImagePipelineOutput</code> or <code>tuple</code></p> | |
| `});var E=e(J,4);N(E,{anchor:"diffusers.HunyuanImagePipeline.__call__.example",children:(o,l)=>{var r=R(),_=e(h(r),2);i(_,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSHVueXVhbkltYWdlUGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwSHVueXVhbkltYWdlUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmh1bnl1YW52aWRlby1jb21tdW5pdHklMkZIdW55dWFuSW1hZ2UtMi4xLURpZmZ1c2VycyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpJTBBcGlwZS50byglMjJjdWRhJTIyKSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBjYXQlMjBob2xkaW5nJTIwYSUyMHNpZ24lMjB0aGF0JTIwc2F5cyUyMGhlbGxvJTIwd29ybGQlMjIlMEElMjMlMjBEZXBlbmRpbmclMjBvbiUyMHRoZSUyMHZhcmlhbnQlMjBiZWluZyUyMHVzZWQlMkMlMjB0aGUlMjBwaXBlbGluZSUyMGNhbGwlMjB3aWxsJTIwc2xpZ2h0bHklMjB2YXJ5LiUwQSUyMyUyMFJlZmVyJTIwdG8lMjB0aGUlMjBwaXBlbGluZSUyMGRvY3VtZW50YXRpb24lMjBmb3IlMjBtb3JlJTIwZGV0YWlscy4lMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEJTIyJTIyJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJodW55dWFuaW1hZ2UucG5nJTIyKQ==",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> HunyuanImagePipeline | |
| <span class="hljs-meta">>>> </span>pipe = HunyuanImagePipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"hunyuanvideo-community/HunyuanImage-2.1-Diffusers"</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, negative_prompt=<span class="hljs-string">""</span>, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>image.save(<span class="hljs-string">"hunyuanimage.png"</span>)`,lang:"py",wrap:!1}),d(o,r)},$$slots:{default:!0}}),t(c);var H=e(c,2),q=a(H);n(q,{name:"encode_prompt",anchor:"diffusers.HunyuanImagePipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14192/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage.py#L296",parameters:[{name:"prompt",val:": str | list[str]"},{name:"device",val:": torch.device | None = None"},{name:"batch_size",val:": int = 1"},{name:"num_images_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask",val:": torch.Tensor | None = None"},{name:"prompt_embeds_2",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask_2",val:": torch.Tensor | None = None"}],parametersDescription:[{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| prompt to be encoded`,name:"prompt"},{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.device",description:`<strong>device</strong> — (<code>torch.device</code>): | |
| torch device`,name:"device"},{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.batch_size",description:`<strong>batch_size</strong> (<code>int</code>) — | |
| batch size of prompts, defaults to 1`,name:"batch_size"},{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) — | |
| number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings. If not provided, text embeddings will be generated from <code>prompt</code> input | |
| argument.`,name:"prompt_embeds"},{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.prompt_embeds_mask",description:`<strong>prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text mask. If not provided, text mask will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds_mask"},{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.prompt_embeds_2",description:`<strong>prompt_embeds_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated glyph text embeddings from ByT5. If not provided, will be generated from <code>prompt</code> input | |
| argument using self.tokenizer_2 and self.text_encoder_2.`,name:"prompt_embeds_2"},{anchor:"diffusers.HunyuanImagePipeline.encode_prompt.prompt_embeds_mask_2",description:`<strong>prompt_embeds_mask_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated glyph text mask from ByT5. If not provided, will be generated from <code>prompt</code> input | |
| argument using self.tokenizer_2 and self.text_encoder_2.`,name:"prompt_embeds_mask_2"}]}),t(H),t(p);var x=e(p,2);s(x,{title:"HunyuanImageRefinerPipeline",local:"diffusers.HunyuanImageRefinerPipeline",headingTag:"h2"});var m=e(x,2),B=a(m);n(B,{name:"class diffusers.HunyuanImageRefinerPipeline",anchor:"diffusers.HunyuanImageRefinerPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14192/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage_refiner.py#L138",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLHunyuanImageRefiner"},{name:"text_encoder",val:": Qwen2_5_VLForConditionalGeneration"},{name:"tokenizer",val:": Qwen2Tokenizer"},{name:"transformer",val:": HunyuanImageTransformer2DModel"},{name:"guider",val:": AdaptiveProjectedMixGuidance | None = None"}],parametersDescription:[{anchor:"diffusers.HunyuanImageRefinerPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_14192/en/api/models/hunyuanimage_transformer_2d#diffusers.HunyuanImageTransformer2DModel">HunyuanImageTransformer2DModel</a>) — | |
| Conditional Transformer (MMDiT) architecture to denoise the encoded image latents.`,name:"transformer"},{anchor:"diffusers.HunyuanImageRefinerPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_14192/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.HunyuanImageRefinerPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/pr_14192/en/api/models/autoencoder_kl_hunyuanimage_refiner#diffusers.AutoencoderKLHunyuanImageRefiner">AutoencoderKLHunyuanImageRefiner</a>) — | |
| Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.HunyuanImageRefinerPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>Qwen2.5-VL-7B-Instruct</code>) — | |
| <a href="https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct" rel="nofollow">Qwen2.5-VL-7B-Instruct</a>, specifically the | |
| <a href="https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct" rel="nofollow">Qwen2.5-VL-7B-Instruct</a> variant.`,name:"text_encoder"},{anchor:"diffusers.HunyuanImageRefinerPipeline.tokenizer",description:"<strong>tokenizer</strong> (<code>Qwen2Tokenizer</code>) — Tokenizer of class [Qwen2Tokenizer].",name:"tokenizer"}]});var u=e(B,4),Z=a(u);n(Z,{name:"__call__",anchor:"diffusers.HunyuanImageRefinerPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14192/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage_refiner.py#L436",parameters:[{name:"prompt",val:": str | list[str] = None"},{name:"negative_prompt",val:": str | list[str] = None"},{name:"distilled_guidance_scale",val:": float | None = 3.25"},{name:"image",val:": PipelineImageInput | None = None"},{name:"height",val:": int | None = None"},{name:"width",val:": int | None = None"},{name:"num_inference_steps",val:": int = 4"},{name:"sigmas",val:": list[float] | None = None"},{name:"num_images_per_prompt",val:": int = 1"},{name:"generator",val:": torch.Generator | list[torch.Generator] | None = None"},{name:"latents",val:": torch.Tensor | None = None"},{name:"prompt_embeds",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds",val:": torch.Tensor | None = None"},{name:"negative_prompt_embeds_mask",val:": torch.Tensor | None = None"},{name:"output_type",val:": str | None = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": dict[str, Any] | None = None"},{name:"callback_on_step_end",val:": Callable[[int, int], None] | None = None"},{name:"callback_on_step_end_tensor_inputs",val:": list[str] = ['latents']"}],parametersDescription:[{anchor:"diffusers.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| The prompt or prompts not to guide the image generation. If not defined, will use an empty negative | |
| prompt. Ignored when not using guidance.`,name:"negative_prompt"},{anchor:"diffusers.HunyuanImageRefinerPipeline.__call__.distilled_guidance_scale",description:`<strong>distilled_guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to None) — | |
| A guidance scale value for guidance distilled models. Unlike the traditional classifier-free guidance | |
| where the guidance scale is applied during inference through noise prediction rescaling, guidance | |
| distilled models take the guidance scale directly as an input parameter during forward pass. Guidance | |
| is enabled by setting <code>distilled_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 | |
| guidance distilled models, this parameter is required. For non-distilled models, this parameter will be | |
| ignored.`,name:"distilled_guidance_scale"},{anchor:"diffusers.HunyuanImageRefinerPipeline.__call__.image",description:`<strong>image</strong> (<code>PipelineImageInput</code>, <em>optional</em>) — | |
| The input image to be refined.`,name:"image"},{anchor:"diffusers.HunyuanImageRefinerPipeline.__call__.num_images_per_prompt",description:"<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) —",name:"num_images_per_prompt"},{anchor:"diffusers.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__call__.prompt_embeds_mask",description:`<strong>prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Attention mask for <code>prompt_embeds</code>.`,name:"prompt_embeds_mask"},{anchor:"diffusers.HunyuanImageRefinerPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt | |
| weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input | |
| argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.HunyuanImageRefinerPipeline.__call__.negative_prompt_embeds_mask",description:`<strong>negative_prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Attention mask for <code>negative_prompt_embeds</code>.`,name:"negative_prompt_embeds_mask"},{anchor:"diffusers.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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.HunyuanImageRefinerPipeline.__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"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~pipelines.hunyuan_image.HunyuanImagePipelineOutput</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.hunyuan_image.HunyuanImagePipelineOutput</code> or <code>tuple</code></p> | |
| `});var Q=e(Z,4);N(Q,{anchor:"diffusers.HunyuanImageRefinerPipeline.__call__.example",children:(o,l)=>{var r=R(),_=e(h(r),2);i(_,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSHVueXVhbkltYWdlUmVmaW5lclBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMEh1bnl1YW5JbWFnZVJlZmluZXJQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyaHVueXVhbnZpZGVvLWNvbW11bml0eSUyRkh1bnl1YW5JbWFnZS0yLjEtUmVmaW5lci1EaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwY2F0JTIwaG9sZGluZyUyMGElMjBzaWduJTIwdGhhdCUyMHNheXMlMjBoZWxsbyUyMHdvcmxkJTIyJTBBaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMnBhdGglMkZ0byUyRmltYWdlLnBuZyUyMiklMEElMjMlMjBEZXBlbmRpbmclMjBvbiUyMHRoZSUyMHZhcmlhbnQlMjBiZWluZyUyMHVzZWQlMkMlMjB0aGUlMjBwaXBlbGluZSUyMGNhbGwlMjB3aWxsJTIwc2xpZ2h0bHklMjB2YXJ5LiUwQSUyMyUyMFJlZmVyJTIwdG8lMjB0aGUlMjBwaXBlbGluZSUyMGRvY3VtZW50YXRpb24lMjBmb3IlMjBtb3JlJTIwZGV0YWlscy4lMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwaW1hZ2UlM0RpbWFnZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q0KS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJodW55dWFuaW1hZ2UucG5nJTIyKQ==",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> HunyuanImageRefinerPipeline | |
| <span class="hljs-meta">>>> </span>pipe = HunyuanImageRefinerPipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers"</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>image = load_image(<span class="hljs-string">"path/to/image.png"</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, image=image, num_inference_steps=<span class="hljs-number">4</span>).images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>image.save(<span class="hljs-string">"hunyuanimage.png"</span>)`,lang:"py",wrap:!1}),d(o,r)},$$slots:{default:!0}}),t(u);var P=e(u,2),X=a(P);n(X,{name:"encode_prompt",anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14192/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage_refiner.py#L225",parameters:[{name:"prompt",val:": str | list[str] | None = None"},{name:"device",val:": torch.device | None = None"},{name:"batch_size",val:": int = 1"},{name:"num_images_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": torch.Tensor | None = None"},{name:"prompt_embeds_mask",val:": torch.Tensor | None = None"}],parametersDescription:[{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) — | |
| prompt to be encoded`,name:"prompt"},{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.device",description:`<strong>device</strong> — (<code>torch.device</code>): | |
| torch device`,name:"device"},{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.batch_size",description:`<strong>batch_size</strong> (<code>int</code>) — | |
| batch size of prompts, defaults to 1`,name:"batch_size"},{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) — | |
| number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text embeddings. If not provided, text embeddings will be generated from <code>prompt</code> input | |
| argument.`,name:"prompt_embeds"},{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.prompt_embeds_mask",description:`<strong>prompt_embeds_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated text mask. If not provided, text mask will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds_mask"},{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.prompt_embeds_2",description:`<strong>prompt_embeds_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated glyph text embeddings from ByT5. If not provided, will be generated from <code>prompt</code> input | |
| argument using self.tokenizer_2 and self.text_encoder_2.`,name:"prompt_embeds_2"},{anchor:"diffusers.HunyuanImageRefinerPipeline.encode_prompt.prompt_embeds_mask_2",description:`<strong>prompt_embeds_mask_2</strong> (<code>torch.Tensor</code>, <em>optional</em>) — | |
| Pre-generated glyph text mask from ByT5. If not provided, will be generated from <code>prompt</code> input | |
| argument using self.tokenizer_2 and self.text_encoder_2.`,name:"prompt_embeds_mask_2"}]}),t(P),t(m);var G=e(m,2);s(G,{title:"HunyuanImagePipelineOutput",local:"diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput",headingTag:"h2"});var g=e(G,2),z=a(g);n(z,{name:"class diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput",anchor:"diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14192/src/diffusers/pipelines/hunyuan_image/pipeline_output.py#L10",parameters:[{name:"images",val:": list"}],parametersDescription:[{anchor:"diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput.images",description:`<strong>images</strong> (<code>list[PIL.Image.Image]</code> or <code>np.ndarray</code>) — | |
| List of denoised PIL images of length <code>batch_size</code> or numpy array of shape <code>(batch_size, height, width, num_channels)</code>. PIL images or numpy array present the denoised images of the diffusion pipeline.`,name:"images"}]}),W(2),t(g);var Y=e(g,2);D(Y,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/hunyuanimage21.md"}),W(2),d(C,y),O()}export{ie as component}; | |
Xet Storage Details
- Size:
- 53.4 kB
- Xet hash:
- f4b3b2fd0891ed80c85358a6a234e74ff5f663892c5aef00d37c4db785129c90
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.