Heart Rate Estimation
See the Data Annotation Format page for more information about the data format for Heart Rate Estimation.
HeartRateNet dataset conversion also requires an experiment spec to generate the TFRecords. A detailed description is included in the table below.
Field |
Description |
Data Type and Constraints |
Recommended/Typical Value |
|
A list of training subjects used to generate the |
List of Strings |
|
|
A list of the validation subjects used to generate the |
List of Strings |
|
|
A list of the test subjects used to generate the |
List of Strings |
|
|
The data input directory path |
String |
|
|
Place to save the generated TFRecords |
String |
|
|
The image crop size, which is the image input size to the model |
UnsignedInt |
72 |
|
The last frame to use in the video |
String / UnsignedInt |
‘all’ or 300 |
|
The frame number at which to begin preprocessing |
UnsignedInt |
60 |
|
The minimum frames required for the band pass filter to work |
UnsignedInt |
34 |
|
The frames per second of the captured video |
UnsignedInt |
30 |
|
The sampling frequency of the pulse oximeter |
UnsignedInt |
60 |
|
The lower cutoff frequency of the predicted PPG signal |
Float |
0.67 |
|
The upper cutoff frequency of the predicted PPG signal |
Float |
4.0 |
|
A parameter used for face detection |
Float |
1.3 |
|
A parameter used for face detection |
UnsignedInt |
5 |
|
A parameter used for face detection |
Float |
0.3 |
|
The lower beats per minute cutoff limit. Used for alignment of the green channel and is subtracted from the ground-truth heart rate. |
Float |
20.0 |
|
The upper beats per minute cutoff limit. Used for alignment of the green channel and is added to the ground truth heart rate. |
Float |
20.0 |
|
The model to generate the TFRecords for |
String |
HRNet_release |
To generate TFRecords, use the following command:
tao heartratenet dataset_convert -e <experiment_spec_file>
Required Arguments
-e, --experiment_spec_file
: The path to the dataset spec
Sample Usage
Here is an example of using dataset_convert
to generate TFRecords:
tao heartratenet dataset_convert -e /workspace/examples/heartratenet/specs/heartratenet_data_generation.yaml
The configuration file for HeartRateNet has four key components for training and evaluating the models. The key parts of the configuration files are given below.
The heartratenet train
and heartratenet evaluate
commands share the same
configuration file.
dataloader
: Configures the dataset.model
: Configures the model.loss
: Configures the loss.optimizer
: Configures the optimizer.
__class_name__: HeartRateNetTrainer
checkpoint_dir: "/workspace/tao-experiments/heartratenet/model/"
results_dir: "/workspace/tao-experiments/heartratenet/"
random_seed: 32
log_every_n_secs: 20
checkpoint_n_epoch: 1
num_epoch: 20
summary_every_n_steps: 1
infrequency_summary_every_n_steps: 0
last_step: 1
evaluation_window: 10
low_freq_cutoff: 0.67
high_freq_cutoff: 4.0
fps: 20.0
model_type: HRNet_release
dataloader:
__class_name__: HeartRateNetDataloader
image_info:
num_channels: 3
image_height: 72
image_width: 72
data_format: channels_first
dataset_info:
tfrecords_directory_path: /workspace/tao-experiments/heartratenet/data
tfrecord_folder_name: ''
tfrecord_train_file_name: train.tfrecord
tfrecord_test_file_name: test.tfrecord
tfrecord_validation_file_name: validation.tfrecord
model_info:
model_type: HRNet_release
model:
__class_name__: HeartRateNet
model_parameters:
input_size: 72
data_format: channels_first
conv_dropout_rate: 0.0
fully_connected_dropout_rate: 0.0
use_batch_norm: False
model_type: HRNet_release
frozen_blocks: 0
loss:
__class_name__: HeartRateNetLoss
loss_function_name: MSE
optimizer:
__class_name__: AdaDeltaOptimizer
rho: 0.95
epsilon: 1.0e-7
learning_rate_schedule:
__class_name__: ConstantLearningRateSchedule
learning_rate: 1.0
Field |
Description |
Data Type and Constraints |
Recommended/Typical Value |
|
The module name |
String |
HeartRateNetTrainer |
|
The checkpoint directory to save the model to |
String |
|
|
The directory to save the results to |
String |
|
|
The random seed to use |
Unsigned Int |
|
|
The time interval in seconds to log the loss |
Unsigned Int |
3000 |
|
The frequency for saving the current model |
Unsigned Int |
|
|
The number of epochs for training the model |
Unsigned Int |
|
|
The frequency for giving summaries |
Unsigned Int |
|
|
The evaluation window on the predicted blood volume pulse in seconds |
Unsigned Int |
10 |
|
Heart rate high frequency cut off in Hz |
Float |
0.67 |
|
Heart rate low frequency cut off in Hz |
Float |
0.40 |
|
Video frame rate in seconds |
Float |
|
|
The model to use |
String |
|
|
The dataloader configuration |
Message |
|
|
The model configuration |
Message |
|
|
The loss configuration |
Message |
|
|
The optimizer configuration |
Message |
Dataloader
The dataloader configuration defines how the data will be loaded.
Field |
Description |
Data Type and Constraints |
Recommended/Typical Value |
|
The number of channels used in the video |
Unsigned Int |
3 |
|
The image height |
Unsigned Int |
72 |
|
The image width |
Unsigned Int |
72 |
|
The channel format of the data |
String |
channels_first |
|
The path to the tfrecods directory |
String |
/workspace/tao-experiments /heartratenet/data |
|
The folder name for the tfrecords |
String |
“” |
|
The Tfrecord train filename |
String |
train.tfrecord |
|
The Tfrecord test filename |
String |
test.tfrecord |
|
The Tfrecord validation filename |
String |
validation.tfrecord |
|
The Model to use |
String |
HRNet_release |
Model
The model configuration allows you to customize your HeartRateNet model.
Field |
Description |
Data Type and Constraints |
Recommended/Typical Value |
|
The size of the image input to the model |
Unsigned Int |
72 |
|
The data format of the images |
String |
channels_first |
|
The convolution dropout rate |
Float |
0.1 |
|
The fully connected layer dropout rate |
Float |
0.1 |
|
A flag specifying whether to use batch normalization |
Bool |
False |
|
The model to use |
String |
HRNet_release |
|
The number of layers to freeze in the model starting from the first layer |
Unsigned Int |
0 |
Loss
The loss configuration allows you to pick between different losses.
Field |
Description |
Data Type and Constraints |
Recommended/Typical Value |
|
The loss function to use |
String |
MSE |
Optimizer
The optimizer configuration allows you to configure the optimizer.
Field |
Description |
Data Type and Constraints |
Recommended/Typical Value |
|
The optimizer class name to use |
String |
AdaDeltaOptimizer |
|
The parameter for the optimizer |
Float |
0.95 |
|
The learning rate to use |
Float |
1.0 |
Train the HeartRateNet model using the train
command:
tao heartratenet train -e <experiment_spec>
-k <key>
-r <results_dir>
-ll <log_level>
Required Arguments
-r, --results_dir
: The folder path where training logs are saved-k, --key
: The encryption key to decrypt the model-e, --experiment_spec_file
: The experiment specification file
Optional Arguments
-ll, --log_level
: The log level to use.
Sample Usage
Here’s an example of using the train
command on a HeartRateNet model:
tao heartratenet train -e /workspace/examples/heartratenet/specs/<config_file>.yaml
-k 'test'
-r /workspace/tao-experiments/gesturenet/
Use the evaluate
command to run evaluation for a HeartRateNet model:
tao heartratenet evaluate -e <experiment_spec_file>
-m <model_folder_path>
-k <key>
-r <results_dir>
Required Arguments
-e, --experiment_spec_file
: The experiment spec file to set up evaluation experiment-m, --model_folder_path
: The model folder path where the models are saved-k, --key
: The encryption key used to train the model-r, --results_dir
: The directory to save the evaluation results
Optional Arguments
-ll, --log_level
: The log level to use.
To run inference for a HeartRateNet model, use this command:
tao heartratenet inference -m <model_full_path>
--subject_infer_dir <subject_infer_dir>
--subject <subject>
-f <video fps>
-r <results_dir>
-c <channels_format>
-ll <log_level>
-k <key>
Required Arguments
-m, --model_full_path
: Path to the model to use.--subject_infer_dir
: Path to the subject inference directory.-f, --fps
: FPS for input video-k, --key
: Encryption key that was used to train the model.--subject
: Subject to run inference on.-r, --results_dir
: Directory to save the results.
Optional Arguments
-i, --input_size
: Size of input crop to network-lf, --low_freq
: Low band for band pass filter-hf, --high_freq
: High band for band pass filter-c, --channels_format
: Channel format of data input.-ll, --log_level
: Log level to use.
HeartRateNet includes the heartratenet export
command to export the trained model to
TAO format. To generate an encoded TAO model, use the following commands:
tao heartratenet export -m <model_filename>
-k <key>
-o <output_file>
--log_level <log_level>
Required Arguments
-m, --model_filename
: The absolute path to the desired model file-k, --key
: The encryption key to use-o, --out_file
: The absolute path for the desired exported model
Optional Arguments
-t, --export_type
: The export type to use-ll, --log_level
: The log level to use
The pretrained model for HeartRateNet provided through NGC is available by default with DeepStream 6.0.
For more details, refer to DeepStream TAO Integration for HeartRateNet.