import matplotlib.pyplot as plt import matplotlib.animation as animation %matplotlib inline fig = plt.figure(dpi=200) ims = [] for t in range(0, img1.shape[0]): imx = img1[t,:,:] im = plt.imshow(imx, cmap='gray', animated=True) ims.append([im]) ani = animation.ArtistAnimation(fig, ims, interval=200, blit=True, repeat_delay=1000) plt.close() from IPython.display import HTML HTML(ani.to_jshtml()) # if you want to keep inside function you can use display(HTML(ani.to_jshtml())) Example: def playVideo(input_sample): numFrames = input_sample.shape[0] fig = plt.figure() fig.set_size_inches(10, 10, True) im = plt.imshow(input_sample[0,:,:]) plt.close() def update(i): img = input_sample[i,:,:] im...