From fe83bb7de2ffa8c432cde262e3f3907fde66b31f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 18 Feb 2022 20:34:50 +0100 Subject: [PATCH 1/2] Fix CoreML P6 inference --- models/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/common.py b/models/common.py index 8831723ffa25..5edf11455360 100644 --- a/models/common.py +++ b/models/common.py @@ -428,7 +428,8 @@ def forward(self, im, augment=False, visualize=False, val=False): conf, cls = y['confidence'].max(1), y['confidence'].argmax(1).astype(np.float) y = np.concatenate((box, conf.reshape(-1, 1), cls.reshape(-1, 1)), 1) else: - y = y[sorted(y)[-1]] # last output + k = 'var_' + str(sorted([int(k.replace('var_', '')) for k in y])[-1]) # output key + y = y[k] # output else: # TensorFlow (SavedModel, GraphDef, Lite, Edge TPU) im = im.permute(0, 2, 3, 1).cpu().numpy() # torch BCHW to numpy BHWC shape(1,320,192,3) if self.saved_model: # SavedModel From 1d36aca2e6e4b7e09af65a614720a162163bfe12 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:35:02 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- models/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/common.py b/models/common.py index 5edf11455360..5882c3ea66a6 100644 --- a/models/common.py +++ b/models/common.py @@ -428,7 +428,7 @@ def forward(self, im, augment=False, visualize=False, val=False): conf, cls = y['confidence'].max(1), y['confidence'].argmax(1).astype(np.float) y = np.concatenate((box, conf.reshape(-1, 1), cls.reshape(-1, 1)), 1) else: - k = 'var_' + str(sorted([int(k.replace('var_', '')) for k in y])[-1]) # output key + k = 'var_' + str(sorted(int(k.replace('var_', '')) for k in y)[-1]) # output key y = y[k] # output else: # TensorFlow (SavedModel, GraphDef, Lite, Edge TPU) im = im.permute(0, 2, 3, 1).cpu().numpy() # torch BCHW to numpy BHWC shape(1,320,192,3)