Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2022 Arm Limited. All rights reserved. |
| 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 | |
| 20 | USER_OPTION(${use_case}_FILE_PATH "Directory with custom image files to use, or path to a single image, in the evaluation application" |
| 21 | ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/ |
| 22 | PATH_OR_FILE) |
| 23 | |
| 24 | USER_OPTION(${use_case}_IMAGE_SIZE "Square image size in pixels. Images will be resized to this size." |
| 25 | 192 |
| 26 | STRING) |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 27 | |
Isabella Gottardi | 3107aa2 | 2022-01-27 16:39:37 +0000 | [diff] [blame] | 28 | USER_OPTION(${use_case}_ANCHOR_1 "First anchor array estimated during training." |
| 29 | "{38, 77, 47, 97, 61, 126}" |
| 30 | STRING) |
| 31 | |
| 32 | USER_OPTION(${use_case}_ANCHOR_2 "Second anchor array estimated during training." |
| 33 | "{14, 26, 19, 37, 28, 55 }" |
| 34 | STRING) |
| 35 | |
| 36 | USER_OPTION(${use_case}_CHANNELS_IMAGE_DISPLAYED "Channels' image displayed on the LCD. Select 1 if grayscale, 3 if RGB." |
| 37 | 3 |
| 38 | BOOL) |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 39 | |
| 40 | # Generate input files |
| 41 | generate_images_code("${${use_case}_FILE_PATH}" |
| 42 | ${SRC_GEN_DIR} |
| 43 | ${INC_GEN_DIR} |
| 44 | "${${use_case}_IMAGE_SIZE}") |
| 45 | |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 46 | USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model" |
| 47 | 0x00082000 |
| 48 | STRING) |
| 49 | |
| 50 | if (ETHOS_U_NPU_ENABLED) |
| 51 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/yolo-fastest_192_face_v4_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite) |
| 52 | else() |
| 53 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/yolo-fastest_192_face_v4.tflite) |
| 54 | endif() |
| 55 | |
Isabella Gottardi | 3107aa2 | 2022-01-27 16:39:37 +0000 | [diff] [blame] | 56 | set(${use_case}_ORIGINAL_IMAGE_SIZE |
| 57 | ${${use_case}_IMAGE_SIZE} |
| 58 | CACHE STRING |
| 59 | "Original image size - for the post processing step to upscale the box co-ordinates.") |
| 60 | |
| 61 | set(EXTRA_MODEL_CODE |
| 62 | "extern const int originalImageSize = ${${use_case}_ORIGINAL_IMAGE_SIZE};" |
| 63 | "extern const int channelsImageDisplayed = ${${use_case}_CHANNELS_IMAGE_DISPLAYED};" |
| 64 | "/* NOTE: anchors are different for any given input model size, estimated during training phase */" |
| 65 | "extern const float anchor1[] = ${${use_case}_ANCHOR_1};" |
| 66 | "extern const float anchor2[] = ${${use_case}_ANCHOR_2};" |
| 67 | ) |
| 68 | |
Michael Levit | 06fcf75 | 2022-01-12 11:53:46 +0200 | [diff] [blame] | 69 | USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format." |
| 70 | ${DEFAULT_MODEL_PATH} |
| 71 | FILEPATH |
| 72 | ) |
| 73 | |
| 74 | # Generate model file |
| 75 | generate_tflite_code( |
| 76 | MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH} |
| 77 | DESTINATION ${SRC_GEN_DIR} |
Isabella Gottardi | 3107aa2 | 2022-01-27 16:39:37 +0000 | [diff] [blame] | 78 | EXPRESSIONS ${EXTRA_MODEL_CODE} |
Liam Barry | 213a543 | 2022-05-09 17:06:19 +0100 | [diff] [blame^] | 79 | NAMESPACE "arm" "app" "object_detection") |