UdasriHasindu commited on
Commit ·
2c47f90
1
Parent(s): 16af0dd
create a docker container
Browse files- .dockerignore +9 -0
- Dockerfile +24 -0
- README.md +59 -0
- requirements.txt +11 -1
.dockerignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
venv/
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
*.pyo
|
| 5 |
+
*.pyd
|
| 6 |
+
.env
|
| 7 |
+
.git/
|
| 8 |
+
.gitignore
|
| 9 |
+
*.md
|
Dockerfile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ── Base image ────────────────────────────────────────────────────────────────
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# ── System dependencies ────────────────────────────────────────────────────────
|
| 5 |
+
# ffmpeg : required for audio conversion (webm/ogg/mp3 → wav)
|
| 6 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
+
ffmpeg \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# ── Working directory ──────────────────────────────────────────────────────────
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# ── Python dependencies ────────────────────────────────────────────────────────
|
| 14 |
+
COPY requirements.txt .
|
| 15 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
+
|
| 17 |
+
# ── Application source ─────────────────────────────────────────────────────────
|
| 18 |
+
COPY . .
|
| 19 |
+
|
| 20 |
+
# ── HF Spaces requires port 7860 ───────────────────────────────────────────────
|
| 21 |
+
EXPOSE 7860
|
| 22 |
+
|
| 23 |
+
# ── Entrypoint ─────────────────────────────────────────────────────────────────
|
| 24 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: UPDRS API
|
| 3 |
+
emoji: 🧠
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Parkinson's Disease UPDRS Prediction API
|
| 12 |
+
|
| 13 |
+
A FastAPI-based REST API that predicts a patient's **motor UPDRS score** (Unified Parkinson's Disease Rating Scale) from a voice recording.
|
| 14 |
+
|
| 15 |
+
## Endpoints
|
| 16 |
+
|
| 17 |
+
| Method | Path | Description |
|
| 18 |
+
|--------|------|-------------|
|
| 19 |
+
| `GET` | `/` | Root welcome message |
|
| 20 |
+
| `GET` | `/health` | Health check — confirms models are loaded |
|
| 21 |
+
| `POST` | `/analyze/voice` | Main prediction endpoint |
|
| 22 |
+
| `POST` | `/analyze/test` | Debug echo endpoint |
|
| 23 |
+
|
| 24 |
+
## Usage — `/analyze/voice`
|
| 25 |
+
|
| 26 |
+
Submit a `multipart/form-data` POST request with:
|
| 27 |
+
|
| 28 |
+
| Field | Type | Description |
|
| 29 |
+
|-------|------|-------------|
|
| 30 |
+
| `name` | string | Patient name |
|
| 31 |
+
| `age` | int | Age (11–119) |
|
| 32 |
+
| `sex` | string | `male` or `female` |
|
| 33 |
+
| `test_time` | float | Time since recruitment (days) |
|
| 34 |
+
| `audio_file` | file | Voice recording (WAV, MP3, OGG, WebM) |
|
| 35 |
+
|
| 36 |
+
### Response
|
| 37 |
+
|
| 38 |
+
```json
|
| 39 |
+
{
|
| 40 |
+
"prediction": 18.42,
|
| 41 |
+
"patient": "John Doe"
|
| 42 |
+
}
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
`prediction` is the estimated motor UPDRS score (float).
|
| 46 |
+
|
| 47 |
+
## Voice Features Extracted
|
| 48 |
+
|
| 49 |
+
The API uses **Praat** (via `parselmouth`) to extract 16 acoustic biomarkers:
|
| 50 |
+
- **Jitter**: `Jitter(%)`, `Jitter(Abs)`, `Jitter:RAP`, `Jitter:PPQ5`, `Jitter:DDP`
|
| 51 |
+
- **Shimmer**: `Shimmer`, `Shimmer(dB)`, `Shimmer:APQ3`, `Shimmer:APQ5`, `Shimmer:APQ11`, `Shimmer:DDA`
|
| 52 |
+
- **Noise**: `NHR`, `HNR`
|
| 53 |
+
- **Nonlinear**: `RPDE`, `DFA`, `PPE`
|
| 54 |
+
|
| 55 |
+
## Model
|
| 56 |
+
|
| 57 |
+
- Hosted on HuggingFace: [`xplorers/parkinsons-updrs-model`](https://huggingface.co/xplorers/parkinsons-updrs-model)
|
| 58 |
+
- Ensemble model (RandomForest + XGBoost + LightGBM via VotingRegressor)
|
| 59 |
+
- Downloaded and cached in memory at startup
|
requirements.txt
CHANGED
|
@@ -2,13 +2,17 @@ annotated-doc==0.0.4
|
|
| 2 |
annotated-types==0.7.0
|
| 3 |
anyio==4.13.0
|
| 4 |
certifi==2026.2.25
|
|
|
|
| 5 |
click==8.3.1
|
|
|
|
| 6 |
dnspython==2.8.0
|
| 7 |
email-validator==2.3.0
|
| 8 |
fastapi==0.135.2
|
| 9 |
fastapi-cli==0.0.24
|
|
|
|
| 10 |
filelock==3.25.2
|
| 11 |
fsspec==2026.2.0
|
|
|
|
| 12 |
h11==0.16.0
|
| 13 |
hf-xet==1.4.2
|
| 14 |
httpcore==1.0.9
|
|
@@ -16,18 +20,23 @@ httptools==0.7.1
|
|
| 16 |
httpx==0.28.1
|
| 17 |
huggingface_hub==1.8.0
|
| 18 |
idna==3.11
|
|
|
|
|
|
|
| 19 |
joblib==1.5.3
|
| 20 |
lightgbm==4.6.0
|
| 21 |
markdown-it-py==4.0.0
|
| 22 |
mdurl==0.1.2
|
|
|
|
| 23 |
numpy==2.4.3
|
| 24 |
nvidia-nccl-cu12==2.29.7
|
| 25 |
packaging==26.0
|
| 26 |
pandas==3.0.1
|
|
|
|
| 27 |
praat-parselmouth==0.4.7
|
|
|
|
|
|
|
| 28 |
pydantic==2.12.5
|
| 29 |
pydantic_core==2.41.5
|
| 30 |
-
pydub==0.25.1
|
| 31 |
Pygments==2.19.2
|
| 32 |
python-dateutil==2.9.0.post0
|
| 33 |
python-dotenv==1.2.2
|
|
@@ -39,6 +48,7 @@ scikit-learn==1.8.0
|
|
| 39 |
scipy==1.17.1
|
| 40 |
shellingham==1.5.4
|
| 41 |
six==1.17.0
|
|
|
|
| 42 |
starlette==1.0.0
|
| 43 |
threadpoolctl==3.6.0
|
| 44 |
tqdm==4.67.3
|
|
|
|
| 2 |
annotated-types==0.7.0
|
| 3 |
anyio==4.13.0
|
| 4 |
certifi==2026.2.25
|
| 5 |
+
cffi==2.0.0
|
| 6 |
click==8.3.1
|
| 7 |
+
decorator==5.2.1
|
| 8 |
dnspython==2.8.0
|
| 9 |
email-validator==2.3.0
|
| 10 |
fastapi==0.135.2
|
| 11 |
fastapi-cli==0.0.24
|
| 12 |
+
ffmpeg-python==0.2.0
|
| 13 |
filelock==3.25.2
|
| 14 |
fsspec==2026.2.0
|
| 15 |
+
future==1.0.0
|
| 16 |
h11==0.16.0
|
| 17 |
hf-xet==1.4.2
|
| 18 |
httpcore==1.0.9
|
|
|
|
| 20 |
httpx==0.28.1
|
| 21 |
huggingface_hub==1.8.0
|
| 22 |
idna==3.11
|
| 23 |
+
ImageIO==2.37.3
|
| 24 |
+
imageio-ffmpeg==0.6.0
|
| 25 |
joblib==1.5.3
|
| 26 |
lightgbm==4.6.0
|
| 27 |
markdown-it-py==4.0.0
|
| 28 |
mdurl==0.1.2
|
| 29 |
+
moviepy==2.2.1
|
| 30 |
numpy==2.4.3
|
| 31 |
nvidia-nccl-cu12==2.29.7
|
| 32 |
packaging==26.0
|
| 33 |
pandas==3.0.1
|
| 34 |
+
pillow==11.3.0
|
| 35 |
praat-parselmouth==0.4.7
|
| 36 |
+
proglog==0.1.12
|
| 37 |
+
pycparser==3.0
|
| 38 |
pydantic==2.12.5
|
| 39 |
pydantic_core==2.41.5
|
|
|
|
| 40 |
Pygments==2.19.2
|
| 41 |
python-dateutil==2.9.0.post0
|
| 42 |
python-dotenv==1.2.2
|
|
|
|
| 48 |
scipy==1.17.1
|
| 49 |
shellingham==1.5.4
|
| 50 |
six==1.17.0
|
| 51 |
+
soundfile==0.13.1
|
| 52 |
starlette==1.0.0
|
| 53 |
threadpoolctl==3.6.0
|
| 54 |
tqdm==4.67.3
|