Advertisement
Guest User

Working Deepfake Code

a guest
Sep 7th, 2020
849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. !pip install scikit-video
  2. import skvideo.io
  3. driving_video = skvideo.io.vread("/content/gdrive/My Drive/first-order-motion-model/huhu.mp4")
  4. print(driving_video.shape)
  5.  
  6. import imageio
  7. import numpy as np
  8. import matplotlib.pyplot as plt
  9. import matplotlib.animation as animation
  10. from skimage.transform import resize
  11. from IPython.display import HTML
  12. import warnings
  13. warnings.filterwarnings("ignore")
  14.  
  15. source_image = imageio.imread('/content/gdrive/My Drive/first-order-motion-model/prej.png')
  16.  
  17. #Resize image and video to 256x256
  18.  
  19. source_image = resize(source_image, (256, 256))[..., :3]
  20. driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video]
  21.  
  22. def display(source, driving, generated=None):
  23. fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6))
  24.  
  25. ims = []
  26. for i in range(len(driving)):
  27. cols = [source]
  28. cols.append(driving[i])
  29. if generated is not None:
  30. cols.append(generated[i])
  31. im = plt.imshow(np.concatenate(cols, axis=1), animated=True)
  32. plt.axis('off')
  33. ims.append([im])
  34.  
  35. ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000)
  36. plt.close()
  37. return ani
  38.  
  39.  
  40. HTML(display(source_image, driving_video).to_html5_video())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement