Buckets:
| # AutoencoderDC | |
| [SANA](https://huggingface.co/papers/2410.10629)에서 사용되고, MIT HAN Lab의 Junyu Chen\*, Han Cai\*, Junsong Chen, Enze Xie, Shang Yang, Haotian Tang, Muyang Li, Yao Lu, Song Han 저자가 [DCAE](https://huggingface.co/papers/2410.10733)에서 소개한 2D Autoencoder 모델입니다. | |
| 해당 논문의 초록은 다음과 같습니다: | |
| *저해상도 확산 모델의 추론 속도를 높이기 위한 새로운 오토인코더 모델 계열인 Deep Compression Autoencoder(DC-AE)를 소개합니다. 기존 오토인코더 모델은 중간 수준의 공간 압축 비율(예: 8x)에서 인상적인 결과를 보여주었지만, 높은 공간 압축 비율(예: 64x)에서는 만족스러운 재구성 정확도를 유지하지 못했습니다. 우리는 두 가지 핵심 기술을 도입하여 이 문제를 해결했습니다. (1) Residual Autoencoding: space-to-channel 변환된 특징을 기반으로 잔차를 학습하도록 모델을 설계하여, 높은 공간 압축을 가진 오토인코더의 최적화 난이도를 완화합니다. (2) Decoupled High-Resolution Adaptation: 높은 공간 압축을 가진 오토인코더의 일반화 페널티를 완화하기 위한 효율적인 분리형 3단계 학습 전략입니다. 이러한 설계를 통해 재구성 품질을 유지하면서 오토인코더의 공간 압축 비율을 최대 128까지 향상시켰습니다. DC-AE를 잠재 공간 확산 모델에 적용하면 정확도 저하 없이 상당한 속도 향상을 달성할 수 있습니다. 예를 들어, ImageNet 512x512에서 널리 사용되는 SD-VAE-f8 오토인코더와 비교할 때, H100 GPU에서 UViT-H에 대해 19.1배의 추론 속도 향상과 17.9배의 학습 속도 향상을 제공하면서 더 나은 FID를 달성했습니다. 코드는 [이 https URL](https://github.com/mit-han-lab/efficientvit)에서 사용할 수 있습니다.* | |
| 다음 DCAE 모델들은 Diffusers에서 릴리스되고 지원됩니다. | |
| | Diffusers 형식 | 원본 형식 | | |
| |:----------------:|:---------------:| | |
| | [`mit-han-lab/dc-ae-f32c32-sana-1.0-diffusers`](https://huggingface.co/mit-han-lab/dc-ae-f32c32-sana-1.0-diffusers) | [`mit-han-lab/dc-ae-f32c32-sana-1.0`](https://huggingface.co/mit-han-lab/dc-ae-f32c32-sana-1.0) | |
| | [`mit-han-lab/dc-ae-f32c32-in-1.0-diffusers`](https://huggingface.co/mit-han-lab/dc-ae-f32c32-in-1.0-diffusers) | [`mit-han-lab/dc-ae-f32c32-in-1.0`](https://huggingface.co/mit-han-lab/dc-ae-f32c32-in-1.0) | |
| | [`mit-han-lab/dc-ae-f32c32-mix-1.0-diffusers`](https://huggingface.co/mit-han-lab/dc-ae-f32c32-mix-1.0-diffusers) | [`mit-han-lab/dc-ae-f32c32-mix-1.0`](https://huggingface.co/mit-han-lab/dc-ae-f32c32-mix-1.0) | |
| | [`mit-han-lab/dc-ae-f64c128-in-1.0-diffusers`](https://huggingface.co/mit-han-lab/dc-ae-f64c128-in-1.0-diffusers) | [`mit-han-lab/dc-ae-f64c128-in-1.0`](https://huggingface.co/mit-han-lab/dc-ae-f64c128-in-1.0) | |
| | [`mit-han-lab/dc-ae-f64c128-mix-1.0-diffusers`](https://huggingface.co/mit-han-lab/dc-ae-f64c128-mix-1.0-diffusers) | [`mit-han-lab/dc-ae-f64c128-mix-1.0`](https://huggingface.co/mit-han-lab/dc-ae-f64c128-mix-1.0) | |
| | [`mit-han-lab/dc-ae-f128c512-in-1.0-diffusers`](https://huggingface.co/mit-han-lab/dc-ae-f128c512-in-1.0-diffusers) | [`mit-han-lab/dc-ae-f128c512-in-1.0`](https://huggingface.co/mit-han-lab/dc-ae-f128c512-in-1.0) | |
| | [`mit-han-lab/dc-ae-f128c512-mix-1.0-diffusers`](https://huggingface.co/mit-han-lab/dc-ae-f128c512-mix-1.0-diffusers) | [`mit-han-lab/dc-ae-f128c512-mix-1.0`](https://huggingface.co/mit-han-lab/dc-ae-f128c512-mix-1.0) | |
| 이 모델은 [lawrence-cj](https://github.com/lawrence-cj)님이 기여했습니다. | |
| [from_pretrained()](/docs/diffusers/main/ko/api/models/overview#diffusers.ModelMixin.from_pretrained)로 Diffusers 형식의 모델을 로드합니다. | |
| ```python | |
| from diffusers import AutoencoderDC | |
| ae = AutoencoderDC.from_pretrained("mit-han-lab/dc-ae-f32c32-sana-1.0-diffusers", dtype=torch.float32).to("cuda") # or "mps", "xpu", "cpu" | |
| ``` | |
| ## Diffusers에서 `from_single_file`를 통해 모델을 로드합니다 | |
| ```python | |
| from difusers import AutoencoderDC | |
| ckpt_path = "https://huggingface.co/mit-han-lab/dc-ae-f32c32-sana-1.0/blob/main/model.safetensors" | |
| model = AutoencoderDC.from_single_file(ckpt_path) | |
| ``` | |
| `AutoencoderDC` 모델에는 체크포인트 키가 일치하지만 다른 스케일링 인자를 사용하는 `in` 및 `mix` 단일 파일 체크포인트 변형이 있습니다. Diffusers는 체크포인트만으로 모델에 사용할 올바른 config 파일을 자동으로 추론할 수 없으며, 기본적으로 `mix` 변형의 config 파일을 사용하여 모델을 구성합니다. 자동으로 결정된 config를 오버라이드하려면, `in` 변형의 체크포인트로 단일 파일 로딩을 사용할 때 `config` 인자를 사용하십시오. | |
| ```python | |
| from diffusers import AutoencoderDC | |
| ckpt_path = "https://huggingface.co/mit-han-lab/dc-ae-f128c512-in-1.0/blob/main/model.safetensors" | |
| model = AutoencoderDC.from_single_file(ckpt_path, config="mit-han-lab/dc-ae-f128c512-in-1.0-diffusers") | |
| ``` | |
| ## AutoencoderDC[[diffusers.AutoencoderDC]] | |
| #### diffusers.AutoencoderDC[[diffusers.AutoencoderDC]] | |
| ```python | |
| diffusers.AutoencoderDC(in_channels: int = 3, latent_channels: int = 32, attention_head_dim: int = 32, encoder_block_types: str | tuple[str] = 'ResBlock', decoder_block_types: str | tuple[str] = 'ResBlock', encoder_block_out_channels: tuple = (128, 256, 512, 512, 1024, 1024), decoder_block_out_channels: tuple = (128, 256, 512, 512, 1024, 1024), encoder_layers_per_block: tuple = (2, 2, 2, 3, 3, 3), decoder_layers_per_block: tuple = (3, 3, 3, 3, 3, 3), encoder_qkv_multiscales: tuple = ((), (), (), (5,), (5,), (5,)), decoder_qkv_multiscales: tuple = ((), (), (), (5,), (5,), (5,)), upsample_block_type: str = 'pixel_shuffle', downsample_block_type: str = 'pixel_unshuffle', decoder_norm_types: str | tuple[str] = 'rms_norm', decoder_act_fns: str | tuple[str] = 'silu', encoder_out_shortcut: bool = True, decoder_in_shortcut: bool = True, decoder_conv_act_fn: str = 'relu', scaling_factor: float = 1.0) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_dc.py#L380) | |
| **매개변수:** | |
| in_channels (`int`, 기본값 `3`) : 샘플의 입력 채널 수입니다. | |
| latent_channels (`int`, 기본값 `32`) : 잠재 공간 표현의 채널 수입니다. | |
| encoder_block_types (`str | tuple[str]`, 기본값 `"ResBlock"`) : 인코더에 사용할 블록의 유형입니다. | |
| decoder_block_types (`str | tuple[str]`, 기본값 `"ResBlock"`) : 디코더에 사용할 블록의 유형입니다. | |
| encoder_block_out_channels (`tuple[int, ...]`, 기본값 `(128, 256, 512, 512, 1024, 1024)`) : 인코더의 각 블록에 대한 출력 채널 수입니다. | |
| decoder_block_out_channels (`tuple[int, ...]`, 기본값 `(128, 256, 512, 512, 1024, 1024)`) : 디코더의 각 블록에 대한 출력 채널 수입니다. | |
| encoder_layers_per_block (`tuple[int]`, 기본값 `(2, 2, 2, 3, 3, 3)`) : 인코더의 블록당 레이어 수입니다. | |
| decoder_layers_per_block (`tuple[int]`, 기본값 `(3, 3, 3, 3, 3, 3)`) : 디코더의 블록당 레이어 수입니다. | |
| encoder_qkv_multiscales (`tuple[tuple[int, ...], ...]`, 기본값은 `((), (), (), (5,), (5,), (5,))`) : 인코더의 QKV(쿼리-키-값) 변환을 위한 멀티스케일 구성입니다. | |
| decoder_qkv_multiscales (`tuple[tuple[int, ...], ...]`, 기본값은 `((), (), (), (5,), (5,), (5,))`) : 디코더의 QKV(쿼리-키-값) 변환을 위한 멀티스케일 구성입니다. | |
| upsample_block_type (`str`, 기본값 `"pixel_shuffle"`) : 디코더에서 업샘플링에 사용할 블록의 유형입니다. | |
| downsample_block_type (`str`, 기본값 `"pixel_unshuffle"`) : 인코더에서 다운샘플링에 사용할 블록의 유형입니다. | |
| decoder_norm_types (`str | tuple[str]`, 기본값 `"rms_norm"`) : 디코더에서 사용할 정규화 유형입니다. | |
| decoder_act_fns (`str | tuple[str]`, 기본값 `"silu"`) : 디코더에 사용할 활성화 함수입니다. | |
| encoder_out_shortcut (`bool`, 기본값 `True`) : 인코더의 끝에 shortcut을 사용할지 여부. | |
| decoder_in_shortcut (`bool`, 기본값 `True`) : 디코더의 시작 부분에 shortcut을 사용할지 여부. | |
| decoder_conv_act_fn (`str`, 기본값 `"relu"`) : 디코더의 끝에 사용할 활성화 함수입니다. | |
| scaling_factor (`float`, 기본값 `1.0`) : 잠재 특징의 제곱근 평균 제곱(RMS)의 역수입니다. 이는 diffusion model을 학습할 때 잠재 공간의 분산을 1로 스케일링하는 데 사용됩니다. 잠재 변수는 diffusion model로 전달되기 전에 `z = z * scaling_factor` 공식으로 스케일링됩니다. 디코딩 시에는 `z = 1 / scaling_factor * z` 공식을 사용하여 잠재 변수를 원래의 스케일로 되돌립니다. | |
| [DCAE](https://huggingface.co/papers/2410.10733)에서 소개되고 [SANA](https://huggingface.co/papers/2410.10629)에서 사용되는 Autoencoder 모델입니다. | |
| 이 모델은 [ModelMixin](/docs/diffusers/main/ko/api/models/overview#diffusers.ModelMixin)에서 상속됩니다. 모든 모델에 대해 구현된 일반적 메서드(다운로드 또는 저장 등)에 대해서는 상위 클래스 문서를 확인하세요. | |
| #### encode[[diffusers.AutoencoderDC.encode]] | |
| ```python | |
| encode(x: Tensor, return_dict: bool = True) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_dc.py#L548) | |
| **매개변수:** | |
| x (`torch.Tensor`) : 입력 이미지 배치. | |
| return_dict (`bool`, 기본값 `True`) : 일반 튜플 대신 `~models.vae.EncoderOutput`를 반환할지 여부. | |
| **반환값:** | |
| 인코딩된 비디오의 잠재 표현입니다. `return_dict`가 True이면 `~models.vae.EncoderOutput`이 반환되고, 그렇지 않으면 일반 `tuple`이 반환됩니다. | |
| 이미지 배치(latents)를 인코딩합니다. | |
| #### decode[[diffusers.AutoencoderDC.decode]] | |
| ```python | |
| decode(z: Tensor, return_dict: bool = True) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_dc.py#L582) | |
| **매개변수:** | |
| z (`torch.Tensor`) : 잠재 벡터의 입력 배치. | |
| return_dict (`bool`, 기본값 `True`) : 일반 튜플 대신 `~models.vae.DecoderOutput`를 반환할지 여부. | |
| **반환값:** `~models.vae.DecoderOutput` 또는 `tuple` | |
| return_dict가 True이면 `~models.vae.DecoderOutput`가 반환되고, 그렇지 않으면 일반 `tuple`이 반환됩니다. | |
| 이미지 배치(decode)를 디코딩합니다. | |
| #### enable_tiling[[diffusers.AutoencoderDC.enable_tiling]] | |
| ```python | |
| enable_tiling(tile_sample_min_height: int | None = None, tile_sample_min_width: int | None = None, tile_sample_stride_height: float | None = None, tile_sample_stride_width: float | None = None) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_dc.py#L506) | |
| **매개변수:** | |
| tile_sample_min_height (`int`, *선택 사항*) : 샘플이 높이 차원으로 타일링되어 분리되려면 필요한 최소 높이입니다. | |
| tile_sample_min_width (`int`, *선택 사항*) : 샘플이 너비 차원으로 타일 분리되도록 요구되는 최소 너비입니다. | |
| tile_sample_stride_height (`int`, *선택 사항*) : 두 개의 연속된 세로 타일 사이의 최소 겹침 양입니다. 이는 높이 차원에서 타일링 아티팩트가 발생하지 않도록 보장하기 위한 것입니다. | |
| tile_sample_stride_width (`int`, *선택 사항*) : 두 인접한 수평 타일 사이의 스트라이드입니다. 이는 너비 차원에서 타일링 아티팩트가 발생하지 않도록 보장하기 위한 것입니다. | |
| 타일 AE 디코딩을 활성화합니다. 이 옵션이 활성화되면 AE는 입력 텐서를 타일로 분할하여 디코딩과 인코딩을 여러 단계로 계산합니다. 이는 대량의 메모리를 절약하고 더 큰 이미지를 처리할 수 있도록 하는 데 유용합니다. | |
| #### forward[[diffusers.AutoencoderDC.forward]] | |
| ```python | |
| forward(sample: Tensor, return_dict: bool = True) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_dc.py#L708) | |
| **매개변수:** | |
| sample (`torch.Tensor`) : 입력 샘플. | |
| return_dict (`bool`, *선택 사항*, 기본값 `True`) : 일반 튜플 대신 `DecoderOutput`를 반환할지 여부. | |
| **반환값:** `~models.vae.DecoderOutput` 또는 `tuple` | |
| `return_dict`가 True이면 `~models.vae.DecoderOutput`가 반환되고, 그렇지 않으면 일반 `tuple`이 반환됩니다. | |
| ## DecoderOutput[[diffusers.models.autoencoders.vae.DecoderOutput]] | |
| #### diffusers.models.autoencoders.vae.DecoderOutput[[diffusers.models.autoencoders.vae.DecoderOutput]] | |
| ```python | |
| diffusers.models.autoencoders.vae.DecoderOutput(sample: Tensor, commit_loss: typing.Optional[torch.FloatTensor] = None) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/vae.py#L49) | |
| **매개변수:** | |
| sample (`torch.Tensor`, shape `(batch_size, num_channels, height, width)`) : 모델의 마지막 레이어에서 디코딩된 출력 샘플. | |
| 디코딩 메서드의 출력. | |
Xet Storage Details
- Size:
- 13.3 kB
- Xet hash:
- e416aa0907c3b07e625ef4d0707c22fe668bd4bdc1ce1e5033a75d696f2805d5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.