def tensor_to_video(tensor, fps=4): tensor = tbxmake_np(tensor) tensor = tbx_prepare_video(tensor) # If user passes in uint8, then we don't need to rescale by 255 if tensor.dtype != np.uint8: tensor = (tensor * 255.0).astype(np.uint8) return tbxsummary.make_video(tensor, fps)
def tensor_to_clip(tensor, fps=4): tensor = tbxmake_np(tensor) tensor = tbx_prepare_video(tensor) # If user passes in uint8, then we don't need to rescale by 255 if tensor.dtype != np.uint8: tensor = (tensor * 255.0).astype(np.uint8) t, h, w, c = tensor.shape clip = mpy.ImageSequenceClip(list(tensor), fps=fps) return clip, (h, w, c)