PAIR / README.md
fantos's picture
Update README.md
57815fe verified

A newer version of the Gradio SDK is available: 5.49.1

Upgrade
metadata
title: PAIR-inspired Delivery Timing Predictor
emoji: 😻
colorFrom: red
colorTo: green
sdk: gradio
sdk_version: 5.42.0
app_file: app.py
pinned: false

PAIR-inspired Delivery Timing Predictor (Gradio Space)

https://www.tandfonline.com/doi/full/10.1080/14767058.2025.2532099

Important This demo is inspired by the PAIR study (Perinatal artificial intelligence in ultrasound) but does not include the proprietary model or the private clinical dataset described in the paper. It is provided only as a technical scaffold and demonstration UI.

What this Space does

  1. Lets you upload ultrasound images (PNG/JPG) or DICOM files and returns:
    • Predicted days-until-delivery (regression).
    • Preterm probability and label (binary classification with threshold 0.5).
  2. Aggregates predictions across multiple images from the same exam using a simple mean.
  3. Can load your own PyTorch weights via a Hugging Face repo id or a path to a .pt file.

How to use in your own Space

  1. Create a new Space on Hugging Face with SDK set to Gradio.
  2. Upload the files in this repository.
  3. Optional: place your model weights at weights/pair_v4.pt or set the env var HF_WEIGHTS to point to a Hugging Face model repo or a local .pt file.
  4. Click Run. If weights are missing, the app falls back to a constant baseline just to demonstrate the UI.

Model input

  • One or more 2D ultrasound images or DICOM frames from one exam. The app will convert grayscale to 3-channels when needed.

Model output

  • days_to_delivery: float in [1, 300] (clamped).
  • preterm_proba: float in [0, 1].
  • preterm_label: Term if proba < 0.5, Preterm otherwise.
  • predicted_date: today + days_to_delivery (for demo; in clinical use you would provide the scan date).

Notes

  • This is not a medical device and is not for clinical use.
  • Performance will be meaningless without appropriate training on a suitable dataset; this scaffold is for integration and UI only.
  • To replicate the paper, you would need authorized access to a comparable dataset and a trained model.