diff options
author | Éanna Ó Catháin <eanna.ocathain@arm.com> | 2021-08-20 14:41:38 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-09-08 16:28:41 +0000 |
commit | 65d5d2ddf77c69e76643e40440aa986defe6d0d7 (patch) | |
tree | 716e143f5ffa686ec44ed19b9e1df81e7bed80ff | |
parent | e38c418ebc434d6c2a5618388b0bd05963308047 (diff) | |
download | armnn-65d5d2ddf77c69e76643e40440aa986defe6d0d7.tar.gz |
MLECO-2207 Fix issue with the PyArmNN OD example, for FP32 models.
Change-Id: I6b8887f0b3e23c0c1529719e20b17a9f55ccf4e7
Signed-off-by: Éanna Ó Catháin <eanna.ocathain@arm.com>
-rw-r--r-- | python/pyarmnn/examples/common/cv_utils.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/python/pyarmnn/examples/common/cv_utils.py b/python/pyarmnn/examples/common/cv_utils.py index 61aa46c3d7..fd848b8b0f 100644 --- a/python/pyarmnn/examples/common/cv_utils.py +++ b/python/pyarmnn/examples/common/cv_utils.py @@ -32,7 +32,12 @@ def preprocess(frame: np.ndarray, input_binding_info: tuple): resized_frame = resize_with_aspect_ratio(frame, input_binding_info) # Expand dimensions and convert data type to match model input - data_type = np.float32 if input_binding_info[1].GetDataType() == ann.DataType_Float32 else np.uint8 + if input_binding_info[1].GetDataType() == ann.DataType_Float32: + data_type = np.float32 + resized_frame = resized_frame.astype("float32")/255 + else: + data_type = np.uint8 + resized_frame = np.expand_dims(np.asarray(resized_frame, dtype=data_type), axis=0) assert resized_frame.shape == tuple(input_binding_info[1].GetShape()) @@ -40,6 +45,7 @@ def preprocess(frame: np.ndarray, input_binding_info: tuple): return input_tensors + def resize_with_aspect_ratio(frame: np.ndarray, input_binding_info: tuple): """ Resizes frame while maintaining aspect ratio, padding any empty space. |