Buckets:
| # AutoencoderRAE | |
| NYU VISIONx'ten Boyang Zheng, Nanye Ma, Shengbang Tong ve Saining Xie'nin [Diffusion Transformers with Representation Autoencoders](https://huggingface.co/papers/2510.11690) makalesinde tanıttığı Representation Autoencoder (RAE) modeli. | |
| RAE, dondurulmuş önceden eğitilmiş bir görme kodlayıcıyı (DINOv2, SigLIP2 veya MAE) eğitilebilir bir ViT-MAE tarzı çözücüyle birleştirir. İki aşamalı RAE eğitim sürecinde, oto-kodlayıcı 1. aşamada (yeniden yapılandırma) eğitilir ve ardından bir difüzyon modeli, 2. aşamada (üretim) elde edilen gizli uzay üzerinde eğitilir. | |
| Diffusers'ta yayınlanan ve desteklenen RAE modelleri şunlardır: | |
| | Model | Encoder | Gizli şekil (224px giriş) | | |
| |:------|:--------|:---------------------------| | |
| | [`nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08`](https://huggingface.co/nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08) | DINOv2-base | 768 x 16 x 16 | | |
| | [`nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08-i512`](https://huggingface.co/nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08-i512) | DINOv2-base (512px) | 768 x 32 x 32 | | |
| | [`nyu-visionx/RAE-dinov2-wReg-small-ViTXL-n08`](https://huggingface.co/nyu-visionx/RAE-dinov2-wReg-small-ViTXL-n08) | DINOv2-small | 384 x 16 x 16 | | |
| | [`nyu-visionx/RAE-dinov2-wReg-large-ViTXL-n08`](https://huggingface.co/nyu-visionx/RAE-dinov2-wReg-large-ViTXL-n08) | DINOv2-large | 1024 x 16 x 16 | | |
| | [`nyu-visionx/RAE-siglip2-base-p16-i256-ViTXL-n08`](https://huggingface.co/nyu-visionx/RAE-siglip2-base-p16-i256-ViTXL-n08) | SigLIP2-base | 768 x 16 x 16 | | |
| | [`nyu-visionx/RAE-mae-base-p16-ViTXL-n08`](https://huggingface.co/nyu-visionx/RAE-mae-base-p16-ViTXL-n08) | MAE-base | 768 x 16 x 16 | | |
| ## Önceden eğitilmiş bir modelin yüklenmesi | |
| ```python | |
| from diffusers import AutoencoderRAE | |
| model = AutoencoderRAE.from_pretrained( | |
| "nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08" | |
| ).to("cuda").eval() # or "mps", "xpu", "cpu" | |
| ``` | |
| ## Gerçek bir görüntünün kodlanması ve çözümlenmesi | |
| ```python | |
| import torch | |
| from diffusers import AutoencoderRAE | |
| from diffusers.utils import load_image | |
| from torchvision.transforms.functional import to_tensor, to_pil_image | |
| model = AutoencoderRAE.from_pretrained( | |
| "nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08" | |
| ).to("cuda").eval() # or "mps", "xpu", "cpu" | |
| image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") | |
| image = image.convert("RGB").resize((224, 224)) | |
| x = to_tensor(image).unsqueeze(0).to("cuda") # (1, 3, 224, 224), values in [0, 1] | |
| with torch.no_grad(): | |
| latents = model.encode(x).latent # (1, 768, 16, 16) | |
| recon = model.decode(latents).sample # (1, 3, 256, 256) | |
| recon_image = to_pil_image(recon[0].clamp(0, 1).cpu()) | |
| recon_image.save("recon.png") | |
| ``` | |
| ## Gizillemeli normalizasyon | |
| Bazı önceden eğitilmiş kontrol noktaları, gizli uzayı normalize etmek için kanal başına `latents_mean` ve `latents_std` istatistiklerini içerir. Bu istatistikler mevcut olduğunda, `encode` ve `decode` sırasıyla normalizasyonu ve normalizasyonun tersini otomatik olarak uygular. | |
| ```python | |
| model = AutoencoderRAE.from_pretrained( | |
| "nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08" | |
| ).to("cuda").eval() # or "mps", "xpu", "cpu" | |
| # Latent normalization is handled automatically inside encode/decode | |
| # when the checkpoint config includes latents_mean/latents_std. | |
| with torch.no_grad(): | |
| latents = model.encode(x).latent # normalized latents | |
| recon = model.decode(latents).sample | |
| ``` | |
| ## AutoencoderRAE[[diffusers.AutoencoderRAE]] | |
| #### diffusers.AutoencoderRAE[[diffusers.AutoencoderRAE]] | |
| ```python | |
| diffusers.AutoencoderRAE(encoder_type: str = 'dinov2', encoder_hidden_size: int = 768, encoder_patch_size: int = 14, encoder_num_hidden_layers: int = 12, decoder_hidden_size: int = 512, decoder_num_hidden_layers: int = 8, decoder_num_attention_heads: int = 16, decoder_intermediate_size: int = 2048, patch_size: int = 16, encoder_input_size: int = 224, image_size: int | None = None, num_channels: int = 3, encoder_norm_mean: list | None = None, encoder_norm_std: list | None = None, latents_mean: typing.Union[list, tuple, torch.Tensor, NoneType] = None, latents_std: typing.Union[list, tuple, torch.Tensor, NoneType] = None, noise_tau: float = 0.0, reshape_to_2d: bool = True, use_encoder_loss: bool = False, scaling_factor: float = 1.0) | |
| ``` | |
| [Kaynak](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_rae.py#L393) | |
| **Parametreler:** | |
| encoder_type (`str`, *isteğe bağlı*, varsayılan `"dinov2"`) : Kullanılacak donmuş kodlayıcının türü. `"dinov2"`, `"siglip2"` veya `"mae"` değerlerinden biri. | |
| encoder_hidden_size (`int`, *isteğe bağlı*, varsayılan `768`) : Kodlayıcı modelinin gizli boyutu. | |
| encoder_patch_size (`int`, *isteğe bağlı*, varsayılan `14`) : Kodlayıcı modelinin yama boyutu. | |
| encoder_num_hidden_layers (`int`, *isteğe bağlı*, varsayılan `12`) : Kodlayıcı modelindeki gizli katman sayısı. | |
| patch_size (`int`, *isteğe bağlı*, varsayılan `16`) : Decoder yama boyutu (unpatchify ve decoder head için kullanılır). | |
| encoder_input_size (`int`, *isteğe bağlı*, varsayılan `224`) : Kodlayıcının beklediği giriş boyutu. | |
| image_size (`int`, *isteğe bağlı*) : Dekoder çıktı görüntü boyutu. `None` ise, RAE-main'de olduğu gibi kodlayıcı token sayısı ve `patch_size` üzerinden türetilir: `image_size = patch_size * sqrt(num_patches)`, burada `num_patches = (encoder_input_size // encoder_patch_size) ** 2`. | |
| num_channels (`int`, *isteğe bağlı*, varsayılan `3`) : Giriş/çıkış kanal sayısı. | |
| encoder_norm_mean (`list`, *opsiyonel*, varsayılan `[0.485, 0.456, 0.406]`) : Kodlayıcı girdisi normalizasyonu için kanal bazlı ortalama (ImageNet varsayılanları). | |
| encoder_norm_std (`list`, *opsiyonel*, varsayılan `[0.229, 0.224, 0.225]`) : Kodlayıcı girdi normalizasyonu için kanal bazlı std (ImageNet varsayılanları). | |
| latents_mean (`list` veya `tuple`, *isteğe bağlı*) : Gizli normalizasyon için isteğe bağlı ortalama. Girdi olarak tensörler kabul edilir ve yapılandırma-serileştirilebilir listelere dönüştürülür. | |
| latents_std (`list` veya `tuple`, *isteğe bağlı*) : Gizli normalizasyon için isteğe bağlı standart sapma. Girdi olarak tensörler kabul edilir ve yapılandırma-dizilebilir listelere dönüştürülür. | |
| noise_tau (`float`, *isteğe bağlı*, varsayılan `0.0`) : Eğitim için gürültü seviyesi (eğitim sırasında latentlere gürültü ekler). | |
| reshape_to_2d (`bool`, *isteğe bağlı*, varsayılan `True`) : Latentlerin 2B (B, C, H, W) biçimine yeniden şekillendirilip şekillendirilmeyeceğini belirtir. | |
| use_encoder_loss (`bool`, *isteğe bağlı*, varsayılan `False`) : Kayıp fonksiyonunda (ileri düzey eğitim için) kodlayıcı gizli durumlarının kullanılıp kullanılmayacağı. | |
| Görselleri latentlere kodlamak ve latentleri görsellere çözmek için kullanılan Representation Autoencoder (RAE) modeli. | |
| Bu model, öğrenilmiş temsillerden görüntüleri yeniden oluşturmak için dondurulmuş önceden eğitilmiş bir kodlayıcıyı (DINOv2, SigLIP2 veya MAE) ve eğitilebilir bir ViT çözücüsünü kullanır. | |
| Bu model [ModelMixin](/docs/diffusers/main/tr/api/models/overview#diffusers.ModelMixin) sınıfından devralır. Tüm modeller için uygulanan genel yöntemlerini (indirme veya kaydetme gibi) görmek için üst sınıfın belgelerini kontrol edin. | |
| #### encode[[diffusers.AutoencoderRAE.encode]] | |
| ```python | |
| encode(x: Tensor, return_dict: bool = True, generator: typing.Optional[torch.Generator] = None) | |
| ``` | |
| [Kaynak](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_rae.py#L640) | |
| #### decode[[diffusers.AutoencoderRAE.decode]] | |
| ```python | |
| decode(z: Tensor, return_dict: bool = True) | |
| ``` | |
| [Kaynak](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_rae.py#L671) | |
| #### forward[[diffusers.AutoencoderRAE.forward]] | |
| ```python | |
| forward(sample: Tensor, return_dict: bool = True, generator: typing.Optional[torch.Generator] = None) | |
| ``` | |
| [Kaynak](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_rae.py#L682) | |
| **Parametreler:** | |
| sample (`torch.Tensor`) : Girdi örneği. | |
| return_dict (`bool`, *isteğe bağlı*, varsayılan `True`) : Düz bir tuple yerine `DecoderOutput` döndürülüp döndürülmemesi. | |
| generator (`torch.Generator`, *isteğe bağlı*) : Örnekleme işlemini deterministik hale getirmek için kullanılan bir [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html). | |
| **Dönüş:** `DecoderOutput` veya `tuple` | |
| `return_dict` True ise, `DecoderOutput` döndürülür; aksi halde düz bir `tuple` döndürülür. | |
| ## 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) | |
| ``` | |
| [Kaynak](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/vae.py#L49) | |
| **Parametreler:** | |
| sample (`torch.Tensor`, şekli `(batch_size, num_channels, height, width)`) : Modelin son katmanından çözümlenmiş çıktı örneği. | |
| Çözümleme yönteminin çıktısı. | |
Xet Storage Details
- Size:
- 9.45 kB
- Xet hash:
- bebb49860ee5dc8492b34eb70ca59edb98237c0bb9e9d37ca1bd30825b2875c4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.