Diffusers documentation

DDIMInverseScheduler

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

DDIMInverseScheduler

DDIMInverseScheduler는 Jiaming Song, Chenlin Meng, Stefano Ermon의 Denoising Diffusion Implicit Models(DDIM)에서 역전된 스케줄러입니다. 구현은 Null-text Inversion for Editing Real Images using Guided Diffusion Models의 DDIM 역전 정의에 주로 기반합니다.

DDIMInverseScheduler

클래스 diffusers.DDIMInverseScheduler

< >

( num_train_timesteps: int = 1000beta_start: float = 0.0001beta_end: float = 0.02beta_schedule: typing.Literal['linear', 'scaled_linear', 'squaredcos_cap_v2'] = 'linear'trained_betas: numpy.ndarray | list[float] | None = Noneclip_sample: bool = Trueset_alpha_to_one: bool = Truesteps_offset: int = 0prediction_type: typing.Literal['epsilon', 'sample', 'v_prediction'] = 'epsilon'clip_sample_range: float = 1.0timestep_spacing: typing.Literal['leading', 'trailing'] = 'leading'rescale_betas_zero_snr: bool = False**kwargs )

매개변수

  • num_train_timesteps (int, 기본값 1000) — 모델을 학습할 때 사용할 diffusion 단계 수입니다.
  • beta_start (float, 기본값 0.0001) — 추론의 시작 beta 값입니다.
  • beta_end (float, 기본값 0.02) — 최종 beta 값입니다.
  • beta_schedule (str, 기본값 "linear") — 모델의 스테핑을 위한 베타 범위에서 베타 시퀀스로의 매핑인 베타 스케줄입니다. linear, scaled_linear, 또는 squaredcos_cap_v2 중 하나를 선택합니다.
  • trained_betas (np.ndarray, 선택 사항) — beta_start와 beta_end를 우회하여 베타 배열을 생성자에 직접 전달합니다.
  • clip_sample (bool, 기본값 True) — 수치적 안정성을 위해 예측된 샘플을 클리핑합니다.
  • clip_sample_range (float, 기본값 1.0) — 샘플 클리핑의 최대 크기입니다. clip_sample=True일 때만 유효합니다.
  • set_alpha_to_one (bool, 기본값 True) — 각 diffusion 단계는 해당 단계와 이전 단계의 alphas 곱 값을 사용합니다. 마지막 단계에는 이전 alpha가 없습니다. 이 옵션이 True이면 이전 alpha 곱 값이 0으로 고정되고, 그렇지 않으면 num_train_timesteps - 1 단계의 alpha 값을 사용합니다.
  • steps_offset (int, 기본값 0) — 일부 모델 계열에서 요구하는 추론 단계에 추가되는 오프셋입니다.
  • prediction_type (str, defaults to epsilon, optional) — Prediction type of the scheduler function; can be epsilon (predicts the noise of the diffusion process), sample (directly predicts the noisy sample) or v_prediction` (see section 2.4 of Imagen Video paper).
  • timestep_spacing (str, 기본값 "leading") — timestep을 스케일링하는 방법입니다. 자세한 내용은 공통 확산 노이즈 스케줄 및 샘플 단계는 결함이 있다의 표 2를 참조하세요.
  • rescale_betas_zero_snr (bool, 기본값 False) — 베타를 재조정하여 최종 SNR을 0으로 만들지 여부를 지정합니다. 이를 통해 중간 밝기의 샘플로 제한되는 대신 매우 밝고 어두운 샘플을 생성할 수 있습니다. --offset_noise와 느슨하게 관련이 있습니다.

DDIMInverseScheduler는 DDIMScheduler의 역 스케줄러입니다.

이 모델은 SchedulerMixin과 ConfigMixin을 상속합니다. 로딩 및 저장과 같은 모든 스케줄러에 대해 라이브러리가 구현하는 일반적 메서드에 대해서는 상위 클래스 문서를 확인하세요.

scale_model_input

< >

( sample: Tensortimestep: int | None = None ) → torch.Tensor

매개변수

  • sample (torch.Tensor) — 입력 샘플입니다.
  • timestep (int, 선택 사항) — 확산 체인에서의 현재 timestep입니다.

반환값

torch.Tensor

스케일된 입력 샘플.

현재 timestep에 따라 denoising 모델 입력을 scale해야 하는 scheduler와의 호환성을 보장합니다.

set_timesteps

< >

( num_inference_steps: intdevice: typing.Union[str, torch.device, NoneType] = None )

매개변수

  • num_inference_steps (int) — 학습된 모델로 샘플을 생성할 때 사용되는 diffusion 단계 수입니다.
  • device (str 또는 torch.device, 선택 사항) — timesteps를 이동할 대상 device입니다. None인 경우 timesteps는 이동되지 않습니다.

추론 실행 전에 실행할 diffusion chain에 사용할 이산 timesteps를 설정합니다.

단계

< >

( model_output: Tensortimestep: intsample: Tensorreturn_dict: bool = True ) → ~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput or tuple

매개변수

  • model_output (torch.Tensor) — 학습된 diffusion 모델의 직접적인 출력입니다.
  • timestep (int) — 확산 체인(diffusion chain)의 현재 이산 시간 단계(discrete timestep)입니다.
  • sample (torch.Tensor) — 확산 과정에 의해 생성된 샘플의 현재 인스턴스입니다.
  • return_dict (bool, 선택 사항, 기본값 True) — ~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput 또는 tuple을 반환할지 여부.

반환값

~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput 또는 tuple

return_dict가 True인 경우 ~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput이 반환되고, 그렇지 않으면 첫 번째 요소가 샘플 텐서인 튜플이 반환됩니다.

이전 시간 단계의 샘플을 SDE를 역방향으로 적용하여 예측합니다. 이 함수는 학습된 모델의 출력(대부분 예측된 노이즈)으로부터 확산 과정을 전파합니다.

Update on GitHub