From 04afaa58cfed2ecef9e22d8f2474395bdb373451 Mon Sep 17 00:00:00 2001 From: Chenguo Lin Date: Wed, 30 Oct 2024 18:17:34 +0800 Subject: [PATCH] debug `EMAModel.from_pretrained()` `model_cls.load_config()` is modified to **`model_cls.from_config()`**. When setting `return_unused_kwargs=True`, for `model_cls.load_config()`, the returned unused kwargs are referred to as **unused input args**, instead of unused args for `model_cls` initialization. So the returned `ema_kwargs` are always empty (`{}`). **`model_cls.from_config()`** will return the real **unused args for model initialization**, which are the expected `ema_kwargs`. --- src/diffusers/training_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffusers/training_utils.py b/src/diffusers/training_utils.py index 0e0d0ce5b568..d2bf3fe07185 100644 --- a/src/diffusers/training_utils.py +++ b/src/diffusers/training_utils.py @@ -379,7 +379,7 @@ def __init__( @classmethod def from_pretrained(cls, path, model_cls, foreach=False) -> "EMAModel": - _, ema_kwargs = model_cls.load_config(path, return_unused_kwargs=True) + _, ema_kwargs = model_cls.from_config(path, return_unused_kwargs=True) model = model_cls.from_pretrained(path) ema_model = cls(model.parameters(), model_cls=model_cls, model_config=model.config, foreach=foreach)