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

Method ema_scope

ldm/models/autoencoder.py:71–83  ·  view source on GitHub ↗
(self, context=None)

Source from the content-addressed store, hash-verified

69
70 @contextmanager
71 def ema_scope(self, context=None):
72 if self.use_ema:
73 self.model_ema.store(self.parameters())
74 self.model_ema.copy_to(self)
75 if context is not None:
76 print(f"{context}: Switched to EMA weights")
77 try:
78 yield None
79 finally:
80 if self.use_ema:
81 self.model_ema.restore(self.parameters())
82 if context is not None:
83 print(f"{context}: Restored training weights")
84
85 def on_train_batch_end(self, *args, **kwargs):
86 if self.use_ema:

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