torchvideo.tools

Tools

torchvideo.tools.show_video(frames, fps=30, ndarray_format='THWC')[source]

Show frames as a video in Jupyter, or in a PyGame window using moviepy.

Parameters
  • frames (Union[Tensor, ndarray, List[Image]]) –

    One of:

    • torch.Tensor with layout CTHW.

    • numpy.ndarray of layout THWC or CTHW, if the latter, then set ndarray_format to CTHW. The array should have a np.uint8 dtype and range [0, 255].

    • a list of PIL.Image.Image.

  • fps (optional) – Frame rate of video

  • ndarray_format – ‘CTHW’ or ‘THWC’ depending on layout of ndarray.

Returns

ImageSequenceClip displayed.

torchvideo.tools.convert_to_clip(frames, fps=30, ndarray_format='THWC')[source]

Convert frames to a moviepy ImageSequenceClip.

Parameters
  • frames

    One of:

    • torch.Tensor with layout CTHW.

    • numpy.ndarray of layout THWC or CTHW, if the latter, then set ndarray_format to CTHW. The array should have a np.uint8 dtype and range [0, 255].

    • a list of PIL.Image.Image.

  • fps (optional) – Frame rate of video

  • ndarray_format – ‘CTHW’ or ‘THWC’ depending on layout of ndarray.

Returns

ImageSequenceClip