blob: d591f98b25621a807f3b577d23eeb1045b4b21d3 [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
alexander3c798932021-03-26 21:42:19 +000018USER_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."
19 ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010020 PATH_OR_FILE)
alexander3c798932021-03-26 21:42:19 +000021
22USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 16000."
23 16000
24 STRING)
25
26USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON."
27 ON
28 BOOL)
29
30USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0."
31 0
32 STRING)
33
34USER_OPTION(${use_case}_AUDIO_DURATION "Specify the audio duration to load (in seconds). If set to 0 the entire audio will be processed."
35 0
36 STRING)
37
38USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'."
39 kaiser_best
40 STRING)
41
42USER_OPTION(${use_case}_AUDIO_MIN_SAMPLES "Specify the minimum number of samples to use. By default is amount needed to do one inference,
43 if the audio is shorter then it will be automatically padded."
44 33280
45 STRING)
46
47USER_OPTION(${use_case}_MODEL_SCORE_THRESHOLD "Specify the score threshold for a result to be deemed anomalous."
48 -0.8
49 STRING)
50
51generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR}
52 ${${use_case}_AUDIO_RATE}
53 ${${use_case}_AUDIO_MONO}
54 ${${use_case}_AUDIO_OFFSET}
55 ${${use_case}_AUDIO_DURATION}
56 ${${use_case}_AUDIO_RES_TYPE}
57 ${${use_case}_AUDIO_MIN_SAMPLES})
58
59USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
60 0x00200000
61 STRING)
62
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010063if (ETHOS_U55_ENABLED)
64 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8_vela.tflite)
alexander3c798932021-03-26 21:42:19 +000065else()
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010066 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8.tflite)
alexander3c798932021-03-26 21:42:19 +000067endif()
68
69set(EXTRA_MODEL_CODE
70 "/* Model parameters for ${use_case} */"
71 "extern const int g_FrameLength = 1024"
72 "extern const int g_FrameStride = 512"
73 "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD}"
74 "extern const float g_TrainingMean = -30"
75 )
76
77USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
78 ${DEFAULT_MODEL_PATH}
79 FILEPATH)
80
81# Generate model file
82generate_tflite_code(
83 MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH}
84 DESTINATION ${SRC_GEN_DIR}
85 EXPRESSIONS ${EXTRA_MODEL_CODE}
86)