リモート推論
Remote inference は、デコードおよびエンコードのためのローカルでの生成要件をオフロードするために、Inference Endpoint へのアクセスを提供します。
remote_decode
diffusers.utils.remote_decode
< source >( 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の場合、スケーリングを適用した入力を渡す必要があります。
- Flux: 0.1159
- output_type (
"mp4"または"pil"または"pt", default“) — エンドポイントの 出力タイプ。変更される可能性があります。希望するタイプに関するフィードバックをお寄せください。"mp4": Supported by video models. Endpoint returnsbytesof video.“pil”: Supported by image and video models. Image models: Endpoint returnsbytesof an image inimage_format. Video models: Endpoint returnstorch.Tensorwith partialpostprocessingapplied. Requiresprocessoras a flag (anyNonevalue will work).“pt”: Support by image and video models. Endpoint returnstorch.Tensor. Withpartial_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 returnsbytesof video.“pil”: Function returnsPIL.Image.Image. Withoutput_type=“pil” no further processing is applied. Withoutput_type="pt" aPIL.Image.Imageis created.partial_postprocess=Falseprocessoris required.partial_postprocess=Trueprocessoris **not** required.“pt”: Function returnstorch.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
< source >( 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の場合、スケーリングを適用した入力を渡す必要があります。
- Flux: 0.1159
VAEエンコードをリモートで実行できるHugging Face Hybrid Inference。