Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- ARCHITECTURE.md +14 -14
- README.md +25 -31
ARCHITECTURE.md
CHANGED
|
@@ -21,32 +21,32 @@ graph TD
|
|
| 21 |
|
| 22 |
subgraph Client [Client Application / Next.js 16]
|
| 23 |
direction TB
|
| 24 |
-
UI["
|
| 25 |
-
WS_Client["WebSocket
|
| 26 |
-
HTTP_Client["HTTP
|
| 27 |
end
|
| 28 |
|
| 29 |
subgraph Core [FastAPI Core / Python 3.10+]
|
| 30 |
direction TB
|
| 31 |
-
WS_Server["
|
| 32 |
-
REST_API["REST API Router<br/>
|
| 33 |
-
Simulator["Vitals Simulator<br/>
|
| 34 |
-
DB["SQLite
|
| 35 |
end
|
| 36 |
|
| 37 |
subgraph ML_Layer [Intelligence Pipeline / Scikit-Learn]
|
| 38 |
direction TB
|
| 39 |
-
Inference["Inference
|
| 40 |
-
Ensemble["Soft-Voting
|
| 41 |
-
Training["Model Training<br/>
|
| 42 |
-
EdgeCompiler["C-Code Exporter<br/>
|
| 43 |
end
|
| 44 |
|
| 45 |
subgraph Storage [Persistence & Hardware]
|
| 46 |
direction TB
|
| 47 |
-
ModelWeights["Model Artifacts<br/>
|
| 48 |
-
CSV["Patient Dataset<br/>
|
| 49 |
-
MCU["Edge Silicon
|
| 50 |
end
|
| 51 |
|
| 52 |
%% Flows
|
|
|
|
| 21 |
|
| 22 |
subgraph Client [Client Application / Next.js 16]
|
| 23 |
direction TB
|
| 24 |
+
UI["Views<br/>(page.tsx)"]:::frontend
|
| 25 |
+
WS_Client["WebSocket<br/>(TelemetryContext.tsx)"]:::frontend
|
| 26 |
+
HTTP_Client["HTTP Fetch"]:::frontend
|
| 27 |
end
|
| 28 |
|
| 29 |
subgraph Core [FastAPI Core / Python 3.10+]
|
| 30 |
direction TB
|
| 31 |
+
WS_Server["WebSocket Broker<br/>(main.py)"]:::backend
|
| 32 |
+
REST_API["REST API Router<br/>(main.py)"]:::backend
|
| 33 |
+
Simulator["Vitals Simulator<br/>(simulator.py)"]:::backend
|
| 34 |
+
DB["SQLite & aiosqlite<br/>(database.py)"]:::backend
|
| 35 |
end
|
| 36 |
|
| 37 |
subgraph ML_Layer [Intelligence Pipeline / Scikit-Learn]
|
| 38 |
direction TB
|
| 39 |
+
Inference["Inference<br/>(inference.py)"]:::ml_node
|
| 40 |
+
Ensemble["Soft-Voting<br/>(ensemble.py)"]:::ml_node
|
| 41 |
+
Training["Model Training<br/>(models.py)"]:::ml_node
|
| 42 |
+
EdgeCompiler["C-Code Exporter<br/>(export.py)"]:::ml_node
|
| 43 |
end
|
| 44 |
|
| 45 |
subgraph Storage [Persistence & Hardware]
|
| 46 |
direction TB
|
| 47 |
+
ModelWeights["Model Artifacts<br/>(model/)"]:::data
|
| 48 |
+
CSV["Patient Dataset<br/>(patient_dataset.csv)"]:::data
|
| 49 |
+
MCU["Edge Silicon<br/>(tinyml_model.h)"]:::edge_tech
|
| 50 |
end
|
| 51 |
|
| 52 |
%% Flows
|
README.md
CHANGED
|
@@ -7,9 +7,9 @@ sdk: docker
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
#
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |

|
| 15 |

|
|
@@ -17,29 +17,23 @@ A production-grade, edge-optimized application for real-time cardiovascular tele
|
|
| 17 |

|
| 18 |

|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
## π Overview
|
| 23 |
-
|
| 24 |
-
HeartFlow OS is engineered for high-frequency clinical telemetry. It ingests live patient vitals via WebSockets, evaluates telemetry against an ensemble of distributed classifiers to compute diagnostic probability distributions, and physically compresses these complex mathematical models into raw C-code headers ready to be flashed onto constrained edge silicon (e.g., ESP32, Cortex-M series).
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
- **Edge Inference & TinyML:** Transpiles sophisticated `scikit-learn` models into highly optimized, dependency-free C-code. Designed with strict spatial and temporal constraints in mind, bypassing dynamic memory allocation entirely (`malloc`-free).
|
| 30 |
-
- **INT8 Quantization Engine:** Algorithmically scales 64-bit floating-point weights and biases down to 8-bit integers, effectively shrinking the flashed payload memory footprint by ~75% without significant accuracy degradation.
|
| 31 |
-
- **Soft-Voting Ensemble:** Fuses predictions from five discrete model architectures (Random Forest, SVM, KNN, Logistic Regression, MLP Neural Network) to generate resilient probability distributions, mitigating the variance and biases of individual black-box models.
|
| 32 |
-
- **Zero-Downtime MLOps:** Integrated `/retrain` pipeline allowing for real-time schema validation, data imputation, and background ensemble retraining. Hot-swaps the underlying intelligence engine globally without interrupting active clinical WebSocket streams.
|
| 33 |
|
| 34 |
-
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
### Repository
|
| 43 |
|
| 44 |
```text
|
| 45 |
HEARTFLOW_OS/
|
|
@@ -54,33 +48,33 @@ HEARTFLOW_OS/
|
|
| 54 |
βββ data/ # Immutable patient cohort datasets for MLOps
|
| 55 |
```
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
-
##
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
### 1. Initialize the Core (Backend)
|
| 62 |
-
Requires Python 3.10+
|
| 63 |
```bash
|
| 64 |
cd backend
|
| 65 |
python -m venv .venv
|
| 66 |
-
source .venv/bin/activate
|
| 67 |
pip install -r requirements.txt
|
| 68 |
-
python models.py
|
| 69 |
uvicorn main:app --reload --port 8000
|
| 70 |
```
|
| 71 |
|
| 72 |
-
### 2. Initialize the
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
```bash
|
| 75 |
cd frontend
|
| 76 |
npm install
|
| 77 |
npm run dev
|
| 78 |
```
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
---
|
| 83 |
|
| 84 |
-
##
|
| 85 |
|
| 86 |
Distributed under the MIT License. See `LICENSE` for more information.
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# HeartFlow OS
|
| 11 |
|
| 12 |
+
HeartFlow OS is a telemetry application for real-time cardiovascular inference. It ingests patient vitals and evaluates them against a machine-learning ensemble to compute diagnostic probabilities. It also compiles these models into C-code headers for edge devices.
|
| 13 |
|
| 14 |

|
| 15 |

|
|
|
|
| 17 |

|
| 18 |

|
| 19 |
|
| 20 |
+
## Overview
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
HeartFlow OS runs clinical telemetry at 60Hz. It uses native WebSockets in a Next.js dashboard to render telemetry sweeps without dropping frames. The backend transpiles scikit-learn models into `malloc`-free C-code for constrained microcontrollers.
|
| 23 |
|
| 24 |
+
### Key features
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
- **Telemetry interface**: A Next.js 16 dashboard renders 60fps SVG telemetry sweeps using React 19 and WebSockets.
|
| 27 |
+
- **Edge inference**: The system transpiles `scikit-learn` models into dependency-free C-code. It avoids dynamic memory allocation.
|
| 28 |
+
- **INT8 quantization**: The backend algorithmically scales 64-bit floating-point weights to 8-bit integers. This shrinks the flash memory footprint by 75%.
|
| 29 |
+
- **Soft-voting ensemble**: Five model architectures (Random Forest, SVM, KNN, Logistic Regression, MLP) fuse predictions into a probability distribution.
|
| 30 |
+
- **Zero-downtime MLOps**: You can upload CSVs to the `/retrain` pipeline. It imputes data and retrains the ensemble in the background without dropping WebSocket connections.
|
| 31 |
|
| 32 |
+
## System architecture
|
| 33 |
|
| 34 |
+
The architecture uses a decoupled pattern split across the React client, FastAPI core, and C-compiler edge. Read the [architecture guide](./ARCHITECTURE.md) for data flows and design rationale.
|
| 35 |
|
| 36 |
+
### Repository topology
|
| 37 |
|
| 38 |
```text
|
| 39 |
HEARTFLOW_OS/
|
|
|
|
| 48 |
βββ data/ # Immutable patient cohort datasets for MLOps
|
| 49 |
```
|
| 50 |
|
| 51 |
+
## Quickstart
|
| 52 |
|
| 53 |
+
### 1. Initialize the core
|
| 54 |
+
|
| 55 |
+
You need Python 3.10+ installed.
|
| 56 |
|
|
|
|
|
|
|
| 57 |
```bash
|
| 58 |
cd backend
|
| 59 |
python -m venv .venv
|
| 60 |
+
source .venv/bin/activate
|
| 61 |
pip install -r requirements.txt
|
| 62 |
+
python models.py
|
| 63 |
uvicorn main:app --reload --port 8000
|
| 64 |
```
|
| 65 |
|
| 66 |
+
### 2. Initialize the client
|
| 67 |
+
|
| 68 |
+
You need Node.js 18+ installed.
|
| 69 |
+
|
| 70 |
```bash
|
| 71 |
cd frontend
|
| 72 |
npm install
|
| 73 |
npm run dev
|
| 74 |
```
|
| 75 |
|
| 76 |
+
Navigate to `http://localhost:3000` to monitor telemetry streams, access MLOps pipelines, and export INT8 headers.
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
## License
|
| 79 |
|
| 80 |
Distributed under the MIT License. See `LICENSE` for more information.
|