From a3faf3f260101c2bc09112ebb514d1e0d0220e1a Mon Sep 17 00:00:00 2001 From: Sayak Paul Date: Thu, 6 Jun 2024 20:35:05 +0530 Subject: [PATCH] [Core] fix: legacy model mapping (#8416) * fix: legacy model mapping * remove print --- src/diffusers/models/modeling_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/diffusers/models/modeling_utils.py b/src/diffusers/models/modeling_utils.py index 744972cde0..da4f798202 100644 --- a/src/diffusers/models/modeling_utils.py +++ b/src/diffusers/models/modeling_utils.py @@ -1057,6 +1057,9 @@ class LegacyModelMixin(ModelMixin): # To prevent depedency import problem. from .model_loading_utils import _fetch_remapped_cls_from_config + # Create a copy of the kwargs so that we don't mess with the keyword arguments in the downstream calls. + kwargs_copy = kwargs.copy() + cache_dir = kwargs.pop("cache_dir", None) force_download = kwargs.pop("force_download", False) resume_download = kwargs.pop("resume_download", None) @@ -1094,4 +1097,4 @@ class LegacyModelMixin(ModelMixin): # resolve remapping remapped_class = _fetch_remapped_cls_from_config(config, cls) - return remapped_class.from_pretrained(pretrained_model_name_or_path, **kwargs) + return remapped_class.from_pretrained(pretrained_model_name_or_path, **kwargs_copy)