Spaces:
Sleeping
Sleeping
A newer version of the Streamlit SDK is available:
1.55.0
metadata
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
- π§ Detects affected side of the face using a Keras CNN model.
- π― Crops the unaffected side of the face using OpenCV + Haar cascades.
- π 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 |
pain_model.pth |
Predict PSPI pain intensity | PyTorch | Download |
π οΈ 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