Skip to content

Repository files navigation

title Heart Sound Classifier
emoji 💓
colorFrom yellow
colorTo blue
sdk docker
pinned true
license mit
short_description Classify heart sound (phonocardiogram) recordings — normal vs abnormal

Heart Sound Classification (Heartbeat Anomaly Detection)

Hugging Face Spaces License: MIT

End‑to‑end system that detects cardiac abnormalities from heart sound recordings. It trains a CNN on log‑mel spectrograms and serves predictions via a FastAPI web app with waveform/spectrogram visuals, class probabilities, batch analysis, PDF reports, and session history.

App screenshot (result view)

Highlights

  • 94% record‑level accuracy and 0.986 ROC‑AUC on PhysioNet CinC 2016 test set
  • Audio pipeline: 4 kHz resampling, 5 s windows (50% overlap), 64‑mel spectrograms, global normalization
  • Training: TensorFlow/Keras, SpecAugment, class weighting, EarlyStopping/ModelCheckpoint
  • Web app: drag‑and‑drop uploads (mobile mic capture), waveform/spectrogram, probability bar chart, segment highlights
  • Extra features: batch processing (multiple files/ZIP), PDF export, session history with delete
  • Productionized: Docker image, health/readiness endpoints, deployed on Hugging Face Spaces (CPU)

Tech Stack

  • Core: Python 3.11, TensorFlow/Keras, scikit‑learn
  • Audio: librosa, soundfile, audioread/ffmpeg
  • API/UI: FastAPI, Uvicorn, Jinja2, Chart.js, Matplotlib, ReportLab
  • Data/Storage: SQLAlchemy + SQLite (session history)
  • Ops: Docker, Hugging Face Spaces, Git LFS (for model)

Results

  • Dataset: PhysioNet/CinC Challenge 2016 (normal vs abnormal), >3,000 recordings
  • Segment‑level: ~94.6% accuracy on test
  • Record‑level (avg probs across segments): ~94.2% accuracy, ROC‑AUC ~0.986

Note: Model predicts two classes: normal, abnormal_other.


Screenshots

Upload page placeholder

Result page placeholder

Batch results placeholder

History placeholder


Quickstart (local)

  • Python 3.11
  • ffmpeg on PATH (for MP3/M4A decoding)
  • Git LFS (to fetch the model): https://git-lfs.com

setup

python -m venv .venv

Windows

.venv\Scripts\activate

macOS/Linux

source .venv/bin/activate

python -m pip install --upgrade pip python -m pip install -r requirements.txt

Run the app

uvicorn src.app.main:app --host 0.0.0.0 --port 8000

Notes & Disclaimer

  • Supported formats: WAV, MP3, M4A/AAC, OGG/WEBM (ffmpeg required). On mobile, you can record directly with your mic.
  • Privacy: app stores only filenames, probabilities, and temporary files under /tmp (cleared on restart). No PHI.
  • Medical disclaimer: for education/research only; not a medical device; not for diagnosis or treatment.

Acknowledgements

Maintainer

Aryan Singh

Releases

Packages

Contributors

Languages