Skip to content

Instantly share code, notes, and snippets.

@edgeboyo
Created October 20, 2020 13:48
Show Gist options
  • Select an option

  • Save edgeboyo/f8bc3eaad08b07d410db2f0dbdf5a422 to your computer and use it in GitHub Desktop.

Select an option

Save edgeboyo/f8bc3eaad08b07d410db2f0dbdf5a422 to your computer and use it in GitHub Desktop.

Revisions

  1. edgeboyo revised this gist Oct 20, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    !pip install PyYAML==5.3.1
    !git clone https://github.com/AliaksandrSiarohin/first-order-model
    pip install PyYAML==5.3.1
    git clone https://github.com/AliaksandrSiarohin/first-order-model
  2. edgeboyo created this gist Oct 20, 2020.
    42 changes: 42 additions & 0 deletions quickrun.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    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(input("Point to source picture: "))
    reader = imageio.get_reader(input("Point to trainer video: ))


    #Resize image and video to 256x256

    source_image = resize(source_image, (256, 256))[..., :3]

    fps = reader.get_meta_data()['fps']
    driving_video = []
    try:
    for im in reader:
    driving_video.append(im)
    except RuntimeError:
    pass
    reader.close()

    driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video]

    from demo import load_checkpoints
    generator, kp_detector = load_checkpoints(config_path='config/vox-256.yaml',
    checkpoint_path='damedame/vox-cpk.pth.tar')

    from demo import make_animation
    from skimage import img_as_ubyte

    predictions = make_animation(source_image, driving_video, generator, kp_detector, relative=True)

    #save resulting video
    imageio.mimsave('../generated.mp4', [img_as_ubyte(frame) for frame in predictions], fps=fps)
    #video can be downloaded from /content folder

    # HTML(display(source_image, driving_video, predictions).to_html5_video())
    2 changes: 2 additions & 0 deletions startup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    !pip install PyYAML==5.3.1
    !git clone https://github.com/AliaksandrSiarohin/first-order-model