Diffusers 文件

混合推理API參考

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

混合推理API參考

遠端解碼

diffusers.utils.remote_decode

< >

( endpoint: str tensor: torch.Tensor processor: typing.Union[ForwardRef('VaeImageProcessor'), ForwardRef('VideoProcessor'), NoneType] = None do_scaling: bool = True scaling_factor: typing.Optional[float] = None shift_factor: typing.Optional[float] = None output_type: typing.Literal['mp4', 'pil', 'pt'] = 'pil' return_type: typing.Literal['mp4', 'pil', 'pt'] = 'pil' image_format: typing.Literal['png', 'jpg'] = 'jpg' partial_postprocess: bool = False input_tensor_type: typing.Literal['binary'] = 'binary' output_tensor_type: typing.Literal['binary'] = 'binary' height: typing.Optional[int] = None width: typing.Optional[int] = None )

引數

  • endpoint (str) — 遠端解碼的端點。
  • tensor (torch.Tensor) — 要解碼的張量。
  • processor (VaeImageProcessorVideoProcessor, 可選) — 與 return_type="pt" 以及影片模型的 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", 預設為 “pil”) — 端點輸出型別。可能會更改。請反饋首選型別。

    "mp4":影片模型支援。端點返回影片的 bytes"pil":影像和影片模型支援。影像模型:端點返回 image_format 中的影像 bytes。影片模型:端點返回應用了部分 postprocessingtorch.Tensor。需要 processor 標誌(任何 None 值都可以)。"pt":影像和影片模型支援。端點返回 torch.Tensor。當 partial_postprocess=True 時,張量是經過後處理的 uint8 影像張量。

    建議:"pt"partial_postprocess=True 時傳輸的資料量最小,質量最高。"pt"partial_postprocess=False 時與第三方程式碼相容性最佳。"pil"image_format="jpg" 時總體傳輸資料量最小。

  • return_type ("mp4""pil""pt", 預設為 “pil”) — 函式返回型別。

    "mp4":函式返回影片的 bytes"pil":函式返回 PIL.Image.Image。當 output_type="pil" 時,不進行進一步處理。當 output_type="pt" 時,建立 PIL.Image.Image。當 partial_postprocess=False 時,需要 processor。當 partial_postprocess=True 時,不需要 processor"pt":函式返回 torch.Tensor不需要 processor。當 partial_postprocess=False 時,張量為 float16bfloat16,未經去範化。當 partial_postprocess=True 時,張量為 uint8,已去範化。

  • image_format ("png""jpg", 預設為 jpg) — 與 output_type="pil" 一起使用。端點返回 jpgpng
  • partial_postprocess (bool, 預設為 False) — 與 output_type="pt" 一起使用。當 partial_postprocess=False 時,張量為 float16bfloat16,未經去範化。當 partial_postprocess=True 時,張量為 uint8,已去範化。
  • input_tensor_type ("binary", 預設為 "binary") — 張量傳輸型別。
  • output_tensor_type ("binary", 預設為 "binary") — 張量傳輸型別。
  • height (int, 可選) — "packed" 潛在空間所需。
  • width (int, 可選) — "packed" 潛在空間所需。

Hugging Face 混合推理,允許遠端執行 VAE 解碼。

遠端編碼

diffusers.utils.remote_utils.remote_encode

< >

( endpoint: str image: typing.Union[ForwardRef('torch.Tensor'), PIL.Image.Image] scaling_factor: typing.Optional[float] = None shift_factor: typing.Optional[float] = None )

引數

  • endpoint (str) — 遠端解碼的端點。
  • image (torch.TensorPIL.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,則輸入必須經過縮放處理。

Hugging Face 混合推理,允許遠端執行 VAE 編碼。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.