From aa65feb4b76eefc2a34cd002a925910def7e3829 Mon Sep 17 00:00:00 2001 From: The-truthh <821372701@qq.com> Date: Thu, 7 Nov 2024 16:00:29 +0800 Subject: [PATCH] fix(diffusers): fix the bug of sdxl training --- mindone/diffusers/configuration_utils.py | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/mindone/diffusers/configuration_utils.py b/mindone/diffusers/configuration_utils.py index a95d8b3dc4..b186ef50ef 100644 --- a/mindone/diffusers/configuration_utils.py +++ b/mindone/diffusers/configuration_utils.py @@ -120,23 +120,24 @@ def register_to_config(self, **kwargs): self._internal_dict = FrozenDict(internal_dict) - def __getattr__(self, name: str) -> Any: - """The only reason we overwrite `getattr` here is to gracefully deprecate accessing - config attributes directly. See https://github.com/huggingface/diffusers/pull/3129 - - This function is mostly copied from PyTorch's __getattr__ overwrite: - https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module - """ - - is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name) - is_attribute = name in self.__dict__ - - if is_in_config and not is_attribute: - deprecation_message = f"Accessing config attribute `{name}` directly via '{type(self).__name__}' object attribute is deprecated. Please access '{name}' over '{type(self).__name__}'s config object instead, e.g. 'scheduler.config.{name}'." # noqa: E501 - deprecate("direct config name access", "1.0.0", deprecation_message, standard_warn=False) - return self._internal_dict[name] - - raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") + # FIXME @ms>2.3.0: "getattr(): attribute name must be string but got: External" + # def __getattr__(self, name: str) -> Any: + # """The only reason we overwrite `getattr` here is to gracefully deprecate accessing + # config attributes directly. See https://github.com/huggingface/diffusers/pull/3129 + # + # This function is mostly copied from PyTorch's __getattr__ overwrite: + # https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module + # """ + # + # is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name) + # is_attribute = name in self.__dict__ + # + # if is_in_config and not is_attribute: + # deprecation_message = f"Accessing config attribute `{name}` directly via '{type(self).__name__}' object attribute is deprecated. Please access '{name}' over '{type(self).__name__}'s config object instead, e.g. 'scheduler.config.{name}'." # noqa: E501 + # deprecate("direct config name access", "1.0.0", deprecation_message, standard_warn=False) + # return self._internal_dict[name] + # + # raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool = False, **kwargs): """