(cls, path, model_cls, foreach=False)
| 364 | |
| 365 | @classmethod |
| 366 | def from_pretrained(cls, path, model_cls, foreach=False) -> "EMAModel": |
| 367 | _, ema_kwargs = model_cls.load_config(path, return_unused_kwargs=True) |
| 368 | model = model_cls.from_pretrained(path) |
| 369 | |
| 370 | ema_model = cls(model.parameters(), model_cls=model_cls, model_config=model.config, foreach=foreach) |
| 371 | |
| 372 | ema_model.load_state_dict(ema_kwargs) |
| 373 | return ema_model |
| 374 | |
| 375 | def save_pretrained(self, path): |
| 376 | if self.model_cls is None: |