FLOPS min stride 32 (#2276)

Signed-off-by: xiaowo1996 <429740343@qq.com>
This commit is contained in:
xiaowo1996 2021-02-24 01:38:56 +08:00 committed by GitHub
parent cc79f3a9ea
commit 83dc1b4484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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