From 5854ad19e35d356c1f2ffe50bc375248040188f7 Mon Sep 17 00:00:00 2001 From: hlky Date: Fri, 7 Feb 2025 04:22:04 +0000 Subject: [PATCH] Add `Self` type hint to `ModelMixin`'s `from_pretrained` --- src/diffusers/models/modeling_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/diffusers/models/modeling_utils.py b/src/diffusers/models/modeling_utils.py index 3ef40ffb5783..eb3063ff0c30 100644 --- a/src/diffusers/models/modeling_utils.py +++ b/src/diffusers/models/modeling_utils.py @@ -31,6 +31,7 @@ from huggingface_hub import DDUFEntry, create_repo, split_torch_state_dict_into_shards from huggingface_hub.utils import validate_hf_hub_args from torch import Tensor, nn +from typing_extensions import Self from .. import __version__ from ..hooks import apply_layerwise_casting @@ -605,7 +606,7 @@ def dequantize(self): @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 pretrained PyTorch model from a pretrained model configuration.