Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -8,8 +8,8 @@ pinned: false
|
|
| 8 |
---
|
| 9 |
|
| 10 |
<div align="center">
|
| 11 |
-
<h1>
|
| 12 |
-
<p><strong>
|
| 13 |
|
| 14 |
<p>
|
| 15 |
<img src="https://img.shields.io/badge/Next.js-16+-black.svg?style=for-the-badge&logo=next.js" alt="Next.js" />
|
|
@@ -22,58 +22,52 @@ pinned: false
|
|
| 22 |
|
| 23 |
---
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
## ⚡ Tech Stack
|
| 32 |
-
|
| 33 |
-
| Domain | Technologies Used | Purpose |
|
| 34 |
| :--- | :--- | :--- |
|
| 35 |
-
| **Frontend** | Next.js 16
|
| 36 |
-
| **Backend
|
| 37 |
-
| **
|
| 38 |
-
| **Database** | SQLite, `aiosqlite` | Non-blocking
|
| 39 |
-
| **
|
| 40 |
-
|
| 41 |
-
## ✨ Key Features
|
| 42 |
|
| 43 |
-
|
| 44 |
-
- **Edge Inference & TinyML**: Transpiles complex `scikit-learn` decision boundaries into highly optimized, dependency-free C-code designed for constrained environments (bypassing dynamic memory allocation).
|
| 45 |
-
- **INT8 Quantization Engine**: Algorithmically scales 64-bit floating-point weights to 8-bit integers, shrinking the flash memory footprint by up to **75%** without meaningful accuracy loss.
|
| 46 |
-
- **Soft-Voting ML Ensemble**: Fuses predictions from five distinct model architectures to generate resilient probability distributions rather than opaque binary classifications.
|
| 47 |
-
- **Zero-Downtime MLOps**: Exposes a `/retrain` pipeline allowing for dynamic CSV uploads. It automatically imputes missing data, scales features, and retrains the entire ensemble in a background thread—hot-swapping the intelligence engine without interrupting active WebSocket streams.
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
|
| 55 |
-
##
|
| 56 |
|
| 57 |
-
### 1.
|
| 58 |
|
| 59 |
-
Requires Python 3.10
|
| 60 |
|
| 61 |
```bash
|
| 62 |
cd backend
|
| 63 |
python -m venv .venv
|
| 64 |
-
source .venv/bin/activate #
|
| 65 |
pip install -r requirements.txt
|
| 66 |
|
| 67 |
-
#
|
| 68 |
python models.py
|
| 69 |
|
| 70 |
-
#
|
| 71 |
uvicorn main:app --reload --port 8000
|
| 72 |
```
|
| 73 |
|
| 74 |
-
### 2.
|
| 75 |
|
| 76 |
-
Requires Node.js 18
|
| 77 |
|
| 78 |
```bash
|
| 79 |
cd frontend
|
|
@@ -81,8 +75,8 @@ npm install
|
|
| 81 |
npm run dev
|
| 82 |
```
|
| 83 |
|
| 84 |
-
|
| 85 |
|
| 86 |
-
##
|
| 87 |
|
| 88 |
-
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
<div align="center">
|
| 11 |
+
<h1>HeartFlow OS</h1>
|
| 12 |
+
<p><strong>Cardiovascular Telemetry & MLOps Engine</strong></p>
|
| 13 |
|
| 14 |
<p>
|
| 15 |
<img src="https://img.shields.io/badge/Next.js-16+-black.svg?style=for-the-badge&logo=next.js" alt="Next.js" />
|
|
|
|
| 22 |
|
| 23 |
---
|
| 24 |
|
| 25 |
+
HeartFlow OS takes real-time patient vitals via WebSockets, runs them through an scikit-learn ensemble, and outputs probability distributions for cardiovascular conditions. It also transpiles these models into standalone C headers you can flash directly to constrained edge devices like an ESP32.
|
| 26 |
|
| 27 |
+
## Components
|
| 28 |
|
| 29 |
+
| Domain | Tech | Details |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
| :--- | :--- | :--- |
|
| 31 |
+
| **Frontend** | Next.js 16, React 19 | Renders 60Hz telemetry streams using WebSockets and SVG |
|
| 32 |
+
| **Backend** | FastAPI, Python 3.10 | Handles WebSocket routing and MLOps API endpoints |
|
| 33 |
+
| **ML** | Scikit-Learn | Soft-voting ensemble (RF, SVM, KNN, LogReg, MLP) |
|
| 34 |
+
| **Database** | SQLite, `aiosqlite` | Non-blocking telemetry and prediction logging |
|
| 35 |
+
| **Compiler** | Custom AST Transpiler | Generates INT8 quantized, `malloc`-free C code |
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
## Features
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
- **Live Telemetry**: Streams data at 60Hz via WebSockets to a React 19 dashboard.
|
| 40 |
+
- **Edge Compilation**: Converts trained scikit-learn models into C headers. The generated code requires no dependencies and does not use dynamic memory allocation.
|
| 41 |
+
- **Quantization**: Scales 64-bit float weights down to 8-bit integers, reducing flash memory usage by ~75%.
|
| 42 |
+
- **Soft-Voting**: Combines predictions from 5 different models to output a probability distribution.
|
| 43 |
+
- **Background Retraining**: Upload new CSV data to `/retrain` and the backend will impute missing values, retrain the models in a background thread, and update the live ensemble without dropping active socket connections.
|
| 44 |
|
| 45 |
+
## Architecture
|
| 46 |
|
| 47 |
+
See [ARCHITECTURE.md](./ARCHITECTURE.md) for data flow diagrams and the file map.
|
| 48 |
|
| 49 |
+
## Quickstart
|
| 50 |
|
| 51 |
+
### 1. Backend
|
| 52 |
|
| 53 |
+
Requires Python 3.10+.
|
| 54 |
|
| 55 |
```bash
|
| 56 |
cd backend
|
| 57 |
python -m venv .venv
|
| 58 |
+
source .venv/bin/activate # Windows: .\.venv\Scripts\activate
|
| 59 |
pip install -r requirements.txt
|
| 60 |
|
| 61 |
+
# Train initial models and seed the DB
|
| 62 |
python models.py
|
| 63 |
|
| 64 |
+
# Start the server
|
| 65 |
uvicorn main:app --reload --port 8000
|
| 66 |
```
|
| 67 |
|
| 68 |
+
### 2. Frontend
|
| 69 |
|
| 70 |
+
Requires Node.js 18+.
|
| 71 |
|
| 72 |
```bash
|
| 73 |
cd frontend
|
|
|
|
| 75 |
npm run dev
|
| 76 |
```
|
| 77 |
|
| 78 |
+
Open `http://localhost:3000` to view the dashboard, upload new data, or export C headers.
|
| 79 |
|
| 80 |
+
## License
|
| 81 |
|
| 82 |
+
MIT License. See `LICENSE`.
|