Inspiration

While brainstorming for an idea, we thougth of making something which will address one of the deprivations the villagers, and after sometime, our attention was shifted to healthcare in villages. This thought chain led us to create GarbhSurakhsha.

What it does

Pregnant women in rural and underserved (especially in under developed countries) areas such as India, Afghanisthan, Chad, South Sudan, Haiti, Somalia, Niger, DRC to name a few, often don’t have access to healthcare services / clinics. Due to a lack of regular checkup, even if there are any abnormalities in the fetus, often times, it may go unnoticed leading to further complications or even death. GarbhSurakhsha aims to solve this by integrating AI and healthcare to provide early time fetal abnormality detection by capture the heart beat of the fetus and analysing it.
It provides info on FHR (fetal heart rate), abnormality of FHR (using a trained AI model), probability of Bradycardia / Trachycardia and gives recommendations and informs the user of any fetal abnormalities.

The fetal heart sound can be captured using a stethoscope attatched to the microphone of a wired headphone, which we have made, and it can be distributed to our users. ([link]https://ik.imagekit.io/o8zmk0phf/1766154759488.jpg)

Our app also has multilingual support so that people from all over the world can use it.

How we built it

We trained an AI model using PyTorch using VG11 deep CNN classifier. The dataset used contains more than 3000 general heart rate sounds (PCG) ([link]https://physionet.org/content/challenge-2016/1.0.0/) which is used to train the model, since there is a lack of dataset for fetal heart sound, we had to use the prior, but upon testing it on a fetal heart sound dataset ([link]https://physionet.org/content/challenge-2016/1.0.0/), it gave excellent results. After all, the model predicts wheter the heart beat rythym is normal or abnormal and all bioogical hearts have a periodic rythymic pattern. The model architecture is as follows:

The VGG_11 is an 11-layer convolutional neural network inspired by the VGG architecture, adapted for audio/heart sound classification:

Input Layer:

Input shape: (batch_size, mel_bins, num_frames) Reshaped to: (batch_size, in_channel, mel_bins, num_frames) where in_channel=3 (using mel spectrogram + delta features) BatchNorm2d(128) applied after transposing dimensions Convolutional Blocks (4 blocks)

Each ConvBlock contains 2 convolutional layers:

Conv Block 1: 3 → 64 channels Conv2d(kernel=3×3, stride=1, padding=1) + BatchNorm + ReLU Conv2d(kernel=3×3, stride=1, padding=1) + BatchNorm + ReLU MaxPool2d(2×2) Dropout(0.2)

Conv Block 2: 64 → 128 channels Same structure as above MaxPool2d(2×2) Dropout(0.2)

Conv Block 3: 128 → 256 channels Same structure MaxPool2d(2×2) Dropout(0.2)

Conv Block 4: 256 → 512 channels Same structure MaxPool2d(2×2) Dropout(0.2)

Output Layer

Global Max Pooling over spatial dimensions Fully Connected: 512 → 2 classes (normal/abnormal heartbeat) Log Softmax activation for final classification

We then converted the .pth model to .onnx model for lesser prediction times.

The front end of the app has been written with Flutter and the backend with FastAPI which has been hosted on railway.com for public accessibility. The backend has 2 main endpoints - /health and /analyse. The latter is used for uploading the getting the analysis results.

Fetal Heart Rate (FHR) Processing Pipeline:

  1. Audio Preprocessing (predict_onnx.py:32-43) Audio file is read and converted to mono if stereo High-pass filter (20 Hz cutoff, 5th order Butterworth) removes DC offset and low-frequency noise

  2. Signal Envelope Extraction Uses Hilbert transform to extract the signal envelope This captures the amplitude modulation of the heartbeat sounds

  3. Peak Detection Detects peaks in the envelope representing individual heartbeats Minimum distance of ~300 ms between peaks (to avoid false detections) Only peaks above mean envelope amplitude are considered

  4. FHR Calculation Converts peak positions to time intervals (inter-beat intervals or IBI) Calculates FHR: 60 / mean(IBI) = beats per minute

  5. Heart Rate Feature Extraction Comprehensive features are extracted:

  6. Gestational Age-Based Analysis Normal FHR ranges vary by gestation:

5-7 weeks: 90-130 bpm 8-10 weeks: 170-180 bpm 14-27 weeks: 120-160 bpm 33-40 weeks: 110-150 bpm

  1. Clinical Classification Normal: FHR within gestational age-appropriate range Bradycardia: FHR below normal (slow heart rate) Tachycardia: FHR above normal (fast heart rate)

  2. Risk Probability Calculation Only shows abnormality risk if deviation ≥ 20 bpm Calculates probabilities for normal, bradycardia, and tachycardia Provides medical recommendations based on severity

  3. Parallel ML Classification Mel-spectrogram features extracted from audio ONNX neural network classifies as "Normal" or "Abnormal" Combined with FHR analysis for comprehensive assessment

Metrics: Accuracy - 90.2% MAcc - 87.2% F1 Score - 95.2%

Challenges we ran into

Building the overall application was a challenge for us, since we did it in 4 days.

What we learned

Flutter, how to train better AI models, FastAPI, about Railway.com

What's next for GarbhSurakhsha

We plan to improve the AI model, the UI, use a backend with more computing power.

Built With

Share this project:

Updates