From 2875315d6b6b4f5a375f04b6673ef2a57483edfa Mon Sep 17 00:00:00 2001 From: eellison Date: Mon, 16 Mar 2020 04:18:13 -0700 Subject: [PATCH] fix len error (#1981) Co-authored-by: eellison --- torchvision/ops/misc.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/torchvision/ops/misc.py b/torchvision/ops/misc.py index a4c53556753..f26b3393444 100644 --- a/torchvision/ops/misc.py +++ b/torchvision/ops/misc.py @@ -77,12 +77,13 @@ def _check_size_scale_factor(dim, size, scale_factor): raise ValueError("either size or scale_factor should be defined") if size is not None and scale_factor is not None: raise ValueError("only one of size or scale_factor should be defined") - if scale_factor is not None and isinstance(scale_factor, tuple)\ - and len(scale_factor) != dim: - raise ValueError( - "scale_factor shape must match input shape. " - "Input is {}D, scale_factor size is {}".format(dim, len(scale_factor)) - ) + if scale_factor is not None: + if isinstance(scale_factor, (list, tuple)): + if len(scale_factor) != dim: + raise ValueError( + "scale_factor shape must match input shape. " + "Input is {}D, scale_factor size is {}".format(dim, len(scale_factor)) + ) def _output_size(dim, input, size, scale_factor):