MCPcopy Create free account
hub / github.com/IceClear/StableSR / ema_scope

Method ema_scope

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

Source from the content-addressed store, hash-verified

70
71 @contextmanager
72 def ema_scope(self, context=None):
73 if self.use_ema:
74 self.model_ema.store(self.parameters())
75 self.model_ema.copy_to(self)
76 if context is not None:
77 print(f"{context}: Switched to EMA weights")
78 try:
79 yield None
80 finally:
81 if self.use_ema:
82 self.model_ema.restore(self.parameters())
83 if context is not None:
84 print(f"{context}: Restored training weights")
85
86 def init_from_ckpt(self, path, ignore_keys=list()):
87 sd = torch.load(path, map_location="cpu")["state_dict"]

Callers 13

validation_stepMethod · 0.95
log_imagesMethod · 0.95
predictMethod · 0.45
inferenceFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 3

storeMethod · 0.80
copy_toMethod · 0.80
restoreMethod · 0.80

Tested by

no test coverage detected