File size: 2,594 Bytes
efa45f9
e47d4ee
efa45f9
7f3ee09
8cc4f3e
e47d4ee
efa45f9
8cc4f3e
b63d191
8cc4f3e
b63d191
8cc4f3e
b63d191
8cc4f3e
b63d191
8cc4f3e
 
 
 
 
b63d191
8cc4f3e
b63d191
8cc4f3e
 
 
 
 
b63d191
8cc4f3e
 
 
 
 
 
b63d191
8cc4f3e
 
 
 
b63d191
8cc4f3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7f3ee09
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
title: Sundew Health Demo
sdk: gradio
sdk_version: 6.0.2
app_file: app_space_wow.py
pinned: false
---
# Sundew Health Monitor

**Neurosymbolic, energy-aware AI for continuous ECG monitoring**

Combines adaptive gating, ML inference, and symbolic reasoning to deliver trustworthy, energy-efficient medical biosignal monitoring.

## Key Features

- **85% energy reduction** via Sundew gating algorithm
- **Explainable alerts** through symbolic rule chains
- **Real-time streaming** with WebSocket support
- **Multi-patient dashboard** for clinical monitoring
- **Production-ready API** with comprehensive SDK

## Quick Start

### Docker (Recommended)
```bash
docker-compose up --build
```
API: http://localhost:8000 | Docs: http://localhost:8000/docs

### Local Development
```bash
pip install -e . --extra-index-url https://download.pytorch.org/whl/cpu
alembic upgrade head
uvicorn app.main:app --reload
```

### Live Demo
```bash
python app_space_live.py
```

## Architecture

```
ECG Stream β†’ Sundew Gating β†’ ML Inference β†’ Rule Engine β†’ Alert
              (50-90% reduction)  (PyTorch CNN)   (Symbolic)
```

**Three-stage neurosymbolic pipeline:**
1. **Gating** - Adaptive windowing with significance scoring
2. **Inference** - Energy-efficient neural network
3. **Rules** - Medical knowledge base for explainability

## API Endpoints

- `POST /ecg/infer` - Run full pipeline
- `WS /ws/ecg/{patient_id}` - Real-time streaming
- `GET /dashboard/stats` - System metrics
- `GET /dashboard/patients` - Patient summaries
- `GET /dashboard/alerts` - Alert queue

## SDK Usage

```python
from sundew_sdk import SundewClient

client = SundewClient(base_url="http://localhost:8000")
result = client.infer_ecg(
    patient_id="p001",
    signal=[...],
    age=72,
    has_prior_stroke=False
)

print(f"{result['label']} | Alert: {result['alert_level']}")
```

See `sdk/example_client.py` for complete examples.

## Benchmarking

Evaluate against MIT-BIH Arrhythmia Database:

```bash
bash scripts/run_full_benchmark.sh
```

**Metrics tracked:**
- Accuracy, Precision, Recall, F1
- FLOPs reduction
- Energy savings
- Latency

Results saved to `benchmarks/results/`

## Documentation

- [DEPLOYMENT.md](DEPLOYMENT.md) - Production deployment guide
- [LAUNCH.md](LAUNCH.md) - Complete feature overview
- [CLAUDE.md](CLAUDE.md) - Architecture documentation

## Technology Stack

- **Backend:** FastAPI, SQLAlchemy, Alembic
- **ML:** PyTorch, Adaptive Sparse Training
- **Algorithms:** Sundew (gating), symbolic reasoning
- **Database:** PostgreSQL (production), SQLite (dev)
- **Demo:** Gradio