Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 1 | # Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | |
| 4 | import os |
| 5 | |
| 6 | import cv2 |
| 7 | |
| 8 | from context import network_executor |
| 9 | from context import cv_utils |
| 10 | |
| 11 | |
| 12 | def test_execute_network(test_data_folder): |
| 13 | model_path = os.path.join(test_data_folder, "detect.tflite") |
| 14 | backends = ["CpuAcc", "CpuRef"] |
| 15 | |
| 16 | executor = network_executor.ArmnnNetworkExecutor(model_path, backends) |
| 17 | img = cv2.imread(os.path.join(test_data_folder, "messi5.jpg")) |
| 18 | input_tensors = cv_utils.preprocess(img, executor.input_binding_info) |
| 19 | |
| 20 | output_result = executor.run(input_tensors) |
| 21 | |
| 22 | # Ensure it detects a person |
| 23 | classes = output_result[1] |
| 24 | assert classes[0][0] == 0 |