Skip to content

Commit

Permalink
[Fix] Type Hint in from_pretrained() to Ensure Correct Type Inference (
Browse files Browse the repository at this point in the history
…#10714)

* Update pipeline_utils.py

Added Self in from_pretrained method so  inference will correctly recognize pipeline

* Use typing_extensions

---------

Co-authored-by: hlky <[email protected]>
  • Loading branch information
SahilCarterr and hlky authored Feb 4, 2025
1 parent dbe0094 commit 5b1dcd1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/diffusers/pipelines/pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from packaging import version
from requests.exceptions import HTTPError
from tqdm.auto import tqdm
from typing_extensions import Self

from .. import __version__
from ..configuration_utils import ConfigMixin
Expand Down Expand Up @@ -513,7 +514,7 @@ def dtype(self) -> torch.dtype:

@classmethod
@validate_hf_hub_args
def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], **kwargs):
def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], **kwargs) -> Self:
r"""
Instantiate a PyTorch diffusion pipeline from pretrained pipeline weights.
Expand Down

0 comments on commit 5b1dcd1

Please sign in to comment.