MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / ema_scope

Method ema_scope

ldm/models/diffusion/ddpm.py:202–214  ·  view source on GitHub ↗
(self, context=None)

Source from the content-addressed store, hash-verified

200
201 @contextmanager
202 def ema_scope(self, context=None):
203 if self.use_ema:
204 self.model_ema.store(self.model.parameters())
205 self.model_ema.copy_to(self.model)
206 if context is not None:
207 print(f"{context}: Switched to EMA weights")
208 try:
209 yield None
210 finally:
211 if self.use_ema:
212 self.model_ema.restore(self.model.parameters())
213 if context is not None:
214 print(f"{context}: Restored training weights")
215
216 @torch.no_grad()
217 def init_from_ckpt(self, path, ignore_keys=list(), only_model=False):

Callers 2

validation_stepMethod · 0.95
log_imagesMethod · 0.95

Calls 3

storeMethod · 0.80
copy_toMethod · 0.80
restoreMethod · 0.80

Tested by

no test coverage detected