Diffusers documentation
Suy luận từ xa
Suy luận từ xa
Remote inference cung cấp quyền truy cập vào Inference Endpoint để chuyển tải các yêu cầu tạo cục bộ cho việc giải mã và mã hóa.
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 )
Tham số
- endpoint (
str) — Endpoint cho Remote Decode. - tensor (
torch.Tensor) — Tensor cần giải mã. - processor (
VaeImageProcessorhoặcVideoProcessor, tùy chọn) — Được sử dụng vớireturn_type="pt", vàreturn_type="pil"cho các mô hình Video. - do_scaling (
bool, mặc địnhTrue, tùy chọn) — ĐÃ BỊ LỖI THỜI. hãy truyềnscaling_factor/shift_factorthay thế. vẫn đặt do_scaling=None/do_scaling=False để không áp dụng scaling cho đến khi tùy chọn này bị loại bỏ KhiTrue, scaling, ví dụlatents / self.vae.config.scaling_factor, sẽ được áp dụng từ xa. NếuFalse, đầu vào phải được truyền với scaling đã được áp dụng. - scaling_factor (
float, tuỳ chọn) — Việc mở rộng (scaling) được áp dụng khi được truyền vào, ví dụlatents / self.vae.config.scaling_factor.- SD v1: 0.18215
- SD XL: 0.13025
- Flux: 0.3611
Nếu là
None, đầu vào phải được truyền với việc áp dụng tỷ lệ.
- shift_factor (
float, tuỳ chọn) — Shift được áp dụng khi được truyền vào, ví dụlatents + self.vae.config.shift_factor.- Flux: 0.1159
Nếu là
None, đầu vào phải được truyền với việc áp dụng tỷ lệ.
- Flux: 0.1159
Nếu là
- output_type (
"mp4"hoặc"pil"hoặc"pt", default“) — Loại đầu ra của Endpoint Có thể thay đổi. Vui lòng phản hồi về loại đầu ra bạn ưu tiên."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.Khuyến nghị:
"pt"vớipartial_postprocess=Truelà phương thức truyền tải nhỏ nhất cho chất lượng đầy đủ."pt"vớipartial_postprocess=Falselà phương thức tương thích nhất với mã bên thứ ba."pil"vớiimage_format="jpg"là phương thức truyền tải nhỏ nhất tổng thể. - return_type (
"mp4"hoặc"pil"hoặc"pt", default“) — Loại trả về của hàm."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"hoặc"jpg", mặc địnhjpg) — Được sử dụng cùng vớioutput_type="pil". Endpoint trả vềjpghoặcpng. - partial_postprocess (
bool, mặc địnhFalse) — Dùng vớioutput_type="pt". Tensorpartial_postprocess=Falselàfloat16hoặcbfloat16, không được chuẩn hóa lại. Tensorpartial_postprocess=Truelàuint8, đã được chuẩn hóa lại. - input_tensor_type (
"binary", mặc định"binary") — Loại chuyển tensor. - output_tensor_type (
"binary", mặc định"binary") — Loại chuyển tensor. - height (
int, tùy chọn) — Bắt buộc đối với latents"packed". - width (
int, tùy chọn) — Bắt buộc đối với latents"packed".
Hugging Face Hybrid Inference cho phép chạy VAE decode từ xa.
remote_encode
diffusers.utils.remote_utils.remote_encode
< source >( endpoint: strimage: 'torch.Tensor' | Image.Imagescaling_factor: float | None = Noneshift_factor: float | None = None )
Tham số
- endpoint (
str) — Endpoint cho Remote Decode. - image (
torch.TensorhoặcPIL.Image.Image) — Hình ảnh cần được mã hóa. - scaling_factor (
float, tuỳ chọn) — Thao tác scale được áp dụng khi được truyền vào, ví dụlatents * self.vae.config.scaling_factor.- SD v1: 0.18215
- SD XL: 0.13025
- Flux: 0.3611
Nếu là
None, đầu vào phải được truyền với việc áp dụng tỷ lệ.
- shift_factor (
float, tuỳ chọn) — Shift được áp dụng khi được truyền vào, ví dụlatents - self.vae.config.shift_factor.- Flux: 0.1159
Nếu là
None, đầu vào phải được truyền với việc áp dụng tỷ lệ.
- Flux: 0.1159
Nếu là
Hugging Face Hybrid Inference cho phép chạy VAE encode từ xa.