Task-Level Demo
Introduction
Each task in HeartKit has a corresponding demo mode that allows you to run a task-level demonstration using the specified backend inference engine (e.g. PC or EVB). This is useful to showcase the model's performance in real-time and to verify its accuracy in a real-world scenario. Similar to other modes, the demo can be invoked either via CLI or within heartkit
python package. At a high level, the demo mode performs the following actions based on the provided configuration parameters:
- Load the configuration data (e.g.
configuration.json
) - Load the desired datasets (e.g.
icentia11k
) - Load the trained model (e.g.
model.keras
) - Initialize inference engine backend (e.g.
pc
orevb
) - Generate input data (e.g.
x, y
) - Perform inference on backend (e.g.
model.predict
) - Generate report (e.g.
report.html
)
graph LR
A("`Load
configuration
__HKTaskParams__
`")
B("`Load
datasets
__DatasetFactory__
`")
C("`Load trained
__model__
`")
D("`Initialize
inference engine
__BackendFactory__
`")
E("`Generate
input stimulus
`")
F("`Perform
__inference(s)__
`")
G("`Generate
__report__
`")
A ==> B
B ==> C
C ==> D
subgraph CF["Inference Engine"]
D ==> E
E ==> F
end
F ==> G
Backend Inference Engines
HeartKit includes two built-in backend inference engines: PC and EVB. Additional backends can be easily added to the HeartKit framework by creating a new backend class and registering it to the backend factory, BackendFactory
.
PC Backend Inference Engine
The PC backend is used to run the task-level demo on the local machine via Keras
. This is useful for quick testing and debugging of the model.
- Create / modify configuration file (e.g.
configuration.json
) - Ensure "pc" is selected as the backend in configuration file.
- Run demo
heartkit --mode demo --task segmentation --config ./configuration.json
- HTML report will be saved to
${job_dir}/report.html
EVB Backend Inference Engine
The EVB backend is used to run the task-level demo on an Ambiq EVB. This is useful to showcase the model's performance in real-time and to verify its accuracy on deployed hardware.
- Create / modify configuration file (e.g.
configuration.json
) - Ensure "evb" is selected as the
backend
in configuration file. - Plug EVB into PC via two USB-C cables.
- Run demo
heartkit --mode demo --task beat --config ./configuration.json
- HTML report will be saved to
${job_dir}/report.html
Bring-Your-Own-Backend Engine
Similar to datasets, dataloaders, tasks, and models, the demo mode can be customized to use your own backend inference engine. HeartKit includes a backend factory (BackendFactory
) that is used to create and run the backend engine.
How it Works
-
Create a Backend: Define a new backend class that inherits from the HKInferenceBackend base class and implements the required abstract methods.
-
Register the Backend: Register the new backend with the BackendFactory by calling the
register
method. This method takes the backend name and the backend class as arguments. -
Use the Backend: The new backend can now be used by setting the
backend
flag in the demo configuration settings.
Usage
The following is an example of a task-level demo report for the segmentation task. Upon running segmentation, the demo will extract inter-beat-intervals (IBIs) and report various HR and HRV metrics. These metrics are computed using Ambiq's PhysioKit Python Package- a toolkit to process raw ambulatory bio-signals.
Arguments
Please refer to HKTaskParams for the list of arguments that can be used with the demo
command.