Diffusers documentation

원격 추론

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

원격 추론

Remote inference는 디코딩 및 인코딩을 위한 로컬 생성 요구 사항을 오프로드하기 위해 Inference Endpoint에 대한 액세스를 제공합니다.

remote_decode

diffusers.utils.remote_decode

< >

( 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인 경우, 스케일링이 적용된 상태로 입력을 전달해야 합니다.
  • output_type ("mp4" 또는 "pil" 또는 "pt", default “) — 엔드포인트 출력 형식. 변경될 수 있습니다. 선호하는 형식에 대한 피드백을 보고해 주세요.

    "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 postprocesseduint8` image tensor.

    권장 사항: "pt"에 partial_postprocess=True를 사용하는 것이 전체 품질을 유지하면서 가장 작은 전송 크기입니다. "pt"에 partial_postprocess=False를 사용하는 것이 서드파티 코드와의 호환성이 가장 좋습니다. "pil"에 image_format="jpg"를 사용하는 것이 전반적으로 가장 작은 전송 크기입니다.

  • return_type ("mp4" 또는 "pil" 또는 "pt", default “) — 함수의 반환 타입입니다.

    "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" 또는 "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

< >

( 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인 경우, 스케일링이 적용된 상태로 입력을 전달해야 합니다.

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

Update on GitHub