Skip to content

Commit

Permalink
remove ema and message_hub
Browse files Browse the repository at this point in the history
  • Loading branch information
Tau-J committed Mar 9, 2023
1 parent ffbf595 commit 31b4b54
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/misc/publish_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ def parse_args():

def process_checkpoint(in_file, out_file):
checkpoint = torch.load(in_file, map_location='cpu')

# remove optimizer for smaller file size
if 'optimizer' in checkpoint:
del checkpoint['optimizer']
if 'message_hub' in checkpoint:
del checkpoint['message_hub']
if 'ema_state_dict' in checkpoint:
del checkpoint['ema_state_dict']

for key in list(checkpoint['state_dict']):
if key.startswith('data_preprocessor'):
checkpoint['state_dict'].pop(key)

# if it is necessary to remove some sensitive data in checkpoint['meta'],
# add the code here.
torch.save(checkpoint, out_file)
Expand Down

0 comments on commit 31b4b54

Please sign in to comment.