UdasriHasindu commited on
Commit ·
89f2004
1
Parent(s): 66f849f
doc: create readme file
Browse files
README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Parkinson's Motor Impairment Predictor
|
| 3 |
+
emoji: 🧠
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# 🧠 Parkinson's Motor Impairment Score API
|
| 11 |
+
|
| 12 |
+
**FastAPI** backend that evaluates patient drawings (wave and spiral patterns) to detect and quantify motor impairments associated with Parkinson's disease.
|
| 13 |
+
|
| 14 |
+
This service utilizes deep learning models (**VGG19** and **ResNet101**) automatically dynamically fetched from Hugging Face along with a custom OpenCV pre-processing pipeline to score severity precisely.
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## 🚀 Features
|
| 19 |
+
* **Lightning Fast:** Implements a FastAPI lifecycle manager to preload multi-hundred-megabyte machine learning models straight into RAM on server startup, ensuring 0-second prediction latency.
|
| 20 |
+
* **Dual Classifiers:**
|
| 21 |
+
* **Wave Patterns:** Analyzed via a VGG19 backbone.
|
| 22 |
+
* **Spiral Patterns:** Analyzed via a ResNet101 backbone.
|
| 23 |
+
* **Torch-less:** Fully replicates the original PyTorch training `torchvision` image transformation pipeline using strictly `numpy` and `cv2` for ultra-lightweight deployment.
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
## 🛠️ API Endpoints
|
| 28 |
+
|
| 29 |
+
### 1. `POST /predict/wave`
|
| 30 |
+
Accepts a drawn "wave" pattern image overlay and calculates severity.
|
| 31 |
+
|
| 32 |
+
### 2. `POST /predict/spiral`
|
| 33 |
+
Accepts a drawn "spiral" pattern image overlay and calculates severity.
|
| 34 |
+
|
| 35 |
+
**Input Format:** `multipart/form-data` with an image file.
|
| 36 |
+
|
| 37 |
+
**Response Example:**
|
| 38 |
+
```json
|
| 39 |
+
{
|
| 40 |
+
"drawing_type": "wave",
|
| 41 |
+
"raw_logit": 8.7809,
|
| 42 |
+
"sigmoid_probability": 0.9998,
|
| 43 |
+
"motor_impairment_score": 43.98,
|
| 44 |
+
"severity_level": "Mild",
|
| 45 |
+
"description": "Slight motor irregularities observed.",
|
| 46 |
+
"is_parkinson": true
|
| 47 |
+
}
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
## 💻 Local Development
|
| 53 |
+
|
| 54 |
+
1. **Create Virtual Environment:**
|
| 55 |
+
```bash
|
| 56 |
+
python -m venv venv
|
| 57 |
+
source venv/bin/activate
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
2. **Install Dependencies:**
|
| 61 |
+
```bash
|
| 62 |
+
pip install -r requirements.txt
|
| 63 |
+
pip install fastapi uvicorn python-multipart
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
3. **Run the Server:**
|
| 67 |
+
```bash
|
| 68 |
+
uvicorn main:app --reload
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
4. Go to `http://127.0.0.1:8000/docs` to test the API directly using Swagger UI!
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## ☁️ Hugging Face Deployment (Docker)
|
| 76 |
+
This repository is pre-configured to automatically deploy as a **Docker Space** to Hugging Face via GitHub Actions.
|
| 77 |
+
|
| 78 |
+
1. Any changes pushed to the `main` branch trigger `.github/workflows/deploy.yml`
|
| 79 |
+
2. GitHub forcefully mirrors this repository to Hugging Face Hub securely using an injected `HF_TOKEN`.
|
| 80 |
+
3. Hugging Face reads the attached `Dockerfile` and dynamically exposes the FastAPI service on Port `7860`.
|