Cross-domain generalization study for fetal ultrasound plane classification using PyTorch, testing model performance on a held-out imaging device for low-resource clinical settings.
# Fetal Ultrasound Plane Classification: A Cross-Domain Generalization Study
A data pipeline and modeling project analyzing a 12,400-image medical
imaging dataset, focused on building a reproducible pipeline to measure
how well models generalize across different data sources — and how much
of that generalization gap can be closed through better model design.
## Overview
Most machine learning models are evaluated on data that looks like their
training data. In practice, data pulled from a different source, device,
or time period often behaves differently — a common failure mode in any
production data system. This project builds a small, reproducible pipeline
to measure that gap directly: structuring a dataset by source, engineering
a deliberate train/test split along that source boundary (rather than a
random split), and quantifying how much model performance drops as a
result.
## Dataset
- **Source:** FETAL_PLANES_DB (Burgos-Artizzu et al., 2020), a public
dataset of 12,400 medical images from 1,792 subjects, collected across
multiple imaging devices at two hospitals.
zenodo.org
- **Structure:** a CSV of metadata (`FETAL_PLANES_DB_data.csv`) joined
against image files, with fields including `Image_name`, `Patient_num`,
`Plane` (target label), `US_Machine` (data source), and `Operator`.
- Raw data is not redistributed in this repository, in line with the
source dataset's terms of use. Setup instructions: `data/README.md`.
## Data Pipeline Design
The core engineering problem this project solves: build a pipeline that
tests generalization across data sources, not just overall accuracy.
- **Ingestion:** load and join image files against CSV metadata using
pandas, validating expected columns and image paths.
- **Split strategy:** rather than a random train/test split, the pipeline
deliberately partitions data by `US_Machine` (data source) —
holding one source out entirely from training. This produces two
distinct evaluation sets from the sa …