strip_optimizer() default to save FP16 model

pull/1/head
Glenn Jocher 5 years ago
parent cce95e744d
commit 10145833c3

@ -620,6 +620,7 @@ def strip_optimizer(f='weights/best.pt'): # from utils.utils import *; strip_op
# Strip optimizer from *.pt files for lighter files (reduced by 1/2 size) # Strip optimizer from *.pt files for lighter files (reduced by 1/2 size)
x = torch.load(f, map_location=torch.device('cpu')) x = torch.load(f, map_location=torch.device('cpu'))
x['optimizer'] = None x['optimizer'] = None
x['model'].half() # to FP16
torch.save(x, f) torch.save(x, f)
print('Optimizer stripped from %s' % f) print('Optimizer stripped from %s' % f)

Loading…
Cancel
Save