소스 검색

backbone as FP16, save default to FP32

5.0
Glenn Jocher 4 년 전
부모
커밋
cce95e744d
2개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  1. +1
    -1
      train.py
  2. +1
    -2
      utils/utils.py

+ 1
- 1
train.py 파일 보기

@@ -332,7 +332,7 @@ def train(hyp):
ckpt = {'epoch': epoch,
'best_fitness': best_fitness,
'training_results': f.read(),
'model': ema.ema.module.half() if hasattr(model, 'module') else ema.ema.half(),
'model': ema.ema.module if hasattr(model, 'module') else ema.ema,
'optimizer': None if final_epoch else optimizer.state_dict()}

# Save last, best and delete

+ 1
- 2
utils/utils.py 파일 보기

@@ -627,13 +627,12 @@ def strip_optimizer(f='weights/best.pt'): # from utils.utils import *; strip_op
def create_backbone(f='weights/best.pt', s='weights/backbone.pt'): # from utils.utils import *; create_backbone()
# create backbone 's' from 'f'
device = torch.device('cpu')
x = torch.load(f, map_location=device)
torch.save(x, s) # update model if SourceChangeWarning
x = torch.load(s, map_location=device)

x['optimizer'] = None
x['training_results'] = None
x['epoch'] = -1
x['model'].half() # to FP16
for p in x['model'].parameters():
p.requires_grad = True
torch.save(x, s)

Loading…
취소
저장