MCPcopy
hub / github.com/alibaba/EasyCV / load_checkpoint

Method load_checkpoint

easycv/runner/ev_runner.py:184–211  ·  view source on GitHub ↗

Load checkpoint from a file or URL. Args: filename (str): Accept local filepath, URL, ``torchvision://xxx``, ``open-mmlab://xxx``, ``oss://xxx``. Please refer to ``docs/source/model_zoo.md`` for details. map_location (str): Same as :fu

(self,
                        filename,
                        map_location=torch.device('cpu'),
                        strict=False,
                        logger=None)

Source from the content-addressed store, hash-verified

182
183 # !! notice, map_location should be cpu, other wise may stack to some GPU ,which cause OOMß
184 def load_checkpoint(self,
185 filename,
186 map_location=torch.device('cpu'),
187 strict=False,
188 logger=None):
189 """Load checkpoint from a file or URL.
190
191 Args:
192 filename (str): Accept local filepath, URL, ``torchvision://xxx``,
193 ``open-mmlab://xxx``, ``oss://xxx``. Please refer to
194 ``docs/source/model_zoo.md`` for details.
195 map_location (str): Same as :func:`torch.load`.
196 strict (bool): Whether to allow different params for the model and
197 checkpoint.
198 logger (:mod:`logging.Logger` or None): The logger for error message.
199
200 Returns:
201 dict or OrderedDict: The loaded checkpoint.
202 """
203 if torch.cuda.is_available():
204 device_id = torch.cuda.current_device()
205 map_location = lambda storage, loc: storage.cuda(device_id)
206 return load_checkpoint(
207 self.model,
208 filename=filename,
209 map_location=map_location,
210 strict=strict,
211 logger=logger)
212
213 def resume(self,
214 checkpoint,

Callers 2

resumeMethod · 0.95
train_modelFunction · 0.95

Calls 3

load_checkpointFunction · 0.90
cudaMethod · 0.80
deviceMethod · 0.45

Tested by

no test coverage detected