deepinv.utils#

This module provides various plotting and utility functions. Please refer to the user guide for more information.

Plotting#

User Guide: refer to Plotting for more information.

deepinv.utils.plot

Plots a list of images.

deepinv.utils.plot_curves

Plots the metrics of a Plug-and-Play algorithm.

deepinv.utils.plot_parameters

Plot the parameters of the model before and after training.

deepinv.utils.plot_inset

Plots a list of images with zoomed-in insets extracted from the images.

deepinv.utils.plot_videos

Plots and animates a list of image sequences.

deepinv.utils.save_videos

Saves an animation of a list of image sequences.

deepinv.utils.plot_ortho3D

Plots an orthogonal view of 3D images.

deepinv.utils.disable_tex

Globally disable LaTeX

deepinv.utils.enable_tex

Globally enable LaTeX

deepinv.utils.normalize_signal

Normalize a batch of signals between zero and one.

deepinv.utils.plotting.config_matplotlib

Config matplotlib for nice plots in the examples.

TensorList#

User Guide: refer to TensorList for more information.

deepinv.utils.TensorList

Represents a list of torch.Tensor with different shapes.

deepinv.utils.zeros_like

Returns a deepinv.utils.TensorList or torch.Tensor with the same type as x, filled with zeros.

deepinv.utils.ones_like

Returns a deepinv.utils.TensorList or torch.Tensor with the same type as x, filled with ones.

deepinv.utils.randn_like

Returns a deepinv.utils.TensorList or torch.Tensor with the same type as x, filled with standard gaussian numbers.

deepinv.utils.rand_like

Returns a deepinv.utils.TensorList or torch.Tensor with the same type as x, filled with random uniform numbers in [0,1].

Logging#

User Guide: refer to Logging for more information.

deepinv.utils.AverageMeter

Compute and store aggregates online from a stream of scalar values

deepinv.utils.ProgressMeter

deepinv.utils.get_timestamp

Get current timestamp string.

Mixins#

User Guide: refer to Mixins for more information.

deepinv.utils.MRIMixin

Mixin base class for MRI functionality.

deepinv.utils.TimeMixin

Base class for temporal capabilities for physics and models.

deepinv.utils.TiledMixin2d

Mixin base class for 2D tiled patch extraction and reconstruction.

Image Loading#

User Guide: refer to Image Loading for more information.

deepinv.utils.load_dicom

Load image from DICOM file.

deepinv.utils.load_nifti

Load volume from nifti file as torch tensor.

deepinv.utils.load_url

Load URL to a buffer.

deepinv.utils.load_np

Load numpy array from file as torch tensor.

deepinv.utils.load_torch

Load torch tensor from file.

deepinv.utils.load_mat

Load MATLAB array from file.

deepinv.utils.load_raster

Load a raster image and return patches as tensors using rasterio.

deepinv.utils.load_ismrmd

Load complex MRI data from ISMRMD format.

Demo Utils#

User Guide: refer to Demo Utils for more information.

deepinv.utils.load_image

Load an image from a file and return a torch.Tensor with a batch dimension.

deepinv.utils.load_url_image

Load an image from a URL and return a torch.Tensor with a batch dimension.

deepinv.utils.load_np_url

Load a numpy array from url and convert to tensor.

deepinv.utils.load_torch_url

Load an array from url and read it by torch.load.

deepinv.utils.load_example

Load example image from the DeepInverse HuggingFace.

deepinv.utils.download_example

Download an image from the DeepInverse HuggingFace to file.

deepinv.utils.get_data_home

Return a folder to store deepinv datasets.

deepinv.utils.get_image_url

Get URL for image from DeepInverse HuggingFace repository.

deepinv.utils.get_degradation_url

Get URL for degradation from DeepInverse HuggingFace repository.

deepinv.utils.load_dataset

Loads an ImageFolder dataset from DeepInverse HuggingFace repository.

deepinv.utils.load_degradation

Loads a degradation tensor from DeepInverse HuggingFace repository.

Other#

User Guide: refer to Other for more information.

deepinv.utils.get_freer_gpu

Returns the GPU device with the most free memory.

deepinv.utils.dirac

Returns a torch.Tensor with a Dirac delta in 2D at the center.

deepinv.utils.dirac_like

Returns a deepinv.utils.TensorList or torch.Tensor with the same type as x, filled with zeros.

deepinv.utils.dirac_comb

Returns a torch.Tensor with a Dirac comb in 2D (impulse train) at the given step.

deepinv.utils.dirac_comb_like

Returns a deepinv.utils.TensorList or torch.Tensor with the same type as x, filled with a Dirac comb at the given step.