Skip to content

Commit

Permalink
WIP: Refactor almost complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
apage224 committed Aug 15, 2024
1 parent 9903820 commit 1fb6007
Show file tree
Hide file tree
Showing 206 changed files with 12,256 additions and 9,765 deletions.
7 changes: 0 additions & 7 deletions .clang-format

This file was deleted.

11 changes: 2 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
"ppa": true,
"version": "latest"
},
"ghcr.io/devcontainers/features/nvidia-cuda:1": {
"installCudnn": true,
"installCudnnDev": true,
"installNvtx": true,
"installToolkit": true,
"cudaVersion": "12.2",
"cudnnVersion": "8.9.5.29"
},
"ghcr.io/devcontainers-contrib/features/pipenv:2": {
"version": "latest"
}
Expand All @@ -31,10 +23,11 @@

"forwardPorts": [6006],

"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
"postCreateCommand": "./.devcontainer/install.sh",

"remoteEnv": {
"LD_LIBRARY_PATH": "${containerEnv:LD_LIBRARY_PATH}:/usr/local/cuda/lib64",
"PATH": "${containerEnv:PATH}:/usr/local/cuda/bin",
"TF_FORCE_GPU_ALLOW_GROWTH": "true"
}
}
54 changes: 54 additions & 0 deletions .devcontainer/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

export DEBIAN_FRONTEND=noninteractive

sudo apt update
sudo apt install -y libopenblas-dev libyaml-dev ffmpeg wget ca-certificates

# Install CUDA and cuDNN if not already installed
if ! command -v nvcc &> /dev/null; then

CUDA_VERSION="12.3"
CUDNN_VERSION="8.9.7.29-1+cuda12.2" # Not sure why no 12.3

NVIDIA_REPO_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64"
KEYRING_PACKAGE="cuda-keyring_1.1-1_all.deb"
KEYRING_PACKAGE_URL="$NVIDIA_REPO_URL/$KEYRING_PACKAGE"
KEYRING_PACKAGE_PATH="$(mktemp -d)"
KEYRING_PACKAGE_FILE="$KEYRING_PACKAGE_PATH/$KEYRING_PACKAGE"
wget -O "$KEYRING_PACKAGE_FILE" "$KEYRING_PACKAGE_URL"
sudo apt install -yq "$KEYRING_PACKAGE_FILE"
sudo apt update -yq

# Install CUDA libraries
cuda_pkg="cuda-libraries-${CUDA_VERSION/./-}"
sudo apt install -yq "$cuda_pkg"

# Install cuDNN
cudnn_pkg="libcudnn8=${CUDNN_VERSION}"
sudo apt install -yq "$cudnn_pkg_version"

# Install cuDNN dev
cudnn_dev_pkg="libcudnn8-dev=${CUDNN_VERSION}"
sudo apt install -yq "$cudnn_dev_pkg"

# Install NVTX
nvtx_pkg="cuda-nvtx-${CUDA_VERSION/./-}"
sudo apt install -yq "$nvtx_pkg"

# Install CUDA Toolkit
toolkit_pkg="cuda-toolkit-${CUDA_VERSION/./-}"
sudo apt install -yq "$toolkit_pkg"

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-${CUDA_VERSION}/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

