StrokePatientsModel / README.md
AdhamQQ's picture
Update README.md
8ce1e4b verified

A newer version of the Streamlit SDK is available: 1.55.0

Upgrade
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

  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
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