glenn-jocher
commited on
Commit
•
9f27902
1
Parent(s):
d8f5fcf
Improved FLOPS computation (#1398)
Browse files- utils/torch_utils.py +1 -1
utils/torch_utils.py
CHANGED
@@ -156,7 +156,7 @@ def model_info(model, verbose=False, img_size=640):
|
|
156 |
flops = profile(deepcopy(model), inputs=(torch.zeros(1, 3, stride, stride),), verbose=False)[0] / 1E9 * 2
|
157 |
img_size = img_size if isinstance(img_size, list) else [img_size, img_size] # expand if int/float
|
158 |
fs = ', %.1f GFLOPS' % (flops * img_size[0] / stride * img_size[1] / stride) # 640x640 FLOPS
|
159 |
-
except ImportError:
|
160 |
fs = ''
|
161 |
|
162 |
logger.info(f"Model Summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}")
|
|
|
156 |
flops = profile(deepcopy(model), inputs=(torch.zeros(1, 3, stride, stride),), verbose=False)[0] / 1E9 * 2
|
157 |
img_size = img_size if isinstance(img_size, list) else [img_size, img_size] # expand if int/float
|
158 |
fs = ', %.1f GFLOPS' % (flops * img_size[0] / stride * img_size[1] / stride) # 640x640 FLOPS
|
159 |
+
except (ImportError, Exception):
|
160 |
fs = ''
|
161 |
|
162 |
logger.info(f"Model Summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}")
|