From 9f27902368b6c98e5483e9c1b55396c8a90c5501 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 14 Nov 2020 14:48:55 +0100 Subject: [PATCH] Improved FLOPS computation (#1398) --- utils/torch_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/torch_utils.py b/utils/torch_utils.py index e5ef260..a6c460f 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -156,7 +156,7 @@ def model_info(model, verbose=False, img_size=640): flops = profile(deepcopy(model), inputs=(torch.zeros(1, 3, stride, stride),), verbose=False)[0] / 1E9 * 2 img_size = img_size if isinstance(img_size, list) else [img_size, img_size] # expand if int/float fs = ', %.1f GFLOPS' % (flops * img_size[0] / stride * img_size[1] / stride) # 640x640 FLOPS - except ImportError: + except (ImportError, Exception): fs = '' logger.info(f"Model Summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}")