Diffusers documentation

リモート推論

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

リモート推論

Remote inference は、デコードおよびエンコードのためのローカルでの生成要件をオフロードするために、Inference Endpoint へのアクセスを提供します。

remote_decode

diffusers.utils.remote_decode

< >

( endpoint: strtensor: 'torch.Tensor'processor: 'VaeImageProcessor' | 'VideoProcessor' | None = Nonedo_scaling: bool = Truescaling_factor: float | None = Noneshift_factor: float | None = Noneoutput_type: Literal['mp4', 'pil', 'pt'] = 'pil'return_type: Literal['mp4', 'pil', 'pt'] = 'pil'image_format: Literal['png', 'jpg'] = 'jpg'partial_postprocess: bool = Falseinput_tensor_type: Literal['binary'] = 'binary'output_tensor_type: Literal['binary'] = 'binary'height: int | None = Nonewidth: int | None = None )

パラメータ

  • endpoint (str) — Remote Decode のエンドポイント。
  • tensor (torch.Tensor) — デコード対象のテンソル。
  • processor(VaeImageProcessor または VideoProcessor、任意)— return_type="pt" と、Video モデルでは return_type="pil" と組み合わせて使用します。
  • do_scaling (bool、デフォルト True、任意) — 非推奨。 代わりに scaling_factor/shift_factor を渡してください。 オプションが削除されるまで、スケーリングを行わない場合は do_scaling=None/do_scaling=False を設定し続けてください True の場合、latents / self.vae.config.scaling_factor のようなスケーリングがリモートで適用されます。 False の場合、スケーリングが適用された状態で入力を受け渡す必要があります。
  • scaling_factor (float, 省略可) — 例: latents / self.vae.config.scaling_factor.
    • SD v1: 0.18215
    • SD XL: 0.13025
    • Flux: 0.3611 Noneの場合、スケーリングを適用した入力を渡す必要があります。
  • shift_factor (float, 省略可) — 渡された場合、シフトが適用されます。例: latents + self.vae.config.shift_factor.
    • Flux: 0.1159 Noneの場合、スケーリングを適用した入力を渡す必要があります。
  • output_type ("mp4" または "pil" または "pt", default “) — エンドポイントの 出力タイプ。変更される可能性があります。希望するタイプに関するフィードバックをお寄せください。

    "mp4": Supported by video models. Endpoint returns bytesof video.“pil”: Supported by image and video models. Image models: Endpoint returns bytesof an image inimage_format. Video models: Endpoint returns torch.Tensorwith partialpostprocessingapplied. Requiresprocessoras a flag (anyNonevalue will work).“pt”: Support by image and video models. Endpoint returns torch.Tensor. With partial_postprocess=Truethe tensor is postprocesseduint8` image tensor.

    推奨事項: "pt"にpartial_postprocess=Trueを指定すると、フル品質で最小の転送になります。"pt"に partial_postprocess=Falseを指定すると、サードパーティ製コードとの互換性が最高になります。"pil"に image_format="jpg"を指定すると、全体として最小の転送になります。

  • return_type ("mp4" または "pil" または "pt", default “)— 関数の 戻り値の型。

    "mp4": Function returns bytesof video.“pil”: Function returns PIL.Image.Image. With output_type=“pil” no further processing is applied. With output_type="pt" a PIL.Image.Imageis created.partial_postprocess=False processoris required.partial_postprocess=True processoris **not** required.“pt”: Function returns torch.Tensor. processoris **not** required.partial_postprocess=Falsetensor isfloat16orbfloat16, without denormalization. partial_postprocess=Truetensor isuint8`, denormalized.

  • image_format ("png" または "jpg"、デフォルトは jpg) — output_type="pil" と併せて使用します。エンドポイントは jpg または png を返します。
  • partial_postprocess (bool、デフォルト False) — output_type="pt" と併せて使用します。partial_postprocess=False の場合、テンソルはfloat16またはbfloat16で、デノーマライズされていません。partial_postprocess=True の場合、テンソルはuint8で、デノーマライズされています。
  • input_tensor_type ("binary"、デフォルトは "binary") — テンソル転送タイプ。
  • output_tensor_type ("binary"、デフォルトは "binary") — テンソルの転送タイプ。
  • height (int、任意) — "packed" 形式の潜在変数には必須です。
  • width (int、任意) — "packed" 形式の潜在変数には必須です。

VAEのデコードをリモートで実行できるHugging Face Hybrid Inference。

remote_encode

diffusers.utils.remote_utils.remote_encode

< >

( endpoint: strimage: 'torch.Tensor' | Image.Imagescaling_factor: float | None = Noneshift_factor: float | None = None )

パラメータ

  • endpoint (str) — Remote Decode のエンドポイント。
  • image (torch.Tensor または PIL.Image.Image) — エンコードする画像。
  • scaling_factor (float, 省略可) — 例: latents * self.vae.config.scaling_factor.
    • SD v1: 0.18215
    • SD XL: 0.13025
    • Flux: 0.3611 Noneの場合、スケーリングを適用した入力を渡す必要があります。
  • shift_factor (float, 省略可) — 指定された場合、シフトが適用されます。例: latents - self.vae.config.shift_factor.
    • Flux: 0.1159 Noneの場合、スケーリングを適用した入力を渡す必要があります。

VAEエンコードをリモートで実行できるHugging Face Hybrid Inference。

Update on GitHub