# Clean up
sudo rm -rf /var/lib/apt/lists/*
fi

# Install poetry
pipx install poetry --pip-args '--no-cache-dir --force-reinstall'

# Install project dependencies
poetry install
9 changes: 0 additions & 9 deletions .devcontainer/postCreateCommand.sh

This file was deleted.

49 changes: 20 additions & 29 deletions configs/arr-2-eff-sm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"name": "arr-2-eff-sm",
"project": "hk-rhythm-2",
"job_dir": "./results/arr-2-eff-sm",
"verbose": 2,
"dataset_weights": [0.32, 0.68],
"datasets": [{
"name": "icentia11k",
"path": "./datasets/icentia11k",
"params": {}
}, {
"name": "ptbxl",
"path": "./datasets/ptbxl",
"params": {}
"params": {
"path": "./datasets/ptbxl"
}
}, {
"name": "lsad",
"path": "./datasets/lsad",
"params": {}
"params": {
"path": "./datasets/lsad"
}
}],
"num_classes": 2,
"class_map": {
Expand All @@ -24,16 +24,14 @@
"class_names": [
"NORMAL", "AFIB/AFL"
],
"class_weights": "balanced",
"sampling_rate": 100,
"frame_size": 512,
"model_file": "model.keras",
"use_logits": false,
"samples_per_patient": [10, 10],
"val_samples_per_patient": [10, 10],
"val_file": "./results/${task}-class-2-${dataset}-${sampling_rate}fs-${frame_size}sz.pkl",
"test_file": "./results/${task}-class-2-${dataset}-${sampling_rate}fs-${frame_size}sz.pkl",
"val_samples_per_patient": [5, 5],
"test_samples_per_patient": [5, 5],
"val_patients": 0.20,
"test_samples_per_patient": [10, 10],
"val_size": 40000,
"test_size": 40000,
"batch_size": 256,
"buffer_size": 50000,
Expand All @@ -42,9 +40,8 @@
"val_metric": "loss",
"lr_rate": 1e-3,
"lr_cycles": 1,
"class_weights": "balanced",
"threshold": 0.75,
"val_acc_threshold": 0.98,
"val_metric_threshold": 0.98,
"tflm_var_name": "g_rhythm_model",
"tflm_file": "rhythm_model_buffer.h",
"backend": "pc",
Expand All @@ -59,23 +56,17 @@
},
"preprocesses": [
{
"name": "filter",
"params": {
"lowcut": 1.0,
"highcut": 30,
"order": 3,
"forward_backward": true,
"axis": 0
}
},
{
"name": "znorm",
"name": "layer_norm",
"params": {
"eps": 0.01,
"axis": null
"epsilon": 0.01,
"name": "znorm"
}
}
],
"augmentations": [
],
"model_file": "model.keras",
"use_logits": false,
"architecture": {
"name": "efficientnetv2",
"params": {
Expand Down
117 changes: 56 additions & 61 deletions configs/arr-4-eff-lg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"name": "arr-4-eff-lg",
"project": "hk-rhythm-4",
"job_dir": "./results/arr-4-eff-lg",
"verbose": 2,
"datasets": [{
"name": "lsad",
"path": "./datasets/lsad",
"params": {
"path": "./datasets/lsad"
}
}],
"num_classes": 4,
Expand All @@ -20,27 +21,24 @@
"class_names": [
"SR", "SB", "AFIB", "GSVT"
],
"class_weights": "balanced",
"sampling_rate": 100,
"frame_size": 800,
"model_file": "model.keras",
"use_logits": true,
"samples_per_patient": [5, 5, 5, 10],
"val_file": "./results/${task}-class-4-${dataset}-${sampling_rate}fs-${frame_size}sz-noaug.pkl",
"test_file": "./results/${task}-class-4-${dataset}-${sampling_rate}fs-${frame_size}sz-noaug.pkl",
"val_samples_per_patient": [5, 5, 5, 10],
"val_patients": 0.20,
"test_samples_per_patient": [5, 5, 5, 10],
"val_patients": 0.20,
"val_size": 40000,
"test_size": 50000,
"batch_size": 256,
"buffer_size": 50000,
"epochs": 100,
"epochs": 150,
"steps_per_epoch": 50,
"val_metric": "loss",
"lr_rate": 1e-3,
"lr_cycles": 1,
"class_weights": "balanced",
"threshold": 0.5,
"val_acc_threshold": 0.98,
"val_metric_threshold": 0.98,
"tflm_var_name": "g_rhythm_model",
"tflm_file": "rhythm_model_buffer.h",
"backend": "pc",
Expand All @@ -55,23 +53,58 @@
},
"preprocesses": [
{
"name": "filter",
"name": "layer_norm",
"params": {
"lowcut": 1.0,
"highcut": 30,
"order": 3,
"forward_backward": true,
"axis": 0
}
},
{
"name": "znorm",
"params": {
"eps": 0.01,
"axis": null
"epsilon": 0.01,
"name": "znorm"
}
}
],
"augmentations-dis": [{
"name": "random_noise_distortion",
"params": {
"amplitude": [0.01, 0.5],
"frequency": [0.5, 1.5],
"name": "baseline_wander"
}
},{
"name": "random_sine_wave",
"params": {
"amplitude": [0.01, 0.05],
"frequency": [45, 50],
"auto_vectorize": false,
"name": "powerline_noise"
}
},{
"name": "amplitude_warp",
"params": {
"amplitude": [0.99, 1.01],
"frequency": [0.5, 1.5],
"name": "amplitude_warp"
}
}, {
"name": "random_noise",
"params": {
"factor": [0.005, 0.05],
"name": "random_noise"
}
}, {
"name": "random_background_noise",
"params": {
"amplitude": [0.005, 0.1],
"num_noises": 1,
"name": "nstdb"
}
},{
"name": "random_cutout",
"params": {
"cutouts": 2,
"factor": [0.005, 0.01],
"name": "cutout"
}
}],
"model_file": "model.keras",
"use_logits": true,
"architecture": {
"name": "efficientnetv2",
"params": {
Expand All @@ -89,43 +122,5 @@
"include_top": true,
"use_logits": true
}
},
"augmentations-dis": [
{
"name": "baseline_wander",
"params": {
"amplitude": [0.0, 0.2],
"frequency": [0.5, 1.5]
}
},
{
"name": "powerline_noise",
"params": {
"amplitude": [0.0, 0.15],
"frequency": [45, 50]
}
},
{
"name": "burst_noise",
"params": {
"burst_number": [0, 4],
"amplitude": [0.0, 0.1],
"frequency": [20, 49]
}
},
{
"name": "noise_sources",
"params": {
"num_sources": [1, 2],
"amplitude": [0.0, 0.1],
"frequency": [10, 40]
}
},
{
"name": "lead_noise",
"params": {
"scale": [0.05, 0.2]
}
}
]
}
}
Loading

0 comments on commit 1fb6007

Please sign in to comment.