Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !pip install scikit-video
- import skvideo.io
- driving_video = skvideo.io.vread("/content/gdrive/My Drive/first-order-motion-model/huhu.mp4")
- print(driving_video.shape)
- import imageio
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib.animation as animation
- from skimage.transform import resize
- from IPython.display import HTML
- import warnings
- warnings.filterwarnings("ignore")
- source_image = imageio.imread('/content/gdrive/My Drive/first-order-motion-model/prej.png')
- #Resize image and video to 256x256
- source_image = resize(source_image, (256, 256))[..., :3]
- driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video]
- def display(source, driving, generated=None):
- fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6))
- ims = []
- for i in range(len(driving)):
- cols = [source]
- cols.append(driving[i])
- if generated is not None:
- cols.append(generated[i])
- im = plt.imshow(np.concatenate(cols, axis=1), animated=True)
- plt.axis('off')
- ims.append([im])
- ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000)
- plt.close()
- return ani
- HTML(display(source_image, driving_video).to_html5_video())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement