File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11import argparse
22import subprocess
3+ from collections import OrderedDict
34
45import torch
56
6-
77def parse_args ():
88 parser = argparse .ArgumentParser (
99 description = 'Process a checkpoint to be published' )
@@ -18,6 +18,13 @@ def process_checkpoint(in_file, out_file):
1818 # remove optimizer for smaller file size
1919 if 'optimizer' in checkpoint :
2020 del checkpoint ['optimizer' ]
21+ if 'state_dict' in checkpoint :
22+ in_state_dict = checkpoint .pop ('state_dict' )
23+ out_state_dict = OrderedDict ()
24+ for key , val in in_state_dict .items ():
25+ key = key .replace ('backbone.' ,'' )
26+ out_state_dict [key ] = val
27+ checkpoint ['state_dict' ] = out_state_dict
2128 # if it is necessary to remove some sensitive data in checkpoint['meta'],
2229 # add the code here.
2330 torch .save (checkpoint , out_file )
You can’t perform that action at this time.
0 commit comments