A Flask web app for automated fetal head biometry from 2D ultrasound images.
Upload an ultrasound image and pixel spacing. A Keras/TensorFlow model segments the fetal head, an ellipse is fit to the mask, and from its axes the app computes BPD, OFD, head circumference, cephalic index, gestational age, estimated fetal weight, trimester, and due date. It flags clinical warnings (possible micro/macrocephaly, dolichocephaly/brachycephaly) and personalized risks (maternal age, diabetes, hypertension) against GA-indexed normal ranges, then asks Groq's Llama model to turn the numbers into a plain-language summary, with optional text-to-speech playback.
pip install -r requirements.txt
cp .env.example .env
python app.pySet GROQ_API_KEY in .env before running. Open http://localhost:5000,
go to Predict, and upload an ultrasound image with its pixel spacing.
| Input | Segmentation result |
|---|---|
![]() |
![]() |
The green ellipse is fit to the model's predicted head mask; its axes give BPD and OFD, from which the app derives HC, gestational age, and the rest of the measurements described above.
Sample ultrasound images are not included in this repo. The model was trained and tested on the HC18 fetal head circumference dataset:
mkdir -p data && cd data
curl -sL -o training_set.zip "https://zenodo.org/records/1327317/files/training_set.zip"
unzip -q training_set.zipEach image ships as NNN_HC.png with a matching NNN_HC_Annotation.png
mask, and training_set_pixel_size_and_HC.csv gives the pixel spacing
(mm/pixel) each image needs for the pixel_spacing field on upload.

