Update README.md
Browse files
README.md
CHANGED
|
@@ -1,152 +1,167 @@
|
|
| 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 |
-
"
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
}
|
| 113 |
-
```
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
-
|
| 133 |
-
-
|
| 134 |
-
-
|
| 135 |
-
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
-
|
| 140 |
-
|
| 141 |
-
##
|
| 142 |
-
|
| 143 |
-
-
|
| 144 |
-
-
|
| 145 |
-
-
|
| 146 |
-
-
|
| 147 |
-
-
|
| 148 |
-
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Digital Doctors Assistant ML API
|
| 3 |
+
emoji: 🏥
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Digital Doctors Assistant ML API
|
| 12 |
+
|
| 13 |
+
A FastAPI-based machine learning service that provides two prediction models for healthcare applications:
|
| 14 |
+
|
| 15 |
+
1. **Risk Assessment Model** - Predicts patient risk levels (Low/Medium/High) based on vitals and health metrics
|
| 16 |
+
2. **Treatment Outcome Model** - Predicts treatment success probability based on patient data and medication
|
| 17 |
+
|
| 18 |
+
## Features
|
| 19 |
+
|
| 20 |
+
- RESTful API endpoints for ML predictions
|
| 21 |
+
- Interactive web interface for easy testing
|
| 22 |
+
- ONNX Runtime for fast inference
|
| 23 |
+
- Pre-trained models hosted on HuggingFace
|
| 24 |
+
- Docker support for easy deployment
|
| 25 |
+
|
| 26 |
+
## Quick Start
|
| 27 |
+
|
| 28 |
+
### Using HuggingFace Space
|
| 29 |
+
|
| 30 |
+
Simply visit the Space URL and use the web interface to make predictions.
|
| 31 |
+
|
| 32 |
+
### Run Locally with Docker
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
docker run -it -p 7860:7860 \
|
| 36 |
+
-e HUGGINGFACE_TOKEN="your_token_here" \
|
| 37 |
+
registry.hf.space/your-username-your-space-name:latest
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
### Local Setup (Without Docker)
|
| 41 |
+
|
| 42 |
+
1. Install dependencies:
|
| 43 |
+
```bash
|
| 44 |
+
pip install -r requirements.txt
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
2. Set your HuggingFace token:
|
| 48 |
+
```bash
|
| 49 |
+
# Windows PowerShell
|
| 50 |
+
$env:HUGGINGFACE_TOKEN="your_token_here"
|
| 51 |
+
|
| 52 |
+
# Windows CMD
|
| 53 |
+
set HUGGINGFACE_TOKEN=your_token_here
|
| 54 |
+
|
| 55 |
+
# Linux/Mac
|
| 56 |
+
export HUGGINGFACE_TOKEN=your_token_here
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
3. Run the server:
|
| 60 |
+
```bash
|
| 61 |
+
uvicorn ml:app --host 0.0.0.0 --port 7860
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
4. Open your browser:
|
| 65 |
+
- Web Interface: http://localhost:7860
|
| 66 |
+
- API Docs: http://localhost:7860/docs
|
| 67 |
+
- Health Check: http://localhost:7860/health
|
| 68 |
+
|
| 69 |
+
## API Endpoints
|
| 70 |
+
|
| 71 |
+
### POST /predict/risk
|
| 72 |
+
Predict patient risk level based on health metrics.
|
| 73 |
+
|
| 74 |
+
**Request Body:**
|
| 75 |
+
```json
|
| 76 |
+
{
|
| 77 |
+
"age": 45,
|
| 78 |
+
"bmi": 28.5,
|
| 79 |
+
"systolic_bp": 140,
|
| 80 |
+
"diastolic_bp": 90,
|
| 81 |
+
"chronic_conditions": "diabetes,hypertension",
|
| 82 |
+
"severity_score": 7.5
|
| 83 |
+
}
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
**Response:**
|
| 87 |
+
```json
|
| 88 |
+
{
|
| 89 |
+
"success": true,
|
| 90 |
+
"model": "risk_assessment",
|
| 91 |
+
"prediction": "High",
|
| 92 |
+
"confidence": 0.85,
|
| 93 |
+
"probabilities": {
|
| 94 |
+
"Low": 0.05,
|
| 95 |
+
"Medium": 0.10,
|
| 96 |
+
"High": 0.85
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### POST /predict/treatment
|
| 102 |
+
Predict treatment outcome success probability.
|
| 103 |
+
|
| 104 |
+
**Request Body:**
|
| 105 |
+
```json
|
| 106 |
+
{
|
| 107 |
+
"patient_age": 55,
|
| 108 |
+
"severity_score": 6.5,
|
| 109 |
+
"compliance_rate": 0.85,
|
| 110 |
+
"medication": "Metformin",
|
| 111 |
+
"condition": "Diabetes Type 2"
|
| 112 |
+
}
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
**Response:**
|
| 116 |
+
```json
|
| 117 |
+
{
|
| 118 |
+
"success": true,
|
| 119 |
+
"model": "treatment_outcome",
|
| 120 |
+
"prediction": 1,
|
| 121 |
+
"success_probability": 78.5,
|
| 122 |
+
"confidence": 0.78,
|
| 123 |
+
"probabilities": {
|
| 124 |
+
"failure": 0.22,
|
| 125 |
+
"success": 0.78
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## Supported Medications
|
| 131 |
+
|
| 132 |
+
- Paracetamol
|
| 133 |
+
- Ibuprofen
|
| 134 |
+
- Amoxicillin
|
| 135 |
+
- Ciprofloxacin
|
| 136 |
+
- Metformin
|
| 137 |
+
- Lisinopril
|
| 138 |
+
- Amlodipine
|
| 139 |
+
- Omeprazole
|
| 140 |
+
|
| 141 |
+
## Supported Conditions
|
| 142 |
+
|
| 143 |
+
- Common Cold
|
| 144 |
+
- Influenza
|
| 145 |
+
- Pneumonia
|
| 146 |
+
- Bronchitis
|
| 147 |
+
- Hypertension
|
| 148 |
+
- Diabetes Type 2
|
| 149 |
+
- Migraine
|
| 150 |
+
- Gastroenteritis
|
| 151 |
+
|
| 152 |
+
## Environment Variables
|
| 153 |
+
|
| 154 |
+
- `HUGGINGFACE_TOKEN` - Required. Your HuggingFace access token for downloading models
|
| 155 |
+
|
| 156 |
+
## Technology Stack
|
| 157 |
+
|
| 158 |
+
- FastAPI - Web framework
|
| 159 |
+
- ONNX Runtime - ML inference
|
| 160 |
+
- NumPy - Numerical computing
|
| 161 |
+
- HuggingFace Hub - Model hosting
|
| 162 |
+
- Pydantic - Data validation
|
| 163 |
+
- Uvicorn - ASGI server
|
| 164 |
+
|
| 165 |
+
## License
|
| 166 |
+
|
| 167 |
+
MIT
|