Skip to content

SchedulerMixin from_pretrained and ConfigMixin Self type annotation #11192

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

Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/diffusers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
validate_hf_hub_args,
)
from requests import HTTPError
from typing_extensions import Self

from . import __version__
from .utils import (
Expand Down Expand Up @@ -185,7 +186,9 @@ def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool
)

@classmethod
def from_config(cls, config: Union[FrozenDict, Dict[str, Any]] = None, return_unused_kwargs=False, **kwargs):
def from_config(
cls, config: Union[FrozenDict, Dict[str, Any]] = None, return_unused_kwargs=False, **kwargs
) -> Union[Self, Tuple[Self, Dict[str, Any]]]:
r"""
Instantiate a Python class from a config dictionary.

Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/schedulers/scheduling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import torch
from huggingface_hub.utils import validate_hf_hub_args
from typing_extensions import Self

from ..utils import BaseOutput, PushToHubMixin

Expand Down Expand Up @@ -99,7 +100,7 @@ def from_pretrained(
subfolder: Optional[str] = None,
return_unused_kwargs=False,
**kwargs,
):
) -> Self:
r"""
Instantiate a scheduler from a pre-defined JSON configuration file in a local directory or Hub repository.

Expand Down
Loading