Skip to content

Commit

Permalink
Set recompute_scale_factor to None if Upsample module in model
Browse files Browse the repository at this point in the history
  • Loading branch information
khsa1 committed Jul 12, 2023
1 parent 28f91e0 commit 21778b5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pytorch_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def __init__(self, model_path: str, force_cpu: bool = False):
@staticmethod
def _load_model(model_pt_path, device):
checkpoint = torch.load(model_pt_path, map_location=device)
for m in checkpoint['model'].modules():
if type(m) is torch.nn.Upsample:
m.recompute_scale_factor = None
torch.save(checkpoint, model_pt_path)
model = checkpoint['model'].float().fuse().eval() # FP32 model
return model

Expand Down

0 comments on commit 21778b5

Please sign in to comment.