From 16fd2080bd11b339f65e9b76c352232df7f95121 Mon Sep 17 00:00:00 2001 From: Adam Page Date: Fri, 16 Aug 2024 22:38:53 +0000 Subject: [PATCH] chore: Remove unused assets. --- docs/assets/modes/python-download-snippet.md | 10 --- docs/assets/modes/python-evaluate-snippet.md | 38 ----------- docs/assets/modes/python-export-snippet.md | 37 ----------- docs/assets/modes/python-train-snippet.md | 37 ----------- docs/assets/usage/python-demo-snippet.md | 29 --------- docs/assets/usage/python-download-snippet.md | 10 --- docs/assets/usage/python-evaluate-snippet.md | 38 ----------- docs/assets/usage/python-export-snippet.md | 68 -------------------- docs/assets/usage/python-full-snippet.md | 23 ------- docs/assets/usage/python-train-snippet.md | 39 ----------- heartkit/models/__init__.py | 4 +- 11 files changed, 2 insertions(+), 331 deletions(-) delete mode 100644 docs/assets/modes/python-download-snippet.md delete mode 100644 docs/assets/modes/python-evaluate-snippet.md delete mode 100644 docs/assets/modes/python-export-snippet.md delete mode 100644 docs/assets/modes/python-train-snippet.md delete mode 100644 docs/assets/usage/python-demo-snippet.md delete mode 100644 docs/assets/usage/python-download-snippet.md delete mode 100644 docs/assets/usage/python-evaluate-snippet.md delete mode 100644 docs/assets/usage/python-export-snippet.md delete mode 100644 docs/assets/usage/python-full-snippet.md delete mode 100644 docs/assets/usage/python-train-snippet.md diff --git a/docs/assets/modes/python-download-snippet.md b/docs/assets/modes/python-download-snippet.md deleted file mode 100644 index 111d40ae..00000000 --- a/docs/assets/modes/python-download-snippet.md +++ /dev/null @@ -1,10 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -hk.datasets.download_datasets(hk.HKDownloadParams( - ds_path=Path("./datasets"), - datasets=["icentia11k", "ludb", "qtdb", "ecg-synthetic"], - progress=True -)) -``` diff --git a/docs/assets/modes/python-evaluate-snippet.md b/docs/assets/modes/python-evaluate-snippet.md deleted file mode 100644 index 0244d714..00000000 --- a/docs/assets/modes/python-evaluate-snippet.md +++ /dev/null @@ -1,38 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -task = hk.TaskFactory.get("rhythm") -task.evaluate(hk.HKTestParams( - job_dir=Path("./results/rhythm-class-2"), - ds_path=Path("./datasets"), - datasets=[{ - "name": "icentia11k", - "params": {} - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - test_samples_per_patient=[100, 800], - test_patients=1000, - test_size=100000, - data_parallelism=lambda: os.cpu_count() or 1, - preprocesses=[ - hk.PreprocessParams( - name="znorm", - params=dict( - eps=0.01, - axis=None - ) - ) - ] -)) -``` diff --git a/docs/assets/modes/python-export-snippet.md b/docs/assets/modes/python-export-snippet.md deleted file mode 100644 index 79674ed6..00000000 --- a/docs/assets/modes/python-export-snippet.md +++ /dev/null @@ -1,37 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -task = hk.TaskFactory.get("rhythm") -task.export(hk.HKExportParams( - job_dir=Path("./results/rhythm-class-2"), - ds_path=Path("./datasets"), - datasets=[{ - "name": "icentia11k", - "params": {} - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - test_samples_per_patient=[100, 500, 100], - model_file=Path("./results/rhythm-class-2/model.keras"), - quantization={ - enabled=True, - qat=False, - ptq=True, - input_type="int8", - output_type="int8", - }, - threshold=0.95, - tflm_var_name="g_arrhythmia_model", - tflm_file=Path("./results/rhythm-class-2/arrhythmia_model_buffer.h") -)) -``` diff --git a/docs/assets/modes/python-train-snippet.md b/docs/assets/modes/python-train-snippet.md deleted file mode 100644 index 1b8d0bb0..00000000 --- a/docs/assets/modes/python-train-snippet.md +++ /dev/null @@ -1,37 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -task = hk.TaskFactory.get("rhythm") -task.train(hk.HKTrainParams( - job_dir=Path("./results/rhythm-class-2"), - ds_path=Path("./datasets"), - datasets=[{ - "name": "icentia11k", - "params": {} - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - samples_per_patient=[100, 800], - val_samples_per_patient=[100, 800], - data_parallelism=lambda: os.cpu_count() or 1, - preprocesses=[ - hk.PreprocessParams( - name="znorm", - params=dict( - eps=0.01, - axis=None - ) - ) - ] -)) -``` diff --git a/docs/assets/usage/python-demo-snippet.md b/docs/assets/usage/python-demo-snippet.md deleted file mode 100644 index fed3bb83..00000000 --- a/docs/assets/usage/python-demo-snippet.md +++ /dev/null @@ -1,29 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -task = hk.TaskFactory.get("rhythm") - -task.demo(hk.HKTaskParams( - job_dir=Path("./results/rhythm-class-2"), - datasets=[{ - "name": "icentia11k", - "params": dict( - path=Path("./datasets/icentia11k") - ) - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - model_file=Path("./results/rhythm-class-2/model.tflite"), - backend="pc" -)) -``` diff --git a/docs/assets/usage/python-download-snippet.md b/docs/assets/usage/python-download-snippet.md deleted file mode 100644 index 111d40ae..00000000 --- a/docs/assets/usage/python-download-snippet.md +++ /dev/null @@ -1,10 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -hk.datasets.download_datasets(hk.HKDownloadParams( - ds_path=Path("./datasets"), - datasets=["icentia11k", "ludb", "qtdb", "ecg-synthetic"], - progress=True -)) -``` diff --git a/docs/assets/usage/python-evaluate-snippet.md b/docs/assets/usage/python-evaluate-snippet.md deleted file mode 100644 index 2eb056b6..00000000 --- a/docs/assets/usage/python-evaluate-snippet.md +++ /dev/null @@ -1,38 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -task = hk.TaskFactory.get("rhythm") - -params = hk.HKTaskParams( - job_dir=Path("./results/rhythm-class-2"), - ds_path=Path("./datasets"), - datasets=[{ - "name": "icentia11k", - "params": {} - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - samples_per_patient=[100, 800], - val_samples_per_patient=[100, 800], - train_patients=10000, - val_patients=0.10, - val_size=200000, - batch_size=256, - buffer_size=100000, - epochs=100, - steps_per_epoch=20, - val_metric="loss", -) - -task.evaluate(params) -``` diff --git a/docs/assets/usage/python-export-snippet.md b/docs/assets/usage/python-export-snippet.md deleted file mode 100644 index 959e62b6..00000000 --- a/docs/assets/usage/python-export-snippet.md +++ /dev/null @@ -1,68 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -task = hk.TaskFactory.get("rhythm") - -params = hk.HKTaskParams( - job_dir=Path("./results/rhythm-class-2"), - ds_path=Path("./datasets"), - datasets=[{ - "name": "icentia11k", - "params": {} - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - samples_per_patient=[100, 800], - val_samples_per_patient=[100, 800], - train_patients=10000, - val_patients=0.10, - val_size=200000, - batch_size=256, - buffer_size=100000, - epochs=100, - steps_per_epoch=20, - val_metric="loss", -) - -task.export(hk.HKExportParams( - job_dir=Path("./results/rhythm-class-2"), - ds_path=Path("./datasets"), - datasets=[{ - "name": "icentia11k", - "params": {} - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - test_samples_per_patient=[100, 500, 100], - model_file=Path("./results/rhythm-class-2/model.keras"), - quantization={ - enabled=True, - qat=False, - ptq=True, - input_type="int8", - output_type="int8", - }, - threshold=0.95, - tflm_var_name="g_arrhythmia_model", - tflm_file=Path("./results/rhythm-class-2/arrhythmia_model_buffer.h") -)) -``` diff --git a/docs/assets/usage/python-full-snippet.md b/docs/assets/usage/python-full-snippet.md deleted file mode 100644 index 7e021be7..00000000 --- a/docs/assets/usage/python-full-snippet.md +++ /dev/null @@ -1,23 +0,0 @@ -```python -import heartkit as hk - -ds_params = hk.HKDownloadParams.parse_file("download-datasets.json") -train_params = hk.HKTrainParams.parse_file("train.json") -test_params = hk.HKTestParams.parse_file("evaluate.json") -export_params = hk.HKExportParams.parse_file("export.json") - -# Download datasets -hk.datasets.download_datasets(ds_params) - -task = hk.TaskFactory.get("rhythm") - -# Train rhythm model -task.train(train_params) - -# Evaluate rhythm model -task.evaluate(test_params) - -# Export rhythm model -task.export(export_params) - -``` diff --git a/docs/assets/usage/python-train-snippet.md b/docs/assets/usage/python-train-snippet.md deleted file mode 100644 index eb5ad663..00000000 --- a/docs/assets/usage/python-train-snippet.md +++ /dev/null @@ -1,39 +0,0 @@ -```python -from pathlib import Path -import heartkit as hk - -task = hk.TaskFactory.get("rhythm") - -params = hk.HKTaskParams( - job_dir=Path("./results/rhythm-class-2"), - ds_path=Path("./datasets"), - datasets=[{ - "name": "icentia11k", - "params": {} - }], - num_classes=2, - class_map={ - 0: 0, - 1: 1, - 2: 1 - }, - class_names=[ - "NONE", "AFIB/AFL" - ], - sampling_rate=200, - frame_size=800, - samples_per_patient=[100, 800], - val_samples_per_patient=[100, 800], - train_patients=10000, - val_patients=0.10, - val_size=200000, - batch_size=256, - buffer_size=100000, - epochs=100, - steps_per_epoch=20, - val_metric="loss", -) - -task.train(params) - -``` diff --git a/heartkit/models/__init__.py b/heartkit/models/__init__.py index e8ffb8cd..23271e71 100644 --- a/heartkit/models/__init__.py +++ b/heartkit/models/__init__.py @@ -10,6 +10,8 @@ class ModelFactoryItem(Protocol): + def __call__(self, x: keras.KerasTensor, params: dict, num_classes: int) -> keras.Model: ... + """ModelFactoryItem is a protocol for model factory items. Args: @@ -21,8 +23,6 @@ class ModelFactoryItem(Protocol): keras.Model: Model """ - def __call__(self, x: keras.KerasTensor, params: dict, num_classes: int) -> keras.Model: ... - ModelFactory = nse.utils.ItemFactory[ModelFactoryItem].shared("HKModelFactory")