Diffusers documentation
Hybrid Inference API Reference
Hybrid Inference API Reference
Remote Decode
diffusers.utils.remote_decode
< source >( 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 )
Parameters
- endpoint (
str
) — Endpoint for Remote Decode. - tensor (
torch.Tensor
) — Tensor to be decoded. - processor (
VaeImageProcessor
orVideoProcessor
, optional) — Used withreturn_type="pt"
, andreturn_type="pil"
for Video models. - do_scaling (
bool
, defaultTrue
, optional) — DEPRECATED. passscaling_factor
/shift_factor
instead. still set do_scaling=None/do_scaling=False for no scaling until option is removed WhenTrue
scaling e.g.latents / self.vae.config.scaling_factor
is applied remotely. IfFalse
, input must be passed with scaling applied. - scaling_factor (
float
, optional) — Scaling is applied when passed e.g.latents / self.vae.config.scaling_factor
.- SD v1: 0.18215
- SD XL: 0.13025
- Flux: 0.3611
If
None
, input must be passed with scaling applied.
- shift_factor (
float
, optional) — Shift is applied when passed e.g.latents + self.vae.config.shift_factor
.- Flux: 0.1159
If
None
, input must be passed with scaling applied.
- Flux: 0.1159
If
- output_type (
"mp4"
or"pil"
or"pt", default
“pil”) — Endpoint output type. Subject to change. Report feedback on preferred type."mp4": Supported by video models. Endpoint returns
bytesof video.
“pil”: Supported by image and video models. Image models: Endpoint returns
bytesof an image in
image_format. Video models: Endpoint returns
torch.Tensorwith partial
postprocessingapplied. Requires
processoras a flag (any
Nonevalue will work).
“pt”: Support by image and video models. Endpoint returns
torch.Tensor. With
partial_postprocess=Truethe tensor is postprocessed
uint8` image tensor.Recommendations:
"pt"
withpartial_postprocess=True
is the smallest transfer for full quality."pt"
withpartial_postprocess=False
is the most compatible with third party code."pil"
withimage_format="jpg"
is the smallest transfer overall. - return_type (
"mp4"
or"pil"
or"pt", default
“pil”) — Function return type."mp4": Function returns
bytesof video.
“pil”: Function returns
PIL.Image.Image. With
output_type=“pil” no further processing is applied. Withoutput_type="pt" a
PIL.Image.Imageis created.
partial_postprocess=Falseis required.
partial_postprocess=Trueis **not** required.
“pt”: Function returns
torch.Tensor.
processoris **not** required.
partial_postprocess=Falsetensor is
float16or
bfloat16, without denormalization.
partial_postprocess=Truetensor is
uint8`, denormalized. - image_format (
"png"
or"jpg"
, defaultjpg
) — Used withoutput_type="pil"
. Endpoint returnsjpg
orpng
. - partial_postprocess (
bool
, defaultFalse
) — Used withoutput_type="pt"
.partial_postprocess=False
tensor isfloat16
orbfloat16
, without denormalization.partial_postprocess=True
tensor isuint8
, denormalized. - input_tensor_type (
"binary"
, default"binary"
) — Tensor transfer type. - output_tensor_type (
"binary"
, default"binary"
) — Tensor transfer type. - height (
int
, optional) — Required for"packed"
latents. - width (
int
, optional) — Required for"packed"
latents.
Hugging Face Hybrid Inference that allow running VAE decode remotely.