MCPcopy Index your code
hub / github.com/huggingface/diffusers / remote_decode

Function remote_decode

src/diffusers/utils/remote_utils.py:190–336  ·  view source on GitHub ↗

Hugging Face Hybrid Inference that allow running VAE decode remotely. Args: endpoint (`str`): Endpoint for Remote Decode. tensor (`torch.Tensor`): Tensor to be decoded. processor (`VaeImageProcessor` or `VideoProcessor`, *optional*):

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

Source from the content-addressed store, hash-verified

188
189
190def remote_decode(
191 endpoint: str,
192 tensor: "torch.Tensor",
193 processor: "VaeImageProcessor" | "VideoProcessor" | None = None,
194 do_scaling: bool = True,
195 scaling_factor: float | None = None,
196 shift_factor: float | None = None,
197 output_type: Literal["mp4", "pil", "pt"] = "pil",
198 return_type: Literal["mp4", "pil", "pt"] = "pil",
199 image_format: Literal["png", "jpg"] = "jpg",
200 partial_postprocess: bool = False,
201 input_tensor_type: Literal["binary"] = "binary",
202 output_tensor_type: Literal["binary"] = "binary",
203 height: int | None = None,
204 width: int | None = None,
205) -> Image.Image | list[Image.Image] | bytes | "torch.Tensor":
206 """
207 Hugging Face Hybrid Inference that allow running VAE decode remotely.
208
209 Args:
210 endpoint (`str`):
211 Endpoint for Remote Decode.
212 tensor (`torch.Tensor`):
213 Tensor to be decoded.
214 processor (`VaeImageProcessor` or `VideoProcessor`, *optional*):
215 Used with `return_type="pt"`, and `return_type="pil"` for Video models.
216 do_scaling (`bool`, default `True`, *optional*):
217 **DEPRECATED**. **pass `scaling_factor`/`shift_factor` instead.** **still set
218 do_scaling=None/do_scaling=False for no scaling until option is removed** When `True` scaling e.g. `latents
219 / self.vae.config.scaling_factor` is applied remotely. If `False`, input must be passed with scaling
220 applied.
221 scaling_factor (`float`, *optional*):
222 Scaling is applied when passed e.g. [`latents /
223 self.vae.config.scaling_factor`](https://github.com/huggingface/diffusers/blob/7007febae5cff000d4df9059d9cf35133e8b2ca9/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py#L1083C37-L1083C77).
224 - SD v1: 0.18215
225 - SD XL: 0.13025
226 - Flux: 0.3611
227 If `None`, input must be passed with scaling applied.
228 shift_factor (`float`, *optional*):
229 Shift is applied when passed e.g. `latents + self.vae.config.shift_factor`.
230 - Flux: 0.1159
231 If `None`, input must be passed with scaling applied.
232 output_type (`"mp4"` or `"pil"` or `"pt", default `"pil"):
233 **Endpoint** output type. Subject to change. Report feedback on preferred type.
234
235 `"mp4": Supported by video models. Endpoint returns `bytes` of video. `"pil"`: Supported by image and video
236 models.
237 Image models: Endpoint returns `bytes` of an image in `image_format`. Video models: Endpoint returns
238 `torch.Tensor` with partial `postprocessing` applied.
239 Requires `processor` as a flag (any `None` value will work).
240 `"pt"`: Support by image and video models. Endpoint returns `torch.Tensor`.
241 With `partial_postprocess=True` the tensor is postprocessed `uint8` image tensor.
242
243 Recommendations:
244 `"pt"` with `partial_postprocess=True` is the smallest transfer for full quality. `"pt"` with
245 `partial_postprocess=False` is the most compatible with third party code. `"pil"` with
246 `image_format="jpg"` is the smallest transfer overall.
247

Calls 4

deprecateFunction · 0.85
check_inputs_decodeFunction · 0.85
prepare_decodeFunction · 0.85
postprocess_decodeFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…