MCPcopy Create free account
hub / github.com/HYUNJS/SGT / load

Method load

projects/SGT/sgt/checkpointer.py:86–110  ·  view source on GitHub ↗
(self, path: str, checkpointables: Optional[List[str]] = None)

Source from the content-addressed store, hash-verified

84 return self.load(path, checkpointables=[])
85
86 def load(self, path: str, checkpointables: Optional[List[str]] = None) -> Dict[str, Any]:
87 if not path:
88 # no checkpoint provided
89 self.logger.info("No checkpoint found. Initializing model from scratch")
90 return {}
91 self.logger.info("Loading checkpoint from {}".format(path))
92 if not os.path.isfile(path):
93 path = self.path_manager.get_local_path(path)
94 assert os.path.isfile(path), "Checkpoint {} not found!".format(path)
95
96 checkpoint = self._load_file(path)
97 incompatible = self._load_model(checkpoint)
98 if (
99 incompatible is not None
100 ): # handle some existing subclasses that returns None
101 self._log_incompatible_keys(incompatible)
102
103 for key in self.checkpointables if checkpointables is None else checkpointables:
104 if key in checkpoint:
105 self.logger.info("Loading {} from {}".format(key, path))
106 obj = self.checkpointables[key]
107 obj.load_state_dict(checkpoint.pop(key))
108
109 # return any further checkpoint data
110 return checkpoint
111
112 def _load_model(self, checkpoint: Any) -> _IncompatibleKeys:
113 """

Callers 6

resume_or_loadMethod · 0.95
__init__Method · 0.80
load_mix_dataset_dictsFunction · 0.80
load_mot_dataset_dictsFunction · 0.80
load_pretrained_modelMethod · 0.80
_load_fileMethod · 0.80

Calls 2

_load_modelMethod · 0.95
_load_fileMethod · 0.80

Tested by

no test coverage detected