zea.models¶
Collection of (generative) models for ultrasound imaging.
zea contains a collection of models for various tasks, all located in the zea.models package.
See the following dropdown for a list of available models:
Available models
zea.models.echonet.EchoNetDynamic: A model for left ventricle segmentation.zea.models.carotid_segmenter.CarotidSegmenter: A model for carotid artery segmentation.zea.models.echonetlvh.EchoNetLVH: A model for left ventricle hypertrophy segmentation.zea.models.unet.UNet: A simple U-Net implementation.zea.models.lpips.LPIPS: A model implementing the perceptual similarity metric.zea.models.taesd.TinyAutoencoder: A tiny autoencoder model for image compression.zea.models.regional_quality.MobileNetv2RegionalQuality: A scoring model for myocardial regions in apical views.zea.models.lv_segmentation.AugmentedCamusSeg: A nnU-Net based left ventricle and myocardium segmentation model.zea.models.speckle2self.Speckle2Self: A self-supervised speckle reduction model for ultrasound images.
Presets for these models can be found in zea.models.presets. Presets are pre-trained weights for the models, which can be used to initialize the models for inference or further training. Each model class has a presets attribute that lists the available presets for that model. We store the presets on Hugging Face Hub, and they are downloaded automatically when loading a model with a preset.
To use these models, you can import them directly from the zea.models module and load the pretrained weights using the from_preset() method. For example:
>>> from zea.models.unet import UNet
>>> model = UNet.from_preset("unet-echonet-inpainter")
You can list all available presets using the presets attribute:
>>> from zea.models.unet import UNet
>>> presets = list(UNet.presets.keys())
>>> print(f"Available built-in zea presets for UNet: {presets}")
Available built-in zea presets for UNet: ['unet-echonet-inpainter']
Generative models¶
In addition to regular models, zea provides generative models for tasks such as image
generation, inpainting, and denoising. The key difference is that generative models have
sampling methods implemented. There are two base classes:
GenerativeModel for classical models (e.g. a Gaussian
mixture model) and DeepGenerativeModel for
neural-network-based models — the latter also inherits from
BaseModel, adding Keras features like weight saving and preset
loading. Both expose the following methods:
fit()for training the model on datasample()for generating new samples from the learned distributionposterior_sample()for drawing samples from the posterior given measurementslog_density()for computing the log-probability of data under the model
See the following dropdown for a list of available generative models:
Available models
zea.models.diffusion.DiffusionModel: A deep generative diffusion model for ultrasound image generation.zea.models.flow_matching.FlowMatchingModel: A flow matching generative model for ultrasound image generation.zea.models.gmm.GaussianMixtureModel: A Gaussian Mixture Model.zea.models.hvae.HierarchicalVAE: A hierarchical variational autoencoder for ultrasound image generation.
An example of how to use the zea.models.diffusion.DiffusionModel is shown below:
>>> from zea.models.diffusion import DiffusionModel
>>> model = DiffusionModel.from_preset("diffusion-echonet-dynamic")
>>> samples = model.sample(n_samples=4)
Modules
Base model class for all zea Keras models. |
|
Carotid segmentation model. |
|
DeepLabV3+ architecture for multi-class segmentation. |
|
Dense models and architectures |
|
Diffusion models for ultrasound image generation and posterior sampling. |
|
Diffusion Transformer (DiT) backend. |
|
Echonet-Dynamic segmentation model for cardiac ultrasound segmentation. |
|
EchoNetLVH model for segmentation of PLAX view cardiac ultrasound. |
|
Flow matching generative model for ultrasound image generation and posterior sampling. |
|
Generative models for zea. |
|
Gaussian Mixture Model (GMM) implementation |
|
Hierarchical Variational Auto-Encoder for image generation, posterior sampling and inference tasks. |
|
Layers used in zea.models |
|
LPIPS model for perceptual similarity. |
|
nnU-Net segmentation model trained on the augmented CAMUS dataset. |
|
Mostly from keras_hub.src.models import preset_utils |
|
Model presets for zea.models |
|
MobileNetv2 based image quality model for myocardial regions in apical views. |
|
Speckle2Self self-supervised speckle reduction model for ultrasound images. |
|
Tiny Autoencoder (TAESD) model. |
|
UNet models and architectures. |
|
Utilities for models |