Buckets:

HuggingFaceDocBuilder's picture
download
raw
11 kB
import"../chunks/DsnmJJEf.js";import{i as x,h as w,C as I,H as r,D as u,E as T,s as D}from"../chunks/D6n3-7pR.js";import{p as N,o as F,s as e,f as L,a as f,b as E,c as m,d as _,n as s,r as g}from"../chunks/Bxg1KTwn.js";const S='{"title":"混合推理 API 参考","local":"混合推理-api-参考","sections":[{"title":"远程解码","local":"diffusers.utils.remote_decode","sections":[],"depth":2},{"title":"远程编码","local":"diffusers.utils.remote_utils.remote_encode","sections":[],"depth":2}],"depth":1}';var P=_('<meta name="hf:doc:metadata"/>'),C=_('<p></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>Hugging Face Hybrid Inference that allow running VAE decode remotely.</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>Hugging Face Hybrid Inference that allow running VAE encode remotely.</p></div> <!> <p></p>',1);function z(h,b){N(b,!1),F(()=>{new URLSearchParams(window.location.search).get("fw")}),x();var n=C();w("5hk94w",p=>{var l=P();D(l,"content",S),f(p,l)});var d=e(L(n),2);I(d,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var i=e(d,2);r(i,{title:"混合推理 API 参考",local:"混合推理-api-参考",headingTag:"h1"});var c=e(i,2);r(c,{title:"远程解码",local:"diffusers.utils.remote_decode",headingTag:"h2"});var o=e(c,2),y=m(o);u(y,{name:"diffusers.utils.remote_decode",anchor:"diffusers.utils.remote_decode",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/utils/remote_utils.py#L190",parameters:[{name:"endpoint",val:": str"},{name:"tensor",val:": 'torch.Tensor'"},{name:"processor",val:": 'VaeImageProcessor' | 'VideoProcessor' | None = None"},{name:"do_scaling",val:": bool = True"},{name:"scaling_factor",val:": float | None = None"},{name:"shift_factor",val:": float | None = None"},{name:"output_type",val:": Literal['mp4', 'pil', 'pt'] = 'pil'"},{name:"return_type",val:": Literal['mp4', 'pil', 'pt'] = 'pil'"},{name:"image_format",val:": Literal['png', 'jpg'] = 'jpg'"},{name:"partial_postprocess",val:": bool = False"},{name:"input_tensor_type",val:": Literal['binary'] = 'binary'"},{name:"output_tensor_type",val:": Literal['binary'] = 'binary'"},{name:"height",val:": int | None = None"},{name:"width",val:": int | None = None"}],parametersDescription:[{anchor:"diffusers.utils.remote_decode.endpoint",description:`<strong>endpoint</strong> (<code>str</code>) &#x2014;
Endpoint for Remote Decode.`,name:"endpoint"},{anchor:"diffusers.utils.remote_decode.tensor",description:`<strong>tensor</strong> (<code>torch.Tensor</code>) &#x2014;
Tensor to be decoded.`,name:"tensor"},{anchor:"diffusers.utils.remote_decode.processor",description:`<strong>processor</strong> (<code>VaeImageProcessor</code> or <code>VideoProcessor</code>, <em>optional</em>) &#x2014;
Used with <code>return_type=&quot;pt&quot;</code>, and <code>return_type=&quot;pil&quot;</code> for Video models.`,name:"processor"},{anchor:"diffusers.utils.remote_decode.do_scaling",description:`<strong>do_scaling</strong> (<code>bool</code>, default <code>True</code>, <em>optional</em>) &#x2014;
<strong>DEPRECATED</strong>. <strong>pass <code>scaling_factor</code>/<code>shift_factor</code> instead.</strong> <strong>still set
do_scaling=None/do_scaling=False for no scaling until option is removed</strong> When <code>True</code> scaling e.g. <code>latents / self.vae.config.scaling_factor</code> is applied remotely. If <code>False</code>, input must be passed with scaling
applied.`,name:"do_scaling"},{anchor:"diffusers.utils.remote_decode.scaling_factor",description:`<strong>scaling_factor</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Scaling is applied when passed e.g. <a href="https://github.com/huggingface/diffusers/blob/7007febae5cff000d4df9059d9cf35133e8b2ca9/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py#L1083C37-L1083C77" rel="nofollow"><code>latents / self.vae.config.scaling_factor</code></a>.</p>
<ul>
<li>SD v1: 0.18215</li>
<li>SD XL: 0.13025</li>
<li>Flux: 0.3611
If <code>None</code>, input must be passed with scaling applied.</li>
</ul>`,name:"scaling_factor"},{anchor:"diffusers.utils.remote_decode.shift_factor",description:`<strong>shift_factor</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Shift is applied when passed e.g. <code>latents + self.vae.config.shift_factor</code>.</p>
<ul>
<li>Flux: 0.1159
If <code>None</code>, input must be passed with scaling applied.</li>
</ul>`,name:"shift_factor"},{anchor:"diffusers.utils.remote_decode.output_type",description:`<strong>output_type</strong> (<code>&quot;mp4&quot;</code> or <code>&quot;pil&quot;</code> or <code>&quot;pt&quot;, default </code>&#x201C;pil&#x201D;) &#x2014;
<strong>Endpoint</strong> output type. Subject to change. Report feedback on preferred type.</p>
<p><code>&quot;mp4&quot;: Supported by video models. Endpoint returns </code>bytes<code>of video.</code>&#x201C;pil&#x201D;<code>: Supported by image and video models. Image models: Endpoint returns </code>bytes<code>of an image in</code>image_format<code>. Video models: Endpoint returns </code>torch.Tensor<code>with partial</code>postprocessing<code>applied. Requires</code>processor<code>as a flag (any</code>None<code>value will work).</code>&#x201C;pt&#x201D;<code>: Support by image and video models. Endpoint returns </code>torch.Tensor<code>. With </code>partial_postprocess=True<code>the tensor is postprocessed</code>uint8\` image tensor.</p>
<p>Recommendations:
<code>&quot;pt&quot;</code> with <code>partial_postprocess=True</code> is the smallest transfer for full quality. <code>&quot;pt&quot;</code> with
<code>partial_postprocess=False</code> is the most compatible with third party code. <code>&quot;pil&quot;</code> with
<code>image_format=&quot;jpg&quot;</code> is the smallest transfer overall.`,name:"output_type"},{anchor:"diffusers.utils.remote_decode.return_type",description:`<strong>return_type</strong> (<code>&quot;mp4&quot;</code> or <code>&quot;pil&quot;</code> or <code>&quot;pt&quot;, default </code>&#x201C;pil&#x201D;) &#x2014;
<strong>Function</strong> return type.</p>
<p><code>&quot;mp4&quot;: Function returns </code>bytes<code>of video.</code>&#x201C;pil&#x201D;<code>: Function returns </code>PIL.Image.Image<code>. With </code>output_type=&#x201C;pil&#x201D; no further processing is applied. With <code>output_type=&quot;pt&quot; a </code>PIL.Image.Image<code>is created.</code>partial_postprocess=False<code> </code>processor<code>is required.</code>partial_postprocess=True<code> </code>processor<code>is **not** required.</code>&#x201C;pt&#x201D;<code>: Function returns </code>torch.Tensor<code>. </code>processor<code>is **not** required.</code>partial_postprocess=False<code>tensor is</code>float16<code>or</code>bfloat16<code>, without denormalization. </code>partial_postprocess=True<code>tensor is</code>uint8\`, denormalized.`,name:"return_type"},{anchor:"diffusers.utils.remote_decode.image_format",description:`<strong>image_format</strong> (<code>&quot;png&quot;</code> or <code>&quot;jpg&quot;</code>, default <code>jpg</code>) &#x2014;
Used with <code>output_type=&quot;pil&quot;</code>. Endpoint returns <code>jpg</code> or <code>png</code>.`,name:"image_format"},{anchor:"diffusers.utils.remote_decode.partial_postprocess",description:`<strong>partial_postprocess</strong> (<code>bool</code>, default <code>False</code>) &#x2014;
Used with <code>output_type=&quot;pt&quot;</code>. <code>partial_postprocess=False</code> tensor is <code>float16</code> or <code>bfloat16</code>, without
denormalization. <code>partial_postprocess=True</code> tensor is <code>uint8</code>, denormalized.`,name:"partial_postprocess"},{anchor:"diffusers.utils.remote_decode.input_tensor_type",description:`<strong>input_tensor_type</strong> (<code>&quot;binary&quot;</code>, default <code>&quot;binary&quot;</code>) &#x2014;
Tensor transfer type.`,name:"input_tensor_type"},{anchor:"diffusers.utils.remote_decode.output_tensor_type",description:`<strong>output_tensor_type</strong> (<code>&quot;binary&quot;</code>, default <code>&quot;binary&quot;</code>) &#x2014;
Tensor transfer type.`,name:"output_tensor_type"},{anchor:"diffusers.utils.remote_decode.height",description:`<strong>height</strong> (<code>int</code>, <strong>optional</strong>) &#x2014;
Required for <code>&quot;packed&quot;</code> latents.`,name:"height"},{anchor:"diffusers.utils.remote_decode.width",description:`<strong>width</strong> (<code>int</code>, <strong>optional</strong>) &#x2014;
Required for <code>&quot;packed&quot;</code> latents.`,name:"width"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>output (<code>Image.Image</code> or <code>list[Image.Image]</code> or <code>bytes</code> or <code>torch.Tensor</code>).</p>
`}),s(2),g(o);var a=e(o,2);r(a,{title:"远程编码",local:"diffusers.utils.remote_utils.remote_encode",headingTag:"h2"});var t=e(a,2),q=m(t);u(q,{name:"diffusers.utils.remote_utils.remote_encode",anchor:"diffusers.utils.remote_utils.remote_encode",source:"https://github.com/huggingface/diffusers/blob/vr_13881/src/diffusers/utils/remote_utils.py#L382",parameters:[{name:"endpoint",val:": str"},{name:"image",val:": 'torch.Tensor' | Image.Image"},{name:"scaling_factor",val:": float | None = None"},{name:"shift_factor",val:": float | None = None"}],parametersDescription:[{anchor:"diffusers.utils.remote_utils.remote_encode.endpoint",description:`<strong>endpoint</strong> (<code>str</code>) &#x2014;
Endpoint for Remote Decode.`,name:"endpoint"},{anchor:"diffusers.utils.remote_utils.remote_encode.image",description:`<strong>image</strong> (<code>torch.Tensor</code> or <code>PIL.Image.Image</code>) &#x2014;
Image to be encoded.`,name:"image"},{anchor:"diffusers.utils.remote_utils.remote_encode.scaling_factor",description:`<strong>scaling_factor</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Scaling is applied when passed e.g. <code>latents * self.vae.config.scaling_factor</code>.
<ul>
<li>SD v1: 0.18215</li>
<li>SD XL: 0.13025</li>
<li>Flux: 0.3611
If <code>None</code>, input must be passed with scaling applied.</li>
</ul>`,name:"scaling_factor"},{anchor:"diffusers.utils.remote_utils.remote_encode.shift_factor",description:`<strong>shift_factor</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Shift is applied when passed e.g. <code>latents - self.vae.config.shift_factor</code>.
<ul>
<li>Flux: 0.1159
If <code>None</code>, input must be passed with scaling applied.</li>
</ul>`,name:"shift_factor"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>output (<code>torch.Tensor</code>).</p>
`}),s(2),g(t);var v=e(t,2);T(v,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/hybrid_inference/api_reference.md"}),s(2),f(h,n),E()}export{z as component};

Xet Storage Details

Size:
11 kB
·
Xet hash:
757f15437c8b820475efad27f897a83bb53ce0b6042baa46dd99bba4e1ff0607

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