MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / process_checkpoint

Function process_checkpoint

segmentation/tools/publish_model.py:17–27  ·  view source on GitHub ↗
(in_file, out_file)

Source from the content-addressed store, hash-verified

15
16
17def process_checkpoint(in_file, out_file):
18 checkpoint = torch.load(in_file, map_location='cpu')
19 # remove optimizer for smaller file size
20 if 'optimizer' in checkpoint:
21 del checkpoint['optimizer']
22 # if it is necessary to remove some sensitive data in checkpoint['meta'],
23 # add the code here.
24 torch.save(checkpoint, out_file)
25 sha = subprocess.check_output(['sha256sum', out_file]).decode()
26 final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8])
27 subprocess.Popen(['mv', out_file, final_file])
28
29
30def main():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected