Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Python to realize the smile of the Mona Lisa

Shulou Source: shulou.com Published: 2022-06-01 19:59:25 09月30日 Update

This article mainly explains "how to use Python to realize the smile of the Mona Lisa". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Python to realize the smile of the Mona Lisa.

First of all, Clone the repository locally and install related dependencies.

Pip install-r requirements.txt

I recorded a video by myself, and I recorded a smiley face here, using the mp4 format. I haven't tested whether other formats are feasible. Copy the video to the warehouse directory. The warehouse provides a preprocessing file for processing video, first of all, you need to install face-alignment in a virtual environment.

Git clone https://github.com/1adrianb/face-alignmentcd face-alignmentpip install-r requirements.txtpython setup.py install

Then install ffmpeg.

Brew install ffmpeg

Use scripts to preprocess the video.

Python crop-video.py-inp video.mp4-cpu

This command does not process the video directly, but outputs a ffmpeg command that can be executed directly to process the video.

Ffmpeg-I video.mp4-ss 0.0-t 9.1-filter:v "crop=1023:943:238:0, scale=256:256" >

Next, we follow the link in the repository to download the model to the checkpoints directory of the project.

Finally, run the command to generate dynamic video, where crop.mp4 is the video we preprocessed in the previous step, image.jpg is our static image, and the model I use here is vox-cpk. You can also try other models.

Python demo.py-config config/vox-256.yaml-driving_video crop.mp4-source_image image.jpg-checkpoint checkpoints/vox-cpk.pth.tar-relative-adapt_scale-cpu

The final effect is as follows:

At this point, I believe you have a deeper understanding of "how to use Python to realize the smile of the Mona Lisa". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Video warehouse command version Lisa Mona Mona Lisa smile model processing preprocessing content format catalog learning feasible practical deeper interest dynamic Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Technology Apple Huawei NVidia