Buckets:

mishig's picture
|
download
raw
6.16 kB

Inférence à distance

L'inférence distante permet d'accéder à un Inference Endpoint afin de décharger les besoins locaux de génération pour le décodage et l'encodage.

remote_decode[[diffusers.utils.remote_decode]]

diffusers.utils.remote_decode[[diffusers.utils.remote_decode]]

diffusers.utils.remote_decode(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

Paramètres :

endpoint (str) : Point de terminaison pour le décodage distant.

tensor (torch.Tensor) : Tenseur à décoder.

processor (VaeImageProcessor ou VideoProcessor, facultatif) : Utilisé avec return_type="pt", et return_type="pil" pour les modèles vidéo.

do_scaling (bool, par défaut True, facultatif) : DÉPRÉCIÉ. passer scaling_factor/shift_factor à la place. continuer à définir do_scaling=None/do_scaling=False pour ne pas appliquer de mise à l'échelle jusqu'à ce que l'option soit supprimée Si True, la mise à l'échelle, par exemple latents / self.vae.config.scaling_factor, est appliquée à distance. Si False, l'entrée doit être transmise avec la mise à l'échelle déjà appliquée.

scaling_factor (float, facultatif) : Le facteur d'échelle est appliqué lorsqu'il est transmis, par exemple latents / self.vae.config.scaling_factor. - SD v1 : 0.18215 - SD XL : 0.13025 - Flux : 0.3611 Si None, l'entrée doit être transmise avec l'échelle déjà appliquée.

shift_factor (float, facultatif) : Le décalage est appliqué lorsqu'il est transmis, par exemple latents + self.vae.config.shift_factor. - Flux : 0,1159 Si None, l'entrée doit être transmise avec le mise à l'échelle appliquée.

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 inimage_format. Video models: Endpoint returns torch.Tensorwith partialpostprocessingapplied. Requiresprocessoras a flag (anyNonevalue will work)."pt": Support by image and video models. Endpoint returns torch.Tensor. With partial_postprocess=Truethe tensor is postprocesseduint8image tensor. Recommendations:"pt"withpartial_postprocess=Trueis the smallest transfer for full quality."pt"withpartial_postprocess=Falseis 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. With output_type="pt" a PIL.Image.Imageis created.partial_postprocess=False processoris required.partial_postprocess=True processoris **not** required."pt": Function returns torch.Tensor. processoris **not** required.partial_postprocess=Falsetensor isfloat16orbfloat16, without denormalization. partial_postprocess=Truetensor isuint8`, denormalized.

image_format ("png" ou "jpg", par défaut jpg) : Utilisé avec output_type="pil". Le point de terminaison renvoie jpg ou png.

partial_postprocess (bool, par défaut False) : Utilisé avec output_type="pt". partial_postprocess=False le tenseur est en float16 ou bfloat16, sans dénormalisation. partial_postprocess=True le tenseur est en uint8, dénormalisé.

input_tensor_type ("binary", par défaut "binary") : Type de transfert de tenseur.

output_tensor_type ("binary", par défaut "binary") : Type de transfert de tenseur.

height (int, facultatif) : Requis pour les latents "packed".

width (int, facultatif) : Requis pour les latents "packed".

Retourne :

output (Image.Image ou list[Image.Image] ou bytes ou torch.Tensor).

Hugging Face Hybrid Inference, qui permet d’exécuter le décodage VAE à distance.

remote_encode[[diffusers.utils.remote_utils.remote_encode]]

diffusers.utils.remote_utils.remote_encode[[diffusers.utils.remote_utils.remote_encode]]

diffusers.utils.remote_utils.remote_encode(endpoint: str, image: 'torch.Tensor' | Image.Image, scaling_factor: float | None = None, shift_factor: float | None = None)

Source

Paramètres :

endpoint (str) : Point de terminaison pour le décodage distant.

image (torch.Tensor ou PIL.Image.Image) : Image à encoder.

scaling_factor (float, facultatif) : Le facteur d'échelle est appliqué lorsqu'il est transmis, par exemple latents * self.vae.config.scaling_factor. - SD v1 : 0.18215 - SD XL : 0.13025 - Flux : 0.3611 Si None, l'entrée doit être transmise avec l'échelle déjà appliquée.

shift_factor (float, facultatif) : Le décalage est appliqué lorsqu'il est transmis, par exemple latents - self.vae.config.shift_factor. - Flux : 0,1159 Si None, l'entrée doit être transmise avec le mise à l'échelle appliquée.

Retourne :

output (torch.Tensor).

Hugging Face Hybrid Inference, qui permet d’exécuter l’encodage VAE à distance.

Xet Storage Details

Size:
6.16 kB
·
Xet hash:
65fa1015c0cdeac7b2dd40566cafd698140d6029503c9288c6abefc2c1c9c703

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.