Buckets:

download
raw
12.5 kB
import"../chunks/DsnmJJEf.js";import{i as L,h as P,C as K,H as v,a as k,D as o,E as J,s as z}from"../chunks/X8cAGukj.js";import{p as j,o as D,s as e,f as U,a as b,b as q,c as a,d as w,n as t,r as n}from"../chunks/CQ2f15a1.js";const E='{"title":"AutoencoderKLPH3Image","local":"autoencoderklph3image","sections":[{"title":"AutoencoderKLPH3Image","local":"diffusers.AutoencoderKLPH3Image","sections":[],"depth":2}],"depth":1}';var N=w('<meta name="hf:doc:metadata"/>'),V=w(`<p></p> <!> <!> <p>The image VAE of <a href="https://huggingface.co/PrunaAI/P-H3-Image" rel="nofollow">P-H3-Image</a> by Pruna AI. It uses the encoder and latent space of MiniMax-H3’s <a href="./autoencoderkl_minimax_h3">video VAE</a>, with a ViT decoder that decodes a single latent frame into an image.</p> <p>It follows the conventions of <a href="/docs/diffusers/pr_15212/en/api/models/autoencoderkl_minimax_h3#diffusers.AutoencoderKLMiniMaxH3">AutoencoderKLMiniMaxH3</a>:</p> <ul><li>Images are passed as single-frame videos, <code>(batch_size, channels, 1, height, width)</code>, with 16x spatial compression.</li> <li>Latents are normalized per channel with <code>latents_mean</code> / <code>latents_std</code> instead of a <code>scaling_factor</code>.</li> <li>Pixels are ImageNet-normalized RGB over <code>[0, 1]</code>: <code>encode</code> expects <code>(pixel - imagenet_mean) / imagenet_std</code> and <code>decode</code> returns that space.</li> <li>Spatial tiling is on by default, with 256 pixel tiles and at least 64 pixels of overlap.</li></ul> <!> <p>The encoder and the decoder’s output projection stay in float32 whatever <code>dtype</code> the model is loaded in.</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 image VAE of <a href="https://huggingface.co/PrunaAI/P-H3-Image" rel="nofollow">P-H3-Image</a>: MiniMax-H3’s VAE encoder and latent
space, with a <code>PH3ImageViTDecoder</code> that decodes a single latent frame.</p> <p>Images are passed as single-frame videos, <code>(batch_size, channels, 1, height, width)</code>. As in <a href="/docs/diffusers/pr_15212/en/api/models/autoencoderkl_minimax_h3#diffusers.AutoencoderKLMiniMaxH3">AutoencoderKLMiniMaxH3</a>, pixels are ImageNet-normalized RGB over <code>[0, 1]</code> (mean <code>(0.485, 0.456, 0.406)</code>, std <code>(0.229, 0.224, 0.225)</code>) and spatial tiling is on by default.</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>Encode a batch of images into 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>Decode a batch of latent images.</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>Enable tiled VAE encoding/decoding. When this option is enabled, the VAE splits the frames into tiles, encodes
or decodes each tile separately and linearly blends the overlaps back together. This lowers the memory
requirement and allows processing larger frames.</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>Encode then decode a batch of images.</p></div></div> <!> <p></p>`,1);function C(I,y){j(y,!1),D(()=>{new URLSearchParams(window.location.search).get("fw")}),L();var l=V();P("c22the",g=>{var f=N();z(f,"content",E),b(g,f)});var c=e(U(l),2);K(c,{containerStyle:"float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"});var m=e(c,2);v(m,{title:"AutoencoderKLPH3Image",local:"autoencoderklph3image",headingTag:"h1"});var p=e(m,8);k(p,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b2VuY29kZXJLTFBIM0ltYWdlJTBBJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTFBIM0ltYWdlLmZyb21fcHJldHJhaW5lZCglMjJQcnVuYUFJJTJGUC1IMy1JbWFnZSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnZhZSUyMiUyQyUyMGR0eXBlJTNEdG9yY2guYmZsb2F0MTYpLnRvKCUwQSUyMCUyMCUyMCUyMCUyMmN1ZGElMjIlMEEpJTIwJTIwJTIzJTIwb3IlMjAlMjJtcHMlMjIlMkMlMjAlMjJ4cHUlMjIlMkMlMjAlMjJjcHUlMjI=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLPH3Image
vae = AutoencoderKLPH3Image.from_pretrained(<span class="hljs-string">&quot;PrunaAI/P-H3-Image&quot;</span>, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, dtype=torch.bfloat16).to(
<span class="hljs-string">&quot;cuda&quot;</span>
) <span class="hljs-comment"># or &quot;mps&quot;, &quot;xpu&quot;, &quot;cpu&quot;</span>`,lang:"python",wrap:!1});var u=e(p,4);v(u,{title:"AutoencoderKLPH3Image",local:"diffusers.AutoencoderKLPH3Image",headingTag:"h2"});var r=e(u,2),h=a(r);o(h,{name:"class diffusers.AutoencoderKLPH3Image",anchor:"diffusers.AutoencoderKLPH3Image",source:"https://github.com/huggingface/diffusers/blob/vr_15212/src/diffusers/models/autoencoders/autoencoder_kl_p_h3_image.py#L493",parameters:[{name:"in_channels",val:": int = 3"},{name:"out_channels",val:": int = 3"},{name:"latent_channels",val:": int = 24"},{name:"block_out_channels",val:": tuple = (128, 256, 256, 512, 512, 1024)"},{name:"layers_per_block",val:": int = 2"},{name:"spatial_downsample_factors",val:": tuple = (2, 2, 2, 2, 1, 1)"},{name:"temporal_downsample_factors",val:": tuple = (1, 2, 2, 1, 1, 1)"},{name:"norm_num_groups",val:": int = 32"},{name:"norm_eps",val:": float = 1e-06"},{name:"spatial_padding_mode",val:": str = 'reflect'"},{name:"decoder_num_layers",val:": int = 36"},{name:"decoder_num_attention_heads",val:": int = 32"},{name:"decoder_attention_head_dim",val:": int = 64"},{name:"decoder_num_register_tokens",val:": int = 4"},{name:"decoder_ffn_mult",val:": int = 4"},{name:"decoder_rope_theta",val:": float = 100.0"},{name:"decoder_rope_dim_ratio",val:": float = 0.75"},{name:"decoder_norm_eps",val:": float = 1e-05"},{name:"latents_mean",val:": tuple = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)"},{name:"latents_std",val:": tuple = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)"}]});var s=e(h,6),T=a(s);o(T,{name:"encode",anchor:"diffusers.AutoencoderKLPH3Image.encode",source:"https://github.com/huggingface/diffusers/blob/vr_15212/src/diffusers/models/autoencoders/autoencoder_kl_p_h3_image.py#L728",parameters:[{name:"x",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLPH3Image.encode.x",description:`<strong>x</strong> (<code>torch.Tensor</code>) &#x2014;
Input batch of images as single-frame videos, shape <code>(batch_size, in_channels, 1, height, width)</code>.`,name:"x"},{anchor:"diffusers.AutoencoderKLPH3Image.encode.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return a <a href="/docs/diffusers/pr_15212/en/api/models/autoencoderkl_qwenimage#diffusers.models.modeling_outputs.AutoencoderKLOutput">AutoencoderKLOutput</a> instead of a plain
tuple.`,name:"return_dict"}],returnDescription:`
<p>The latent distribution of the encoded images. Note that the latents are normalized with <code>latents_mean</code> /
<code>latents_std</code> afterwards.</p>
`}),t(2),n(s);var i=e(s,2),x=a(i);o(x,{name:"decode",anchor:"diffusers.AutoencoderKLPH3Image.decode",source:"https://github.com/huggingface/diffusers/blob/vr_15212/src/diffusers/models/autoencoders/autoencoder_kl_p_h3_image.py#L757",parameters:[{name:"z",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLPH3Image.decode.z",description:`<strong>z</strong> (<code>torch.Tensor</code>) &#x2014;
Input batch of latents, shape <code>(batch_size, latent_channels, 1, height, width)</code>.`,name:"z"},{anchor:"diffusers.AutoencoderKLPH3Image.decode.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return a <a href="/docs/diffusers/pr_15212/en/api/models/autoencoderkl_qwenimage#diffusers.models.autoencoders.vae.DecoderOutput">DecoderOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`
<p>The decoded images, shape <code>(batch_size, out_channels, 1, height, width)</code>.</p>
`,returnType:`
<p><a
href="/docs/diffusers/pr_15212/en/api/models/autoencoderkl_qwenimage#diffusers.models.autoencoders.vae.DecoderOutput"
>DecoderOutput</a> or <code>tuple</code></p>
`}),t(2),n(i);var d=e(i,2),M=a(d);o(M,{name:"enable_tiling",anchor:"diffusers.AutoencoderKLPH3Image.enable_tiling",source:"https://github.com/huggingface/diffusers/blob/vr_15212/src/diffusers/models/autoencoders/autoencoder_kl_p_h3_image.py#L575",parameters:[{name:"tile_sample_min_height",val:": int | None = None"},{name:"tile_sample_min_width",val:": int | None = None"},{name:"tile_sample_min_overlap_height",val:": int | None = None"},{name:"tile_sample_min_overlap_width",val:": int | None = None"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLPH3Image.enable_tiling.tile_sample_min_height",description:`<strong>tile_sample_min_height</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The tile height in pixel space. Frames taller than this are split along the height dimension.`,name:"tile_sample_min_height"},{anchor:"diffusers.AutoencoderKLPH3Image.enable_tiling.tile_sample_min_width",description:`<strong>tile_sample_min_width</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The tile width in pixel space. Frames wider than this are split along the width dimension.`,name:"tile_sample_min_width"},{anchor:"diffusers.AutoencoderKLPH3Image.enable_tiling.tile_sample_min_overlap_height",description:`<strong>tile_sample_min_overlap_height</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The minimum overlap, in pixels, between two consecutive vertical tiles.`,name:"tile_sample_min_overlap_height"},{anchor:"diffusers.AutoencoderKLPH3Image.enable_tiling.tile_sample_min_overlap_width",description:`<strong>tile_sample_min_overlap_width</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The minimum overlap, in pixels, between two consecutive horizontal tiles.`,name:"tile_sample_min_overlap_width"}]}),t(2),n(d);var _=e(d,2),A=a(_);o(A,{name:"forward",anchor:"diffusers.AutoencoderKLPH3Image.forward",source:"https://github.com/huggingface/diffusers/blob/vr_15212/src/diffusers/models/autoencoders/autoencoder_kl_p_h3_image.py#L784",parameters:[{name:"sample",val:": Tensor"},{name:"sample_posterior",val:": bool = False"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLPH3Image.forward.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
Input batch of images as single-frame videos, shape <code>(batch_size, in_channels, 1, height, width)</code>.`,name:"sample"},{anchor:"diffusers.AutoencoderKLPH3Image.forward.sample_posterior",description:`<strong>sample_posterior</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to sample the posterior instead of taking its mode.`,name:"sample_posterior"},{anchor:"diffusers.AutoencoderKLPH3Image.forward.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
Generator used when <code>sample_posterior=True</code>.`,name:"generator"},{anchor:"diffusers.AutoencoderKLPH3Image.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return a <a href="/docs/diffusers/pr_15212/en/api/models/autoencoderkl_qwenimage#diffusers.models.autoencoders.vae.DecoderOutput">DecoderOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`
<p>The round-tripped images, shape <code>(batch_size, out_channels, 1, height, width)</code>.</p>
`,returnType:`
<p><a
href="/docs/diffusers/pr_15212/en/api/models/autoencoderkl_qwenimage#diffusers.models.autoencoders.vae.DecoderOutput"
>DecoderOutput</a> or <code>tuple</code></p>
`}),t(2),n(_),n(r);var H=e(r,2);J(H,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/autoencoderkl_p_h3_image.md"}),t(2),b(I,l),q()}export{C as component};

Xet Storage Details

Size:
12.5 kB
·
Xet hash:
35e87221112a5e045ae41acbe29e621288ddf7d32b9b21dac982199a99b9061e

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