@@ -81,18 +81,17 @@ def __setitem__(self, name, value):
8181
8282class ConfigMixin :
8383 r"""
84- Base class for all configuration classes. Stores all configuration parameters under `self.config` Also handles all
85- methods for loading/downloading/saving classes inheriting from [`ConfigMixin`] with
86- - [`~ConfigMixin.from_config`]
87- - [`~ConfigMixin.save_config`]
84+ Base class for all configuration classes. All configuration parameters are stored under `self.config`. Also
85+ provides the [`~ConfigMixin.from_config`] and [`~ConfigMixin.save_config`] methods for loading, downloading, and
86+ saving classes that inherit from [`ConfigMixin`].
8887
8988 Class attributes:
9089 - **config_name** (`str`) -- A filename under which the config should stored when calling
9190 [`~ConfigMixin.save_config`] (should be overridden by parent class).
9291 - **ignore_for_config** (`List[str]`) -- A list of attributes that should not be saved in the config (should be
9392 overridden by subclass).
9493 - **has_compatibles** (`bool`) -- Whether the class has compatible classes (should be overridden by subclass).
95- - **_deprecated_kwargs** (`List[str]`) -- Keyword arguments that are deprecated. Note that the init function
94+ - **_deprecated_kwargs** (`List[str]`) -- Keyword arguments that are deprecated. Note that the ` init` function
9695 should only have a `kwargs` argument if at least one argument is deprecated (should be overridden by
9796 subclass).
9897 """
@@ -139,12 +138,12 @@ def __getattr__(self, name: str) -> Any:
139138
140139 def save_config (self , save_directory : Union [str , os .PathLike ], push_to_hub : bool = False , ** kwargs ):
141140 """
142- Save a configuration object to the directory `save_directory`, so that it can be re-loaded using the
141+ Save a configuration object to the directory specified in `save_directory` so that it can be reloaded using the
143142 [`~ConfigMixin.from_config`] class method.
144143
145144 Args:
146145 save_directory (`str` or `os.PathLike`):
147- Directory where the configuration JSON file will be saved (will be created if it does not exist).
146+ Directory where the configuration JSON file is saved (will be created if it does not exist).
148147 """
149148 if os .path .isfile (save_directory ):
150149 raise AssertionError (f"Provided path ({ save_directory } ) should be a directory, not a file" )
@@ -164,15 +163,14 @@ def from_config(cls, config: Union[FrozenDict, Dict[str, Any]] = None, return_un
164163
165164 Parameters:
166165 config (`Dict[str, Any]`):
167- A config dictionary from which the Python class will be instantiated. Make sure to only load
168- configuration files of compatible classes.
166+ A config dictionary from which the Python class is instantiated. Make sure to only load configuration
167+ files of compatible classes.
169168 return_unused_kwargs (`bool`, *optional*, defaults to `False`):
170169 Whether kwargs that are not consumed by the Python class should be returned or not.
171-
172170 kwargs (remaining dictionary of keyword arguments, *optional*):
173171 Can be used to update the configuration object (after it is loaded) and initiate the Python class.
174- `**kwargs` are directly passed to the underlying scheduler/model's `__init__` method and eventually
175- overwrite same named arguments in `config`.
172+ `**kwargs` are passed directly to the underlying scheduler/model's `__init__` method and eventually
173+ overwrite the same named arguments in `config`.
176174
177175 Returns:
178176 [`ModelMixin`] or [`SchedulerMixin`]:
@@ -280,16 +278,16 @@ def load_config(
280278 Whether or not to force the (re-)download of the model weights and configuration files, overriding the
281279 cached versions if they exist.
282280 resume_download (`bool`, *optional*, defaults to `False`):
283- Whether or not to resume downloading the model weights and configuration files. If set to False, any
281+ Whether or not to resume downloading the model weights and configuration files. If set to ` False` , any
284282 incompletely downloaded files are deleted.
285283 proxies (`Dict[str, str]`, *optional*):
286284 A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
287285 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
288286 output_loading_info(`bool`, *optional*, defaults to `False`):
289287 Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages.
290- local_files_only(`bool`, *optional*, defaults to `False`):
291- Whether to only load local model weights and configuration files or not. If set to True, the model
292- won’ t be downloaded from the Hub.
288+ local_files_only (`bool`, *optional*, defaults to `False`):
289+ Whether to only load local model weights and configuration files or not. If set to ` True` , the model
290+ won' t be downloaded from the Hub.
293291 use_auth_token (`str` or *bool*, *optional*):
294292 The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
295293 `diffusers-cli login` (stored in `~/.huggingface`) is used.
@@ -307,14 +305,6 @@ def load_config(
307305 `dict`:
308306 A dictionary of all the parameters stored in a JSON configuration file.
309307
310- <Tip>
311-
312- To use private or [gated models](https://huggingface.co/docs/hub/models-gated#gated-models), log-in with
313- `huggingface-cli login`. You can also activate the special
314- ["offline-mode"](https://huggingface.co/transformers/installation.html#offline-mode) to use this method in a
315- firewalled environment.
316-
317- </Tip>
318308 """
319309 cache_dir = kwargs .pop ("cache_dir" , DIFFUSERS_CACHE )
320310 force_download = kwargs .pop ("force_download" , False )
@@ -536,10 +526,11 @@ def config(self) -> Dict[str, Any]:
536526
537527 def to_json_string (self ) -> str :
538528 """
539- Serializes this instance to a JSON string.
529+ Serializes the configuration instance to a JSON string.
540530
541531 Returns:
542- `str`: String containing all the attributes that make up this configuration instance in JSON format.
532+ `str`:
533+ String containing all the attributes that make up the configuration instance in JSON format.
543534 """
544535 config_dict = self ._internal_dict if hasattr (self , "_internal_dict" ) else {}
545536 config_dict ["_class_name" ] = self .__class__ .__name__
@@ -560,11 +551,11 @@ def to_json_saveable(value):
560551
561552 def to_json_file (self , json_file_path : Union [str , os .PathLike ]):
562553 """
563- Save this instance to a JSON file.
554+ Save the configuration instance's parameters to a JSON file.
564555
565556 Args:
566557 json_file_path (`str` or `os.PathLike`):
567- Path to the JSON file in which this configuration instance's parameters will be saved .
558+ Path to the JSON file to save a configuration instance's parameters.
568559 """
569560 with open (json_file_path , "w" , encoding = "utf-8" ) as writer :
570561 writer .write (self .to_json_string ())
0 commit comments