How to create Real Deepfakes ?
Tags: machinelearning, deeplearning, python, github
Published: 2021-04-05 09:57:16

![Deepfake-using-first-order-motion-model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mczxnk7q90ov82x5ds8o.png)

First things first !
##What is a deepfake ?
>Deepfakes are basically fake videos of real people or objects generated using complex machine learning algorithms, that require some good computational power as well.  

So, I was just wondering on youtube and suddenly youtube algorithm came up with some unexpected recommendation, it was Jordan peele and Barack Obama's deep fake video. which you can watch it [here](https://www.youtube.com/watch?v=cQ54GDm1eL0)
and I decided to make one like that. 

Now, I don't have any experience with machine learning or deep learning stuff, neither I have that much computational power, but still I found one really cool Github repo out there which can help with all those problems.  {% github AliaksandrSiarohin/first-order-model no-readme %} 

Now, as this Repository states that it contains the source code for the paper [First Order Motion Model for Image Animation](https://papers.nips.cc/paper/8935-first-order-motion-model-for-image-animation) by Aliaksandr Siarohin, [Stéphane Lathuilière](http://stelat.eu), [Sergey Tulyakov](http://stulyakov.com), [Elisa Ricci](http://elisaricci.eu/) and [Nicu Sebe](http://disi.unitn.it/~sebe/). So all with all credits to them they have done some really great work.

Now we can easily clone this repo to our pc and start working on it, but that will require you to install all the heavy requirements too, which I think will take much more time if you have never worked with all that machine learning stuff. And also not to forget the GPU power that's required.

So, I think in that case we should use the [Colab Demo](https://colab.research.google.com/github/AliaksandrSiarohin/first-order-model/blob/master/demo.ipynb) that they have provided which is much easier to work with. Now all you need is google drive account to add source image and driving video to the modal.

Also you will need to add first-order-motion-modal folder from the link provided in colab demo file to your G-drive which you can download and upload it to your drive or you can simply create a copy to your drive.

This folder includes some default data in it to try but you can easily add your data to the modal by changing the path in source_image and reader. 

![colab-demo screen shot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/heecdzntisqkd9uayne6.png)

Change the path in both the variable to your g-drive location like for example if your source_image and driving video are located in 'My drive' than your path will be 

```python
source_image = imageio.imread('/content/gdrive/My Drive/source_image.png')
```
```python
reader = imageio.get_reader('/content/gdrive/My Drive/driving_video.mp4')
```


Now there are some limitations to this modal which you have to keep in mind in order to make it work as expected. For the source_image it should be a proper square image i.e the aspect ratio of the source image should be exactly 1:1 . similarly the dirving video should also be a proper square video you can choose any of online services to crop video to 1:1 aspect ratio.

Once you have done that just run the remaining code blocks from colab-demo and you will have your deepfake video.