MCPcopy Create free account
hub / github.com/chenhaoxing/DiffusionInst / EMADetectionCheckpointer

Class EMADetectionCheckpointer

diffusioninst/util/model_ema.py:19–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19class EMADetectionCheckpointer(DetectionCheckpointer):
20 def resume_or_load(self, path: str, *, resume: bool = True) -> Dict[str, Any]:
21 """
22 If `resume` is True, this method attempts to resume from the last
23 checkpoint, if exists. Otherwise, load checkpoint from the given path.
24 This is useful when restarting an interrupted training job.
25
26 Args:
27 path (str): path to the checkpoint.
28 resume (bool): if True, resume from the last checkpoint if it exists
29 and load the model together with all the checkpointables. Otherwise
30 only load the model without loading any checkpointables.
31
32 Returns:
33 same as :meth:`load`.
34 """
35 if resume and self.has_checkpoint():
36 path = self.get_checkpoint_file()
37 return self.load(path)
38 else:
39 # workaround `self.load`
40 return self.load(path, checkpointables=None) # modify
41
42
43class EMAState(object):

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected