From 64c0af356846232df941290f3fa8165727c378dd Mon Sep 17 00:00:00 2001 From: RICKIE777 Date: Thu, 14 Jul 2022 17:10:02 +0800 Subject: [PATCH] [PYTHON][BENCHMARK_APP] Add BGR covert to Gray function (#12118) * Fix the JIRA 80700 issue. Add BGR covert to Gray function * Support NCHW and NHWC Co-authored-by: Shen, Wanglei --- .../openvino/tools/benchmark/utils/inputs_filling.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py b/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py index cc7f53bbb45..8d0d2bcae07 100644 --- a/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py +++ b/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py @@ -168,7 +168,12 @@ def get_image_tensors(image_paths, info, batch_sizes): red = np.divide(red, info.scale[2]) image = cv2.merge([blue, green, red]) - if str(info.layout) in ['[N,C,H,W]', '[C,H,W]']: + model_channel = int(str(info.channels)) + image_channel = image.shape[-1] + if model_channel == 1 and image_channel == 3: + image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) + + if model_channel == image_channel and str(info.layout) in ['[N,C,H,W]', '[C,H,W]']: image = image.transpose((2, 0, 1)) if process_with_original_shapes: