Buckets:
| # Consistency Decoder | |
| Consistency decoder는 [StableDiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline)에서 denoising UNet의 latents를 디코딩하는 데 사용할 수 있습니다. 이 decoder는 [DALL-E 3 technical report](https://openai.com/dall-e-3)에서 소개되었습니다. | |
| 원본 코드베이스는 [openai/consistencydecoder](https://github.com/openai/consistencydecoder)에서 찾을 수 있습니다. | |
| > [!WARNING] | |
| > 현재 Inference는 2회 반복만 지원됩니다. | |
| 이 파이프라인은 [이 이슈](https://github.com/openai/consistencydecoder/issues/1)에서 [madebyollin](https://github.com/madebyollin)와 [mrsteyk](https://github.com/mrsteyk)의 도움 없이는 기여할 수 없었습니다. | |
| ## ConsistencyDecoderVAE[[diffusers.ConsistencyDecoderVAE]] | |
| #### diffusers.ConsistencyDecoderVAE[[diffusers.ConsistencyDecoderVAE]] | |
| ```python | |
| diffusers.ConsistencyDecoderVAE(scaling_factor: float = 0.18215, latent_channels: int = 4, sample_size: int = 32, encoder_act_fn: str = 'silu', encoder_block_out_channels: tuple = (128, 256, 512, 512), encoder_double_z: bool = True, encoder_down_block_types: tuple = ('DownEncoderBlock2D', 'DownEncoderBlock2D', 'DownEncoderBlock2D', 'DownEncoderBlock2D'), encoder_in_channels: int = 3, encoder_layers_per_block: int = 2, encoder_norm_num_groups: int = 32, encoder_out_channels: int = 4, decoder_add_attention: bool = False, decoder_block_out_channels: tuple = (320, 640, 1024, 1024), decoder_down_block_types: tuple = ('ResnetDownsampleBlock2D', 'ResnetDownsampleBlock2D', 'ResnetDownsampleBlock2D', 'ResnetDownsampleBlock2D'), decoder_downsample_padding: int = 1, decoder_in_channels: int = 7, decoder_layers_per_block: int = 3, decoder_norm_eps: float = 1e-05, decoder_norm_num_groups: int = 32, decoder_num_train_timesteps: int = 1024, decoder_out_channels: int = 6, decoder_resnet_time_scale_shift: str = 'scale_shift', decoder_time_embedding_type: str = 'learned', decoder_up_block_types: tuple = ('ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D')) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L51) | |
| DALL-E 3과 함께 사용되는 일관성 디코더입니다. | |
| 예: | |
| ```py | |
| >>> import torch | |
| >>> from diffusers import StableDiffusionPipeline, ConsistencyDecoderVAE | |
| >>> vae = ConsistencyDecoderVAE.from_pretrained("openai/consistency-decoder", torch_dtype=torch.float16) | |
| >>> pipe = StableDiffusionPipeline.from_pretrained( | |
| ... "stable-diffusion-v1-5/stable-diffusion-v1-5", vae=vae, torch_dtype=torch.float16 | |
| ... ).to("cuda") | |
| >>> image = pipe("horse", generator=torch.manual_seed(0)).images[0] | |
| >>> image | |
| ``` | |
| #### decode[[diffusers.ConsistencyDecoderVAE.decode]] | |
| ```python | |
| decode(z: Tensor, generator: typing.Optional[torch.Generator] = None, return_dict: bool = True, num_inference_steps: int = 2) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L220) | |
| **매개변수:** | |
| z (torch.Tensor) : 입력 잠재 벡터. | |
| generator (torch.Generator | None) : 난수 생성기. 기본값은 None입니다. | |
| return_dict (bool) : 출력을 딕셔너리로 반환할지 여부. 기본값은 True입니다. | |
| num_inference_steps (int) : 추론 단계 수. 기본값은 2입니다. | |
| **반환값:** DecoderOutput | tuple[torch.Tensor] | |
| 복호화된 출력. | |
| consistency decoder VAE 모델을 사용하여 입력 잠재 벡터 `z`를 디코딩합니다. | |
| #### encode[[diffusers.ConsistencyDecoderVAE.encode]] | |
| ```python | |
| encode(x: Tensor, return_dict: bool = True) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L185) | |
| **매개변수:** | |
| x (`torch.Tensor`) : 입력 이미지 배치. | |
| return_dict (`bool`, *선택 사항*, 기본값 `True`) : 일반 튜플 대신 `ConsistencyDecoderVAEOutput`을 반환할지 여부. | |
| **반환값:** | |
| 인코딩된 이미지의 잠재 표현입니다. `return_dict`가 True이면 `ConsistencyDecoderVAEOutput`이 반환되고, 그렇지 않으면 일반 `tuple`이 반환됩니다. | |
| 이미지 배치(latents)를 인코딩합니다. | |
| #### forward[[diffusers.ConsistencyDecoderVAE.forward]] | |
| ```python | |
| forward(sample: Tensor, sample_posterior: bool = False, return_dict: bool = True, generator: typing.Optional[torch.Generator] = None) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L336) | |
| **매개변수:** | |
| sample (`torch.Tensor`) : 입력 샘플. | |
| sample_posterior (`bool`, *선택 사항*, 기본값 `False`) : 사후 분포에서 샘플링할지 여부. | |
| return_dict (`bool`, *선택 사항*, 기본값 `True`) : 일반 튜플 대신 `DecoderOutput`를 반환할지 여부. | |
| generator (`torch.Generator`, *선택 사항*, 기본값 `None`) : 샘플링에 사용할 Generator입니다. | |
| **반환값:** `DecoderOutput` 또는 `tuple` | |
| return_dict가 True이면 `DecoderOutput`가 반환되고, 그렇지 않으면 일반 `tuple`이 반환됩니다. | |
| #### set_default_attn_processor[[diffusers.ConsistencyDecoderVAE.set_default_attn_processor]] | |
| ```python | |
| set_default_attn_processor() | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L170) | |
| 커스텀 어텐션 프로세서를 비활성화하고 기본 어텐션 구현을 설정합니다. | |
| #### tiled_encode[[diffusers.ConsistencyDecoderVAE.tiled_encode]] | |
| ```python | |
| tiled_encode(x: Tensor, return_dict: bool = True) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L281) | |
| **매개변수:** | |
| x (`torch.Tensor`) : 입력 이미지 배치. | |
| return_dict (`bool`, *선택 사항*, 기본값 `True`) : `ConsistencyDecoderVAEOutput`을 반환할지, 아니면 일반 튜플을 반환할지를 결정합니다. | |
| **반환값:** `ConsistencyDecoderVAEOutput` 또는 `tuple` | |
| return_dict가 True이면 `ConsistencyDecoderVAEOutput`이 반환되고, 그렇지 않으면 일반 `tuple`이 반환됩니다. | |
| 타일 인코더를 사용하여 이미지 배치 인코딩 | |
| 이 옵션이 활성화되면 VAE는 입력 텐서를 타일로 분할하여 여러 단계에 걸쳐 인코딩을 계산합니다. 이는 이미지 크기와 관계없이 메모리 사용량을 일정하게 유지하는 데 유용합니다. 타일 인코딩의 최종 결과는 타일별 인코더가 다르기 때문에 타일링되지 않은 인코딩과 다릅니다. 타일링 아티팩트를 방지하기 위해 타일들은 겹쳐지고 블렌딩되어 매끄러운 출력을 형성합니다. 출력에서 여전히 타일 크기의 변화가 보일 수 있지만, 훨씬 덜 눈에 띄어야 합니다. | |
Xet Storage Details
- Size:
- 6.9 kB
- Xet hash:
- c7805df1d35a25355bb5f2cceed12493674424ca56fb4e2c22e3657996c0dc34
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.