From 109b389c29075f1fbf308454477f2304d4a8f38b Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 17 Sep 2022 23:14:39 +0200 Subject: [PATCH 1/3] Add Paddle exports to benchmarks Signed-off-by: Glenn Jocher --- benchmarks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks.py b/benchmarks.py index 58e083c95d55..161af73c1eda 100644 --- a/benchmarks.py +++ b/benchmarks.py @@ -65,7 +65,7 @@ def run( model_type = type(attempt_load(weights, fuse=False)) # DetectionModel, SegmentationModel, etc. for i, (name, f, suffix, cpu, gpu) in export.export_formats().iterrows(): # index, (name, file, suffix, CPU, GPU) try: - assert i not in (9, 10, 11), 'inference not supported' # Edge TPU, TF.js and Paddle are unsupported + assert i not in (9, 10), 'inference not supported' # Edge TPU and TF.js are unsupported assert i != 5 or platform.system() == 'Darwin', 'inference only supported on macOS>=10.13' # CoreML if 'cpu' in device.type: assert cpu, 'inference not supported on CPU' From 5a6b45550c0a9892c288869b7a767b5b9e330c50 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 17 Sep 2022 23:44:48 +0200 Subject: [PATCH 2/3] Update plots.py Signed-off-by: Glenn Jocher --- utils/segment/plots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/segment/plots.py b/utils/segment/plots.py index e882c14390f0..9b90900b3772 100644 --- a/utils/segment/plots.py +++ b/utils/segment/plots.py @@ -99,9 +99,9 @@ def plot_images_and_masks(images, targets, masks, paths=None, fname='images.jpg' if mh != h or mw != w: mask = image_masks[j].astype(np.uint8) mask = cv2.resize(mask, (w, h)) - mask = mask.astype(np.bool) + mask = mask.astype(bool) else: - mask = image_masks[j].astype(np.bool) + mask = image_masks[j].astype(bool) with contextlib.suppress(Exception): im[y:y + h, x:x + w, :][mask] = im[y:y + h, x:x + w, :][mask] * 0.4 + np.array(color) * 0.6 annotator.fromarray(im) From 3e6afd8ef466cbda2beda75831252473d7ebd6f9 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 17 Sep 2022 23:52:59 +0200 Subject: [PATCH 3/3] Update common.py Signed-off-by: Glenn Jocher --- models/common.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/models/common.py b/models/common.py index 9c08120fe7f6..2b61307ad46b 100644 --- a/models/common.py +++ b/models/common.py @@ -460,8 +460,8 @@ def wrap_frozen_graph(gd, inputs, outputs): if cuda: config.enable_use_gpu(memory_pool_init_size_mb=2048, device_id=0) predictor = pdi.create_predictor(config) - input_names = predictor.get_input_names() - input_handle = predictor.get_input_handle(input_names[0]) + input_handle = predictor.get_input_handle(predictor.get_input_names()[0]) + output_names = predictor.get_output_names() else: raise NotImplementedError(f'ERROR: {w} is not a supported format') @@ -517,12 +517,10 @@ def forward(self, im, augment=False, visualize=False): k = 'var_' + str(sorted(int(k.replace('var_', '')) for k in y)[-1]) # output key y = y[k] # output elif self.paddle: # PaddlePaddle - im = im.cpu().numpy().astype("float32") + im = im.cpu().numpy().astype(np.float32) self.input_handle.copy_from_cpu(im) self.predictor.run() - output_names = self.predictor.get_output_names() - output_handle = self.predictor.get_output_handle(output_names[0]) - y = output_handle.copy_to_cpu() + y = [self.predictor.get_output_handle(x).copy_to_cpu() for x in self.output_names] 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