(self, context=None)
| 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): |
no test coverage detected