Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.44.1
|
| 8 |
app_file: app.py
|
|
@@ -10,56 +10,79 @@ pinned: false
|
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
| 14 |
|
|
|
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
---
|
| 27 |
|
| 28 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
- Detect the affected side
|
| 32 |
-
- Crop the unaffected side
|
| 33 |
-
- Predict the patient's pain intensity (PSPI)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
## πΎ Models Used
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
---
|
| 49 |
|
| 50 |
-
##
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
- Use the **expressive side** to analyze pain using PSPI (Prkachin and Solomon Pain Intensity) scores
|
| 55 |
|
| 56 |
---
|
| 57 |
|
| 58 |
-
##
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
- TensorFlow/Keras
|
| 63 |
-
- PyTorch
|
| 64 |
-
- Hugging Face Hub
|
| 65 |
|
|
|
|
| 1 |
---
|
| 2 |
+
title: StrokePainSideDetector
|
| 3 |
+
emoji: π§
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.44.1
|
| 8 |
app_file: app.py
|
|
|
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# π§ Stroke Patient Pain Intensity Detector
|
| 14 |
|
| 15 |
+
This app predicts the **pain intensity (PSPI score)** of stroke patients based on facial expressions using deep learning. It also detects the **affected side** of the face and uses the **unaffected half** for analysis.
|
| 16 |
|
| 17 |
+
## π What This App Does
|
| 18 |
|
| 19 |
+
1. π§ **Detects affected side** of the face using a Keras CNN model.
|
| 20 |
+
2. π― **Crops the unaffected side** of the face using OpenCV + Haar cascades.
|
| 21 |
+
3. π **Predicts pain score (PSPI)** using a PyTorch ResNet model.
|
| 22 |
|
| 23 |
+
If the face is tilted, the app will automatically rotate it for correct alignment before prediction.
|
| 24 |
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
## πΌοΈ Input
|
| 28 |
+
|
| 29 |
+
Upload a **full-face photo** of a stroke patient. The app:
|
| 30 |
+
- Detects the face
|
| 31 |
+
- Splits the face in half (face point of view)
|
| 32 |
+
- Uses the expressive side for pain prediction
|
| 33 |
|
| 34 |
---
|
| 35 |
|
| 36 |
+
## π Output
|
| 37 |
+
|
| 38 |
+
- **Affected Side** (face point of view)
|
| 39 |
+
- **Unaffected Side**
|
| 40 |
+
- **Predicted PSPI Score**: A number between 0 and 6
|
| 41 |
+
- **Raw pain model output**
|
| 42 |
+
- **Raw stroke model output** (value closer to 0 β left side affected; closer to 1 β right side affected)
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
|
| 46 |
+
## π PSPI Score Scale
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
| Score | Pain Level |
|
| 49 |
+
|-------|-------------------|
|
| 50 |
+
| 0 | No pain |
|
| 51 |
+
| 1β2 | Mild pain |
|
| 52 |
+
| 3β4 | Moderate pain |
|
| 53 |
+
| 5β6 | Severe pain |
|
| 54 |
|
| 55 |
+
The PSPI (Prkachin and Solomon Pain Intensity) score is based on facial action units like eye tightening, brow lowering, and cheek raising.
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
|
| 59 |
## πΎ Models Used
|
| 60 |
|
| 61 |
+
| Model | Task | Format | Link |
|
| 62 |
+
|--------------------------|----------------------------------|----------------|----------------------------------------------------------------------|
|
| 63 |
+
| `cnn_stroke_model.keras` | Detect affected facial side | TensorFlow | [Download](https://huggingface.co/AdhamQQ/cnn_stroke_model/resolve/main/cnn_stroke_model.keras) |
|
| 64 |
+
| `pain_model.pth` | Predict PSPI pain intensity | PyTorch | [Download](https://huggingface.co/AdhamQQ/cnn_stroke_model/resolve/main/pain_model.pth) |
|
| 65 |
+
|
| 66 |
+
---
|
| 67 |
+
|
| 68 |
+
## π οΈ Technologies
|
| 69 |
|
| 70 |
+
- **Streamlit** for the web interface
|
| 71 |
+
- **OpenCV** for face detection
|
| 72 |
+
- **TensorFlow/Keras** for stroke side classification
|
| 73 |
+
- **PyTorch** for PSPI pain intensity prediction
|
| 74 |
|
| 75 |
---
|
| 76 |
|
| 77 |
+
## π€ Credits
|
| 78 |
|
| 79 |
+
Developed by [Your Name or Team Name]
|
| 80 |
+
With support from Hugging Face Spaces
|
|
|
|
| 81 |
|
| 82 |
---
|
| 83 |
|
| 84 |
+
## π Live App
|
| 85 |
|
| 86 |
+
Launch it on Hugging Face Spaces:
|
| 87 |
+
[π Try It Now](https://huggingface.co/spaces/YourUsername/StrokePainSideDetector)
|
|
|
|
|
|
|
|
|
|
| 88 |
|