Skip to content

About

No description, website, or topics provided.

Resources

Stars

19 stars

Watchers

0 watching

Forks

Repository files navigation

❤️ CardioSense AI

Deep Learning-Based ECG Analysis System

CardioSense AI analyzes uploaded ECG CSV signals using a Convolutional Neural Network (CNN), estimates heart rate, and plots the waveform in a Gradio interface.


🔥 Features

  • 🧠 AI-based ECG Classification (Normal / Abnormal)
  • ❤️ Heart Rate (BPM) Calculation using R-Peak Detection
  • 📈 ECG Waveform Visualization with Peak Marking
  • 🌐 Interactive Web Interface (Gradio)

🛠️ Tech Stack

  • Python
  • TensorFlow / Keras (Deep Learning)
  • Gradio (Web Interface)
  • Pandas, NumPy (Data Processing)
  • SciPy (Signal Processing)
  • Matplotlib (Visualization)
  • Render (Deployment)
  • GitHub (Version Control)

📂 Project Structure

CardioSense-AI/
│
├── app.py
├── ecg_cnn_model.h5
├── requirements.txt
├── render.yaml
└── README.md

⚙️ Installation (Run Locally)

git clone https://github.com/Ayushdevo/cardiosense-ai.git
cd cardiosense-ai
pip install -r requirements.txt
python app.py

Open in browser: http://127.0.0.1:10000/

PORT overrides the default port of 10000. The model is loaded relative to app.py, so startup also works when the process has a different working directory.

The selected ECG column must contain at least 400 finite numeric samples with some variation. Missing, infinite, text, and constant samples are rejected; removing gaps silently would change the waveform's sample timing.

Development checks

pip install -r requirements-dev.txt
python -m pytest -q

Tests cover model startup, signal validation, concurrent plot isolation, probability validation, and a prediction using the checked-in CNN. Errors shown in the interface omit internal paths and stack traces; server logs retain the details needed to debug failures.


🚀 Deployment (Render)

  1. Push code to GitHub
  2. Go to Render → New Web Service
  3. Connect repository
  4. Set:

Build Command:

pip install -r requirements.txt

Start Command:

python app.py
  1. Deploy

🧠 How It Works

  1. Upload ECG CSV file

  2. Preprocessing:

    • Normalize signal
    • Extract segment
  3. CNN Model:

    • Predict Normal / Abnormal
  4. Signal Processing:

    • Detect peaks (SciPy)
    • Compute heart rate
  5. Output:

    • Prediction + Confidence
    • ECG waveform graph

📊 Model Details

  • Model: Convolutional Neural Network (CNN)
  • Input: ECG signal segment
  • Output: Binary classification
  • Dataset: MIT-BIH Arrhythmia Dataset

⚠️ Limitations

  • Free hosting may be slow (cold start)
  • High memory usage due to TensorFlow
  • Not intended for medical diagnosis

👨‍💻 Author

Ayush Tiwari ECE + AI | IIT Guwahati


📌 Future Improvements

  • Real-time ECG monitoring
  • Mobile app integration
  • Lightweight model optimization
  • Multi-class arrhythmia detection

⭐ Acknowledgements

  • MIT-BIH ECG Database
  • TensorFlow & Keras
  • SciPy Signal Processing

🚀 Live Demo

👉 https://cardiosense-ai-i.onrender.com

About

No description, website, or topics provided.

Resources

Stars

19 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages