Diffusers documentation
DDIMInverseScheduler
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
< source >( 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 toepsilon, optional) — Prediction type of the scheduler function; can beepsilon(predicts the noise of the diffusion process),sample(directly predicts the noisy sample) orv_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
< source >( sample: Tensortimestep: int | None = None ) → torch.Tensor
현재 timestep에 따라 denoising 모델 입력을 scale해야 하는 scheduler와의 호환성을 보장합니다.
set_timesteps
< source >( num_inference_steps: intdevice: typing.Union[str, torch.device, NoneType] = None )
추론 실행 전에 실행할 diffusion chain에 사용할 이산 timesteps를 설정합니다.
단계
< source >( 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를 역방향으로 적용하여 예측합니다. 이 함수는 학습된 모델의 출력(대부분 예측된 노이즈)으로부터 확산 과정을 전파합니다.