Increase FLOPS robustness (#1589)

This commit is contained in:
Glenn Jocher 2020-12-05 11:41:17 +01:00 committed by GitHub
parent d1ad63206b
commit dbcb192f2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,7 +152,7 @@ def model_info(model, verbose=False, img_size=640):
try: # FLOPS try: # FLOPS
from thop import profile from thop import profile
stride = int(model.stride.max()) stride = int(model.stride.max()) if hasattr(model, 'stride') else 32
img = torch.zeros((1, 3, stride, stride), device=next(model.parameters()).device) # input img = torch.zeros((1, 3, stride, stride), device=next(model.parameters()).device) # input
flops = profile(deepcopy(model), inputs=(img,), verbose=False)[0] / 1E9 * 2 # stride FLOPS flops = profile(deepcopy(model), inputs=(img,), verbose=False)[0] / 1E9 * 2 # stride FLOPS
img_size = img_size if isinstance(img_size, list) else [img_size, img_size] # expand if int/float img_size = img_size if isinstance(img_size, list) else [img_size, img_size] # expand if int/float