Spaces:
Sleeping
Sleeping
File size: 2,747 Bytes
94f22cd 8ce1e4b 94f22cd 8ce1e4b 94f22cd 8ce1e4b 94f22cd 8ce1e4b 94f22cd 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 4747664 fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b 4747664 8ce1e4b fc5eb9b 8ce1e4b fc5eb9b | 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 | ---
title: StrokePainSideDetector
emoji: π§
colorFrom: red
colorTo: blue
sdk: streamlit
sdk_version: 1.44.1
app_file: app.py
pinned: false
license: mit
---
# π§ Stroke Patient Pain Intensity Detector
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.
## π What This App Does
1. π§ **Detects affected side** of the face using a Keras CNN model.
2. π― **Crops the unaffected side** of the face using OpenCV + Haar cascades.
3. π **Predicts pain score (PSPI)** using a PyTorch ResNet model.
If the face is tilted, the app will automatically rotate it for correct alignment before prediction.
---
## πΌοΈ Input
Upload a **full-face photo** of a stroke patient. The app:
- Detects the face
- Splits the face in half (face point of view)
- Uses the expressive side for pain prediction
---
## π Output
- **Affected Side** (face point of view)
- **Unaffected Side**
- **Predicted PSPI Score**: A number between 0 and 6
- **Raw pain model output**
- **Raw stroke model output** (value closer to 0 β left side affected; closer to 1 β right side affected)
---
## π PSPI Score Scale
| Score | Pain Level |
|-------|-------------------|
| 0 | No pain |
| 1β2 | Mild pain |
| 3β4 | Moderate pain |
| 5β6 | Severe pain |
The PSPI (Prkachin and Solomon Pain Intensity) score is based on facial action units like eye tightening, brow lowering, and cheek raising.
---
## πΎ Models Used
| Model | Task | Format | Link |
|--------------------------|----------------------------------|----------------|----------------------------------------------------------------------|
| `cnn_stroke_model.keras` | Detect affected facial side | TensorFlow | [Download](https://huggingface.co/AdhamQQ/cnn_stroke_model/resolve/main/cnn_stroke_model.keras) |
| `pain_model.pth` | Predict PSPI pain intensity | PyTorch | [Download](https://huggingface.co/AdhamQQ/cnn_stroke_model/resolve/main/pain_model.pth) |
---
## π οΈ Technologies
- **Streamlit** for the web interface
- **OpenCV** for face detection
- **TensorFlow/Keras** for stroke side classification
- **PyTorch** for PSPI pain intensity prediction
---
## π€ Credits
Developed by [Your Name or Team Name]
With support from Hugging Face Spaces
---
## π Live App
Launch it on Hugging Face Spaces:
[π Try It Now](https://huggingface.co/spaces/YourUsername/StrokePainSideDetector)
|