Configuration
In Diffusers, schedulers of type schedulers.scheduling_utils.SchedulerMixin, and models of type ModelMixin inherit from ConfigMixin which conveniently takes care of storing all parameters that are
passed to the respective __init__
methods in a JSON-configuration file.
TODO(PVP) - add example and better info here
ConfigMixin
Base class for all configuration classes. Stores all configuration parameters under self.config
Also handles all
methods for loading/downloading/saving classes inheriting from ConfigMixin with
Class attributes:
- config_name (
str
) — A filename under which the config should stored when calling save_config() (should be overriden by parent class). - ignore_for_config (
List[str]
) — A list of attributes that should not be saved in the config (should be overriden by parent class).
from_config
< source >( pretrained_model_name_or_path: typing.Union[str, os.PathLike] return_unused_kwargs = False **kwargs )
Parameters
-
pretrained_model_name_or_path (
str
oros.PathLike
, optional) — Can be either:- A string, the model id of a model repo on huggingface.co. Valid model ids should have an
organization name, like
google/ddpm-celebahq-256
. - A path to a directory containing model weights saved using save_config(), e.g.,
./my_model_directory/
.
- A string, the model id of a model repo on huggingface.co. Valid model ids should have an
organization name, like
-
cache_dir (
Union[str, os.PathLike]
, optional) — Path to a directory in which a downloaded pretrained model configuration should be cached if the standard cache should not be used. -
ignore_mismatched_sizes (
bool
, optional, defaults toFalse
) — Whether or not to raise an error if some of the weights from the checkpoint do not have the same size as the weights of the model (if for instance, you are instantiating a model with 10 labels from a checkpoint with 3 labels). -
force_download (
bool
, optional, defaults toFalse
) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. -
resume_download (
bool
, optional, defaults toFalse
) — Whether or not to delete incompletely received files. Will attempt to resume the download if such a file exists. -
proxies (
Dict[str, str]
, optional) — A dictionary of proxy servers to use by protocol or endpoint, e.g.,{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}
. The proxies are used on each request. -
output_loading_info(
bool
, optional, defaults toFalse
) — Whether ot not to also return a dictionary containing missing keys, unexpected keys and error messages. -
local_files_only(
bool
, optional, defaults toFalse
) — Whether or not to only look at local files (i.e., do not try to download the model). -
use_auth_token (
str
or bool, optional) — The token to use as HTTP bearer authorization for remote files. IfTrue
, will use the token generated when runningtransformers-cli login
(stored in~/.huggingface
). -
revision (
str
, optional, defaults to"main"
) — The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on huggingface.co, sorevision
can be any identifier allowed by git. -
mirror (
str
, optional) — Mirror source to accelerate downloads in China. If you are from China and have an accessibility problem, you can set this option to resolve it. Note that we do not guarantee the timeliness or safety. Please refer to the mirror site for more information.
Instantiate a Python class from a pre-defined JSON-file.
Passing `use_auth_token=True“ is required when you want to use a private model.
Activate the special “offline-mode” to use this method in a firewalled environment.
save_config
< source >( save_directory: typing.Union[str, os.PathLike] push_to_hub: bool = False **kwargs )
Save a configuration object to the directory save_directory
, so that it can be re-loaded using the
from_config() class method.