From 1a8d538bfe99ee85d4a4c5f159fa74dad82c6a1b Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Fri, 5 Jan 2024 21:23:05 -0600 Subject: [PATCH] handle empty results --- api/onnx_web/chain/result.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/onnx_web/chain/result.py b/api/onnx_web/chain/result.py index 0b59f293..8c94d798 100644 --- a/api/onnx_web/chain/result.py +++ b/api/onnx_web/chain/result.py @@ -328,13 +328,13 @@ class StageResult: def size(self) -> Size: if self.images is not None: return Size( - max([image.width for image in self.images]), - max([image.height for image in self.images]), + max([image.width for image in self.images], default=0), + max([image.height for image in self.images], default=0), ) elif self.arrays is not None: return Size( - max([array.shape[0] for array in self.arrays]), - max([array.shape[1] for array in self.arrays]), + max([image.height for image in self.images], default=0), + max([image.height for image in self.images], default=0), ) # TODO: which fields within the shape are width/height? else: return Size(0, 0)