blob: d19820d804708d6ccfa1aa7b442836f30dc9fbf9 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2021 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#----------------------------------------------------------------------------
17
Kshitij Sisodiaaa4bcb12022-05-06 09:13:03 +010018# Append the API to use for this use case
19list(APPEND ${use_case}_API_LIST "ad")
20
alexander3c798932021-03-26 21:42:19 +000021USER_OPTION(${use_case}_FILE_PATH "Directory with custom WAV input files, or path to a single input WAV file, to use in the evaluation application."
22 ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010023 PATH_OR_FILE)
alexander3c798932021-03-26 21:42:19 +000024
25USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 16000."
26 16000
27 STRING)
28
29USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON."
30 ON
31 BOOL)
32
33USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0."
34 0
35 STRING)
36
37USER_OPTION(${use_case}_AUDIO_DURATION "Specify the audio duration to load (in seconds). If set to 0 the entire audio will be processed."
38 0
39 STRING)
40
41USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'."
42 kaiser_best
43 STRING)
44
45USER_OPTION(${use_case}_AUDIO_MIN_SAMPLES "Specify the minimum number of samples to use. By default is amount needed to do one inference,
46 if the audio is shorter then it will be automatically padded."
47 33280
48 STRING)
49
50USER_OPTION(${use_case}_MODEL_SCORE_THRESHOLD "Specify the score threshold for a result to be deemed anomalous."
51 -0.8
52 STRING)
53
54generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR}
55 ${${use_case}_AUDIO_RATE}
56 ${${use_case}_AUDIO_MONO}
57 ${${use_case}_AUDIO_OFFSET}
58 ${${use_case}_AUDIO_DURATION}
59 ${${use_case}_AUDIO_RES_TYPE}
60 ${${use_case}_AUDIO_MIN_SAMPLES})
61
62USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
63 0x00200000
64 STRING)
65
Cisco Cervelleraf085fa52021-08-02 09:32:07 +010066if (ETHOS_U_NPU_ENABLED)
Kshitij Sisodia3be26232021-10-29 12:29:06 +010067 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite)
alexander3c798932021-03-26 21:42:19 +000068else()
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010069 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8.tflite)
alexander3c798932021-03-26 21:42:19 +000070endif()
71
72set(EXTRA_MODEL_CODE
73 "/* Model parameters for ${use_case} */"
74 "extern const int g_FrameLength = 1024"
75 "extern const int g_FrameStride = 512"
76 "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD}"
77 "extern const float g_TrainingMean = -30"
78 )
79
80USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
81 ${DEFAULT_MODEL_PATH}
82 FILEPATH)
83
84# Generate model file
85generate_tflite_code(
86 MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH}
87 DESTINATION ${SRC_GEN_DIR}
88 EXPRESSIONS ${EXTRA_MODEL_CODE}
Liam Barry213a5432022-05-09 17:06:19 +010089 NAMESPACE "arm" "app" "ad")