dcnum.segm.segm_torch.torch_model ================================= .. py:module:: dcnum.segm.segm_torch.torch_model Attributes ---------- .. autoapisummary:: dcnum.segm.segm_torch.torch_model.logger Functions --------- .. autoapisummary:: dcnum.segm.segm_torch.torch_model.check_md5sum dcnum.segm.segm_torch.torch_model.load_model dcnum.segm.segm_torch.torch_model.retrieve_model_file Module Contents --------------- .. py:data:: logger .. py:function:: check_md5sum(path) Verify the last five characters of the file stem with its MD5 hash .. py:function:: load_model(path_or_name, device) Load a PyTorch model + metadata from a TorchScript jit checkpoint :param path_or_name: jit checkpoint file; For dcnum, these files have the suffix .dcnm and contain a special `_extra_files["dcnum_meta.json"]` extra file that can be loaded via `torch.jit.load` (see below). :type path_or_name: str or pathlib.Path :param device: device on which to run the model :type device: str or torch.device :returns: * **model_jit** (*torch.jit.ScriptModule*) -- loaded PyTorch model stored as a TorchScript module * **model_meta** (*dict*) -- metadata associated with the loaded model .. py:function:: retrieve_model_file(path_or_name) Retrieve a dcnum torch model file If a path to a model is given, then this path is returned directly. If a file name is given, then look for the file with :func:`dcnum.meta.paths.find_file` using the "torch_model_file" topic.