alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
Richard Burton | f32a86a | 2022-11-15 11:46:11 +0000 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com> |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [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 | #---------------------------------------------------------------------------- |
| 17 | |
Kshitij Sisodia | aa4bcb1 | 2022-05-06 09:13:03 +0100 | [diff] [blame] | 18 | # Append the API to use for this use case |
| 19 | list(APPEND ${use_case}_API_LIST "ad") |
| 20 | |
Eanna O Cathain | 4c0ac91 | 2022-09-22 15:18:34 +0100 | [diff] [blame] | 21 | set_input_file_path_user_option(".wav" ${use_case}) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 22 | |
| 23 | USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 16000." |
| 24 | 16000 |
| 25 | STRING) |
| 26 | |
| 27 | USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON." |
| 28 | ON |
| 29 | BOOL) |
| 30 | |
| 31 | USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0." |
| 32 | 0 |
| 33 | STRING) |
| 34 | |
| 35 | USER_OPTION(${use_case}_AUDIO_DURATION "Specify the audio duration to load (in seconds). If set to 0 the entire audio will be processed." |
| 36 | 0 |
| 37 | STRING) |
| 38 | |
| 39 | USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'." |
| 40 | kaiser_best |
| 41 | STRING) |
| 42 | |
| 43 | USER_OPTION(${use_case}_AUDIO_MIN_SAMPLES "Specify the minimum number of samples to use. By default is amount needed to do one inference, |
| 44 | if the audio is shorter then it will be automatically padded." |
| 45 | 33280 |
| 46 | STRING) |
| 47 | |
| 48 | USER_OPTION(${use_case}_MODEL_SCORE_THRESHOLD "Specify the score threshold for a result to be deemed anomalous." |
| 49 | -0.8 |
| 50 | STRING) |
| 51 | |
| 52 | generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR} |
| 53 | ${${use_case}_AUDIO_RATE} |
| 54 | ${${use_case}_AUDIO_MONO} |
| 55 | ${${use_case}_AUDIO_OFFSET} |
| 56 | ${${use_case}_AUDIO_DURATION} |
| 57 | ${${use_case}_AUDIO_RES_TYPE} |
| 58 | ${${use_case}_AUDIO_MIN_SAMPLES}) |
| 59 | |
| 60 | USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model" |
| 61 | 0x00200000 |
| 62 | STRING) |
| 63 | |
Cisco Cervellera | f085fa5 | 2021-08-02 09:32:07 +0100 | [diff] [blame] | 64 | if (ETHOS_U_NPU_ENABLED) |
Kshitij Sisodia | 3be2623 | 2021-10-29 12:29:06 +0100 | [diff] [blame] | 65 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 66 | else() |
Isabella Gottardi | 2181d0a | 2021-04-07 09:27:38 +0100 | [diff] [blame] | 67 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8.tflite) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 68 | endif() |
| 69 | |
| 70 | set(EXTRA_MODEL_CODE |
| 71 | "/* Model parameters for ${use_case} */" |
| 72 | "extern const int g_FrameLength = 1024" |
| 73 | "extern const int g_FrameStride = 512" |
| 74 | "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD}" |
| 75 | "extern const float g_TrainingMean = -30" |
| 76 | ) |
| 77 | |
| 78 | USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format." |
| 79 | ${DEFAULT_MODEL_PATH} |
| 80 | FILEPATH) |
| 81 | |
| 82 | # Generate model file |
| 83 | generate_tflite_code( |
| 84 | MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH} |
| 85 | DESTINATION ${SRC_GEN_DIR} |
| 86 | EXPRESSIONS ${EXTRA_MODEL_CODE} |
Liam Barry | 213a543 | 2022-05-09 17:06:19 +0100 | [diff] [blame] | 87 | NAMESPACE "arm" "app" "ad") |