§
    òwŠi§  ã                   ó<   — d dl mZ ddlmZmZ  G d„ d¦  «        ZdS )é    )Úvalidate_hf_hub_argsé   )Ú#create_diffusers_vae_model_from_ldmÚfetch_ldm_config_and_checkpointc                   ó8   — e Zd ZdZeed„ ¦   «         ¦   «         ZdS )ÚFromOriginalVAEMixinzw
    Load pretrained AutoencoderKL weights saved in the `.ckpt` or `.safetensors` format into a [`AutoencoderKL`].
    c                 óò  — |                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      d	d¦  «        }	|                      d
d¦  «        }
|                      dd¦  «        }|                      dd¦  «        }| j        }||t          d¦  «        ‚|p|}t          |||||||||
|	¬¦
  «
        \  }}|                      dd¦  «        }|                      dd¦  «        }t	          ||||||¬¦  «        }|d         }||                     |¦  «        }|S )aÿ  
        Instantiate a [`AutoencoderKL`] from pretrained ControlNet weights saved in the original `.ckpt` or
        `.safetensors` format. The pipeline is set in evaluation mode (`model.eval()`) by default.

        Parameters:
            pretrained_model_link_or_path (`str` or `os.PathLike`, *optional*):
                Can be either:
                    - A link to the `.ckpt` file (for example
                      `"https://huggingface.co/<repo_id>/blob/main/<path_to_file>.ckpt"`) on the Hub.
                    - A path to a *file* containing all pipeline weights.
            config_file (`str`, *optional*):
                Filepath to the configuration YAML file associated with the model. If not provided it will default to:
                https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml
            torch_dtype (`str` or `torch.dtype`, *optional*):
                Override the default `torch.dtype` and load the model with another dtype. If `"auto"` is passed, the
                dtype is automatically derived from the model's weights.
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force the (re-)download of the model weights and configuration files, overriding the
                cached versions if they exist.
            cache_dir (`Union[str, os.PathLike]`, *optional*):
                Path to a directory where a downloaded pretrained model configuration is cached if the standard cache
                is not used.
            resume_download:
                Deprecated and ignored. All downloads are now resumed by default when possible. Will be removed in v1
                of Diffusers.
            proxies (`Dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
            local_files_only (`bool`, *optional*, defaults to `False`):
                Whether to only load local model weights and configuration files or not. If set to True, the model
                won't be downloaded from the Hub.
            token (`str` or *bool*, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
                `diffusers-cli login` (stored in `~/.huggingface`) is used.
            revision (`str`, *optional*, defaults to `"main"`):
                The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
                allowed by Git.
            image_size (`int`, *optional*, defaults to 512):
                The image size the model was trained on. Use 512 for all Stable Diffusion v1 models and the Stable
                Diffusion v2 base model. Use 768 for Stable Diffusion v2.
            scaling_factor (`float`, *optional*, defaults to 0.18215):
                The component-wise standard deviation of the trained latent space computed using the first batch of the
                training set. This is used to scale the latent space to have unit variance when training the diffusion
                model. The latents are scaled with the formula `z = z * scaling_factor` before being passed to the
                diffusion model. When decoding, the latents are scaled back to the original scale with the formula: `z
                = 1 / scaling_factor * z`. For more details, refer to sections 4.3.2 and D.1 of the [High-Resolution
                Image Synthesis with Latent Diffusion Models](https://arxiv.org/abs/2112.10752) paper.
            kwargs (remaining dictionary of keyword arguments, *optional*):
                Can be used to overwrite load and saveable variables (for example the pipeline components of the
                specific pipeline class). The overwritten components are directly passed to the pipelines `__init__`
                method. See example below for more information.

        <Tip warning={true}>

            Make sure to pass both `image_size` and `scaling_factor` to `from_single_file()` if you're loading
            a VAE from SDXL or a Stable Diffusion v2 model or higher.

        </Tip>

        Examples:

        ```py
        from diffusers import AutoencoderKL

        url = "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/blob/main/vae-ft-mse-840000-ema-pruned.safetensors"  # can also be local file
        model = AutoencoderKL.from_single_file(url)
        ```
        Úoriginal_config_fileNÚconfig_fileÚresume_downloadÚforce_downloadFÚproxiesÚtokenÚ	cache_dirÚlocal_files_onlyÚrevisionÚtorch_dtypez|You cannot pass both `config_file` and `original_config_file` to `from_single_file`. Please use only one of these arguments.)
Úpretrained_model_link_or_pathÚ
class_namer
   r   r   r   r   r   r   r   Ú
image_sizeÚscaling_factor)r   r   r   Úvae)ÚpopÚ__name__Ú
ValueErrorr   r   Úto)Úclsr   Úkwargsr
   r   r   r   r   r   r   r   r   r   r   Úoriginal_configÚ
checkpointr   r   Ú	componentr   s                       úm/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/diffusers/loaders/autoencoder.pyÚfrom_single_filez%FromOriginalVAEMixin.from_single_file   s¯  € ðP  &ŸzšzÐ*@À$ÑGÔGÐØ—j’j °Ñ5Ô5ˆØ Ÿ*š*Ð%6¸Ñ=Ô=ˆØŸšÐ$4°eÑ<Ô<ˆØ—*’*˜Y¨Ñ-Ô-ˆØ—
’
˜7 DÑ)Ô)ˆØ—J’J˜{¨DÑ1Ô1ˆ	Ø!Ÿ:š:Ð&8¸$Ñ?Ô?ÐØ—:’:˜j¨$Ñ/Ô/ˆØ—j’j °Ñ5Ô5ˆà”\ˆ
àÐ#Ð*>Ð*JÝð Oñô ð ð  4ÐB°{ÐÝ&EØ*GØ!Ø!5Ø+Ø)ØØØØ-Øð'
ñ '
ô '
Ñ#ˆ˜ð —Z’Z ¨dÑ3Ô3ˆ
ØŸšÐ$4°dÑ;Ô;ˆÝ7ØØØØ!Ø)Ø#ð
ñ 
ô 
ˆ	ð ˜ÔˆØÐ"Ø—&’&˜Ñ%Ô%ˆCàˆ
ó    N)r   Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr   r#   © r$   r"   r   r      sI   € € € € € ðð ð Øðtð tñ Ôñ „[ðtð tð tr$   r   N)Úhuggingface_hub.utilsr   Úsingle_file_utilsr   r   r   r)   r$   r"   ú<module>r,      s}   ðð 7Ð 6Ð 6Ð 6Ð 6Ð 6ðð ð ð ð ð ð ð ð{ð {ð {ð {ð {ñ {ô {ð {ð {ð {r$   