Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(diffusers): fix the bug of sdxl training #746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions mindone/diffusers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down