원격 추론
Remote inference는 디코딩 및 인코딩을 위한 로컬 생성 요구 사항을 오프로드하기 위해 Inference Endpoint에 대한 액세스를 제공합니다.
remote_decode
diffusers.utils.remote_decode
< source >( endpoint: strtensor: 'torch.Tensor'processor: 'VaeImageProcessor' | 'VideoProcessor' | None = Nonedo_scaling: bool = Truescaling_factor: float | None = Noneshift_factor: float | None = Noneoutput_type: Literal['mp4', 'pil', 'pt'] = 'pil'return_type: Literal['mp4', 'pil', 'pt'] = 'pil'image_format: Literal['png', 'jpg'] = 'jpg'partial_postprocess: bool = Falseinput_tensor_type: Literal['binary'] = 'binary'output_tensor_type: Literal['binary'] = 'binary'height: int | None = Nonewidth: int | None = None )
매개변수
- endpoint (
str) — Remote Decode를 위한 Endpoint입니다. - 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.- 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인 경우, 스케일링이 적용된 상태로 입력을 전달해야 합니다.
- Flux: 0.1159
- output_type (
"mp4"또는"pil"또는"pt", default“) — 엔드포인트 출력 형식. 변경될 수 있습니다. 선호하는 형식에 대한 피드백을 보고해 주세요."mp4": Supported by video models. Endpoint returnsbytesof video.“pil”: Supported by image and video models. Image models: Endpoint returnsbytesof an image inimage_format. Video models: Endpoint returnstorch.Tensorwith partialpostprocessingapplied. Requiresprocessoras a flag (anyNonevalue will work).“pt”: Support by image and video models. Endpoint returnstorch.Tensor. Withpartial_postprocess=Truethe tensor is postprocesseduint8` image tensor.권장 사항:
"pt"에partial_postprocess=True를 사용하는 것이 전체 품질을 유지하면서 가장 작은 전송 크기입니다."pt"에partial_postprocess=False를 사용하는 것이 서드파티 코드와의 호환성이 가장 좋습니다."pil"에image_format="jpg"를 사용하는 것이 전반적으로 가장 작은 전송 크기입니다. - return_type (
"mp4"또는"pil"또는"pt", default“) — 함수의 반환 타입입니다."mp4": Function returnsbytesof video.“pil”: Function returnsPIL.Image.Image. Withoutput_type=“pil” no further processing is applied. Withoutput_type="pt" aPIL.Image.Imageis created.partial_postprocess=Falseprocessoris required.partial_postprocess=Trueprocessoris **not** required.“pt”: Function returnstorch.Tensor.processoris **not** required.partial_postprocess=Falsetensor isfloat16orbfloat16, without denormalization.partial_postprocess=Truetensor isuint8`, 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에 필수입니다.
VAE 디코딩을 원격으로 실행할 수 있는 Hugging Face 하이브리드 추론
remote_encode
diffusers.utils.remote_utils.remote_encode
< source >( endpoint: strimage: 'torch.Tensor' | Image.Imagescaling_factor: float | None = Noneshift_factor: float | None = None )
매개변수
- endpoint (
str) — Remote Decode를 위한 Endpoint입니다. - 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인 경우, 스케일링이 적용된 상태로 입력을 전달해야 합니다.
- Flux: 0.1159
VAE 인코딩을 원격으로 실행할 수 있는 Hugging Face 하이브리드 추론