MCPcopy Create free account
hub / github.com/NVlabs/SegFormer / process_checkpoint

Function process_checkpoint

tools/publish_model.py:16–26  ·  view source on GitHub ↗
(in_file, out_file)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected