Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
Richard Burton | f32a86a | 2022-11-15 11:46:11 +0000 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | #---------------------------------------------------------------------------- |
Kshitij Sisodia | aa4bcb1 | 2022-05-06 09:13:03 +0100 | [diff] [blame] | 17 | # Append the API to use for this use case |
| 18 | list(APPEND ${use_case}_API_LIST "object_detection") |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 19 | |
Eanna O Cathain | 4c0ac91 | 2022-09-22 15:18:34 +0100 | [diff] [blame] | 20 | set_input_file_path_user_option(".bmp" ${use_case}) |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 21 | |
| 22 | USER_OPTION(${use_case}_IMAGE_SIZE "Square image size in pixels. Images will be resized to this size." |
| 23 | 192 |
| 24 | STRING) |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 25 | |
Isabella Gottardi | 3107aa2 | 2022-01-27 16:39:37 +0000 | [diff] [blame] | 26 | USER_OPTION(${use_case}_ANCHOR_1 "First anchor array estimated during training." |
| 27 | "{38, 77, 47, 97, 61, 126}" |
| 28 | STRING) |
| 29 | |
| 30 | USER_OPTION(${use_case}_ANCHOR_2 "Second anchor array estimated during training." |
| 31 | "{14, 26, 19, 37, 28, 55 }" |
| 32 | STRING) |
| 33 | |
| 34 | USER_OPTION(${use_case}_CHANNELS_IMAGE_DISPLAYED "Channels' image displayed on the LCD. Select 1 if grayscale, 3 if RGB." |
| 35 | 3 |
| 36 | BOOL) |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 37 | |
| 38 | # Generate input files |
| 39 | generate_images_code("${${use_case}_FILE_PATH}" |
| 40 | ${SRC_GEN_DIR} |
| 41 | ${INC_GEN_DIR} |
| 42 | "${${use_case}_IMAGE_SIZE}") |
| 43 | |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 44 | USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model" |
| 45 | 0x00082000 |
| 46 | STRING) |
| 47 | |
| 48 | if (ETHOS_U_NPU_ENABLED) |
| 49 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/yolo-fastest_192_face_v4_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite) |
| 50 | else() |
| 51 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/yolo-fastest_192_face_v4.tflite) |
| 52 | endif() |
| 53 | |
Isabella Gottardi | 3107aa2 | 2022-01-27 16:39:37 +0000 | [diff] [blame] | 54 | set(${use_case}_ORIGINAL_IMAGE_SIZE |
| 55 | ${${use_case}_IMAGE_SIZE} |
| 56 | CACHE STRING |
| 57 | "Original image size - for the post processing step to upscale the box co-ordinates.") |
| 58 | |
| 59 | set(EXTRA_MODEL_CODE |
| 60 | "extern const int originalImageSize = ${${use_case}_ORIGINAL_IMAGE_SIZE};" |
| 61 | "extern const int channelsImageDisplayed = ${${use_case}_CHANNELS_IMAGE_DISPLAYED};" |
| 62 | "/* NOTE: anchors are different for any given input model size, estimated during training phase */" |
| 63 | "extern const float anchor1[] = ${${use_case}_ANCHOR_1};" |
| 64 | "extern const float anchor2[] = ${${use_case}_ANCHOR_2};" |
| 65 | ) |
| 66 | |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 67 | USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format." |
| 68 | ${DEFAULT_MODEL_PATH} |
| 69 | FILEPATH |
| 70 | ) |
| 71 | |
| 72 | # Generate model file |
| 73 | generate_tflite_code( |
| 74 | MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH} |
| 75 | DESTINATION ${SRC_GEN_DIR} |
Isabella Gottardi | 3107aa2 | 2022-01-27 16:39:37 +0000 | [diff] [blame] | 76 | EXPRESSIONS ${EXTRA_MODEL_CODE} |
Liam Barry | 213a543 | 2022-05-09 17:06:19 +0100 | [diff] [blame] | 77 | NAMESPACE "arm" "app" "object_detection") |