# 원격 추론

Remote inference는 디코딩 및 인코딩을 위한 로컬 생성 요구 사항을 오프로드하기 위해 [Inference Endpoint](https://huggingface.co/docs/inference-endpoints/index)에 대한 액세스를 제공합니다.

## 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)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/remote_utils.py#L190)

**매개변수:**

endpoint (`str`) : Remote Decode 엔드포인트입니다.

tensor (`torch.Tensor`) : 디코딩할 텐서.

processor (`VaeImageProcessor` 또는 `VideoProcessor`, *선택 사항*) : `return_type="pt"` 및 Video 모델의 `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`](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 `None`인 경우, 스케일링이 적용된 상태로 입력을 전달해야 합니다.

shift_factor (`float`, *선택 사항*) : 전달 시 shift가 적용됩니다. 예: `latents + self.vae.config.shift_factor`. - Flux: 0.1159 `None`인 경우, scaling이 적용된 상태로 입력을 전달해야 합니다.

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"` 또는 `"jpg"`, 기본값 `jpg`) : `output_type="pil"`과 함께 사용됩니다. 엔드포인트는 `jpg` 또는 `png`를 반환합니다.

partial_postprocess (`bool`, 기본값 `False`) : `output_type="pt"`와 함께 사용됩니다. `partial_postprocess=False`인 경우 텐서는 `float16` 또는 `bfloat16`이며, 비정규화(denormalization)되지 않은 상태입니다. `partial_postprocess=True`인 경우 텐서는 `uint8`이며, 비정규화된 상태입니다.

input_tensor_type (`"binary"`, 기본값 `"binary"`) : Tensor 전송 유형.

output_tensor_type (`"binary"`, 기본값 `"binary"`) : Tensor 전송 유형.

height (`int`, **선택 사항**) : `"packed"` latents에 필요합니다.

width (`int`, **선택 사항**) : `"packed"` latents에 필요합니다.

**반환값:**

output (`Image.Image` 또는 `list[Image.Image]` 또는 `bytes` 또는 `torch.Tensor`).

VAE 디코딩을 원격으로 실행할 수 있는 Hugging Face 하이브리드 추론

## 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)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/remote_utils.py#L382)

**매개변수:**

endpoint (`str`) : Remote Decode 엔드포인트입니다.

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`, *선택 사항*) : 전달 시 shift가 적용됩니다. 예: `latents - self.vae.config.shift_factor`. - Flux: 0.1159 `None`인 경우, scaling이 적용된 상태로 입력을 전달해야 합니다.

**반환값:**

output (`torch.Tensor`).

VAE 인코딩을 원격으로 실행할 수 있는 Hugging Face 하이브리드 추론

