Diffusers 文件
混合推理API參考
並獲得增強的文件體驗
開始使用
混合推理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 (
VaeImageProcessor或VideoProcessor, 可選) — 與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,則輸入必須經過縮放處理。
- Flux: 0.1159 如果為
- output_type (
"mp4"或"pil"或"pt", 預設為“pil”) — 端點輸出型別。可能會更改。請反饋首選型別。"mp4":影片模型支援。端點返回影片的bytes。"pil":影像和影片模型支援。影像模型:端點返回image_format中的影像bytes。影片模型:端點返回應用了部分postprocessing的torch.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時,張量為float16或bfloat16,未經去範化。當partial_postprocess=True時,張量為uint8,已去範化。 - 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"潛在空間所需。
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.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 如果為
Hugging Face 混合推理,允許遠端執行 VAE 編碼。