Giter Site home page Giter Site logo

zzxslp / first-order-model Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aliaksandrsiarohin/first-order-model

0.0 0.0 0.0 75.81 MB

This repository contains the source code for the paper First Order Motion Model for Image Animation

Home Page: https://aliaksandrsiarohin.github.io/first-order-model-website/

License: Other

Python 7.15% Jupyter Notebook 92.82% Dockerfile 0.03%

first-order-model's Introduction

First Order Motion Model for Image Animation

This repository provides an improved usage for the project First Order Motion Model for Image Animation.

Example animations

The videos on the left show the driving videos. The first row on the right for each dataset shows the source videos. The bottom row contains the animated sequences with motion transferred from the driving video and object taken from the source image. We trained a separate network for each task.

VoxCeleb Dataset

Screenshot

Installation and Usage

  1. Create a virtual environment with dependecies.

Since the model is dependent on a much odlder version of pytorch (1.0.0), we use Anaconda to manage dependencies.

Install anaconda on your local machine or server from here.

Once anaconda is installed, create a virtual environment named deepfake. In your terminal, run:

conda create -n deepfake python=3.7

Verify that the new environment was installed correctly:

conda env list

Activate the enviroment you just created:

conda activate deepfake

Now you can download the repo and install dependencies:

cd first-order-model
pip install -r requirements.txt
  1. Prepare data

We have prepared a sample video and an image under the folder mydata. If you would like to crop videos and images on your own, refer to the Crop videos and images session below. Generally, the extact size of 256x256 for videos and images are not required, but you should use sources with similar scales and make sure the human face is in the middle of your video/image.

To run the demo, you also need to download a checkpoint of the model. Checkpoints can be found under following link: google-drive or yandex-disk. Select vox-adv-cpk.pth.tar, download it and put under the mydata directory.

  1. Animation Demo

To run the demo and generate a video, run the following command:

python demo.py --relative --adapt_scale --config config/dataset_name.yaml --driving_video path/to/driving --source_image path/to/source --checkpoint path/to/checkpoint --result_video path/to/output --cpu

The result will be stored in output/result.mp4.

Example command in our case: (In our example, we put the video, image and the checkpoint all under folder mydata)

python demo.py  --relative --adapt_scale --config config/vox-adv-256.yaml --driving_video mydata/unravel.mp4 --source_image mydata/girl.png --checkpoint mydata/vox-adv-cpk.pth.tar --result_video output/result.mp4  --cpu

If you have GPU on your computer, delete the --cpu flag.

You shoule obtain an animated video result.mp4 under output.

Crop videos and images

The driving videos and source images should be cropped (or at least the human-face/object is in the middle of your image) before it can be used in our method. To obtain some semi-automatic crop suggestions you can use python crop-video.py --inp some_youtube_video.mp4. It will generate commands for crops using ffmpeg. In order to use the script, face-alligment library is needed:

git clone https://github.com/1adrianb/face-alignment
cd face-alignment
pip install -r requirements.txt
python setup.py install

We also provide a piece of code for resize images in python.

TODO: fix bug in crop-video.py and improve crop-img.py

Face-swap

It is possible to modify the method to perform face-swap using supervised segmentation masks. Screenshot For both unsupervised and supervised video editing, such as face-swap, please refer to Motion Co-Segmentation.

first-order-model's People

Contributors

abcdea avatar aliaksandrsiarohin avatar angwhen avatar dependabot[bot] avatar kmielnik avatar mikaelhg avatar s0lst1ce avatar s1ddok avatar ufoym avatar vsoch avatar zerocool940711 avatar zzxslp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.