plot_videos#
- deepinv.utils.plot_videos(vid_list, titles=None, time_dim=2, rescale_mode='min_max', display=False, figsize=None, dpi=None, save_fn=None, return_anim=False, anim_writer=None, anim_kwargs={}, **plot_kwargs)[source]#
Plots and animates a list of image sequences.
Plots videos as sequence of side-by-side frames, and saves animation (e.g. GIF) or displays as interactive HTML in notebook. This is useful for e.g. time-varying inverse problems. Individual frames are plotted with
deepinv.utils.plot()
Plots videos as sequence of side-by-side frames, and saves animation (e.g. GIF) or displays as interactive HTML in notebook. This is useful for e.g. time-varying inverse problems. Individual frames are plotted with
deepinv.utils.plot()
vid_list can either be a video or a list of them. A video is defined as images of shape(B,C,H,W)
augmented with a time dimension specified bytime_dim
, e.g. of shape(B,C,T,H,W)
andtime_dim=2
. All videos must be same time-length.Per frame of the videos, this function calls
deepinv.utils.plot()
, see its params to see how the frames are plotted.To display an interactive HTML video in an IPython notebook, use
display=True
. Note IPython must be installed for this. Per frame of the videos, this function callsdeepinv.utils.plot()
, see its params to see how the frames are plotted. To display an interactive HTML video in an IPython notebook, usedisplay=True
. Note IPython must be installed for this.
- Examples:
Display list of image sequences live in a notebook:
>>> from deepinv.utils import plot_videos >>> x = torch.rand((1, 3, 5, 8, 8)) # B,C,T,H,W image sequence >>> y = torch.rand((1, 3, 5, 16, 16)) >>> plot_videos([x, y], display=True) # Display interactive view in notebook (requires IPython) >>> plot_videos([x, y], save_fn="vid.gif") # Save video as GIF
- Parameters:
vid_list (Union[torch.Tensor, List[torch.Tensor]]) – video or list of videos as defined above.
titles (Union[str, List[str]]) – titles of images in frame, defaults to
None
.time_dim (int) – time dimension of the videos. All videos should have same length in this dimension, or length 1. After indexing this dimension, the resulting images should be of shape
(B,C,H,W)
. Defaults to 2.rescale_mode (str) – rescaling mode for
deepinv.utils.plot()
, defaults to"min_max"
vid_list – video or list of videos as defined above
titles – titles of images in frame, defaults to
None
time_dim – time dimension of the videos. All videos should have same length in this dimension, or length 1. After indexing this dimension, the resulting images should be of shape
(B,C,H,W)
. Defaults to 2rescale_mode – rescaling mode for
deepinv.utils.plot()
, defaults to"min_max"
display (bool) – display an interactive HTML video in an IPython notebook, defaults to False
figsize (tuple[int], None) – size of the figure. If
None
, calculated from size of img list.save_fn (str) – if not
None
, save the animation to this filename. File extension must be provided, noteanim_writer
might have to be specified. Defaults toNone
save_fn – if not
None
, save the animation to this filename. File extension must be provided, noteanim_writer
might have to be specified. Defaults toNone
anim_writer (str) – animation writer, see https://matplotlib.org/stable/users/explain/animations/animations.html#animation-writers, defaults to
None
return_anim (bool) – return matplotlib animation object, defaults to
False
dpi (int) – DPI of saved videos.
anim_kwargs (dict) – keyword args for matplotlib FuncAnimation init
plot_kwargs (dict) – kwargs to pass to
deepinv.utils.plot()
Examples using plot_videos
:#

Self-supervised MRI reconstruction with Artifact2Artifact