From 82ddf9ca322e6fcc8f9364a696c26d15841d13d8 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sat, 30 Jul 2022 08:06:11 +0200 Subject: [PATCH] Fixed a bug when there are no squares. --- picoclvr.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/picoclvr.py b/picoclvr.py index 8201f5d..3ecbf3a 100755 --- a/picoclvr.py +++ b/picoclvr.py @@ -173,9 +173,14 @@ def descr2properties(descr, height, width): seen[x] = (color_id[x], k // width, k % width) square_infos = tuple(zip(*seen.values())) - square_c = torch.tensor(square_infos[0]) - square_i = torch.tensor(square_infos[1]) - square_j = torch.tensor(square_infos[2]) + if square_infos: + square_c = torch.tensor(square_infos[0]) + square_i = torch.tensor(square_infos[1]) + square_j = torch.tensor(square_infos[2]) + else: + square_c = torch.tensor([]) + square_i = torch.tensor([]) + square_j = torch.tensor([]) s = all_properties(height, width, len(seen), square_i, square_j, square_c) -- 2.39.5