Buckets:
| # Inférence à distance | |
| L'inférence distante permet d'accéder à un [Inference Endpoint](https://huggingface.co/docs/inference-endpoints/index) 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]] | |
| ```python | |
| 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](https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/remote_utils.py#L190) | |
| **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`](https://github.com/huggingface/diffusers/blob/7007febae5cff000d4df9059d9cf35133e8b2ca9/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py#L1083C37-L1083C77). - 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 `bytes` of video. `"pil"`: Supported by image and video models. Image models: Endpoint returns `bytes` of an image in `image_format`. Video models: Endpoint returns `torch.Tensor` with partial `postprocessing` applied. Requires `processor` as a flag (any `None` value will work). `"pt"`: Support by image and video models. Endpoint returns `torch.Tensor`. With `partial_postprocess=True` the tensor is postprocessed `uint8` image tensor. Recommendations: `"pt"` with `partial_postprocess=True` is the smallest transfer for full quality. `"pt"` with `partial_postprocess=False` is the most compatible with third party code. `"pil"` with `image_format="jpg"` is the smallest transfer overall. | |
| return_type (`"mp4"` or `"pil"` or `"pt", default `"pil") : **Function** return type. `"mp4": Function returns `bytes` of video. `"pil"`: Function returns `PIL.Image.Image`. With `output_type="pil" no further processing is applied. With `output_type="pt" a `PIL.Image.Image` is created. `partial_postprocess=False` `processor` is required. `partial_postprocess=True` `processor` is **not** required. `"pt"`: Function returns `torch.Tensor`. `processor` is **not** required. `partial_postprocess=False` tensor is `float16` or `bfloat16`, without denormalization. `partial_postprocess=True` tensor is `uint8`, 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]] | |
| ```python | |
| diffusers.utils.remote_utils.remote_encode(endpoint: str, image: 'torch.Tensor' | Image.Image, scaling_factor: float | None = None, shift_factor: float | None = None) | |
| ``` | |
| [Source](https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/remote_utils.py#L382) | |
| **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.