Python+AI makes static pictures move
Hello, everyone.
Have you ever seen a video like this when you are watching short videos? A static picture of a person in the video can move, such as tilting the head or blinking.
Similar to the effect below
The character on the far left is the original action, and the above is a static picture. Through AI technology, the movements of the character on the far left can be applied to the static picture above, so that all pictures can make the same movement.
This technology is generally implemented based on GAN (Generative Adversarial Network). Today I will share with you an open source project that can reproduce the above effect. You can do interesting projects and remember old friends.
1. Run the project
Project address: https://github.com/AliaksandrSiarohin/first-order-model
First, git clone downloads the project to the local, Enter the project to install dependencies.
git clone https://github.com/AliaksandrSiarohin/first-order-model.git<br>cd first-order-model<br>pip install -r requirements.txt
Then, under the title Pre-trained checkpoint on the project homepage, find the model download link and download the model file. There are many models. I use vox-adv-cpk.pth.tar.
After preparing the model file, execute the following command in the project root directory.
python demo.py<br>--config config/vox-adv-256.yaml <br>--driving_video src_video.mp4 <br>--source_image src_img.jpg <br>--checkpoint weights/vox-adv-cpk.pth.tar
Explain the parameters:
- --config: model configuration file, there are
- --driving_video: provide action video
- --source_image: Static image that needs to be animated
- --checkpoint: The model file just downloaded
After the execution is completed, you will see the following input.
This project uses PyTorch to build a neural network and supports GPU and CPU operation, so if your computer only has a CPU, the operation will be slower.
I run it under CPU. As you can see from the picture above, driving_video only has 31 frames. If you are also running on CPU, it is best to control the duration of the driving_video video, otherwise the running time will be longer.
With this project, you can make some interesting attempts on your own.
2. Python API
The above teaches you how to run the project on the command line according to the official website.
Some friends may want to call it in Python projects, so I extracted the core code in demo.py and encapsulated a Python API.
Friends in need can download this file, put it in the same directory as first-order-model, and call it according to the following code.
fom = FOM()<br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 查看驱动视频,驱动视频最好裁剪为480 x 640 大小的视频</span><br>driving_video = <span style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">''</span><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 被驱动的画面</span><br>source_image = <span style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">''</span><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 输出视频</span><br>result_video = <span style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">''</span><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 驱动画面</span><br>fom.img_to_video(driving_video, source_image, result_video)
The above is the detailed content of Python+AI makes static pictures move. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

The built-in quantization tools on the exchange include: 1. Binance: Provides Binance Futures quantitative module, low handling fees, and supports AI-assisted transactions. 2. OKX (Ouyi): Supports multi-account management and intelligent order routing, and provides institutional-level risk control. The independent quantitative strategy platforms include: 3. 3Commas: drag-and-drop strategy generator, suitable for multi-platform hedging arbitrage. 4. Quadency: Professional-level algorithm strategy library, supporting customized risk thresholds. 5. Pionex: Built-in 16 preset strategy, low transaction fee. Vertical domain tools include: 6. Cryptohopper: cloud-based quantitative platform, supporting 150 technical indicators. 7. Bitsgap:

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

The top 10 digital virtual currency trading platforms are: 1. Binance, 2. OKX, 3. Coinbase, 4. Kraken, 5. Huobi Global, 6. Bitfinex, 7. KuCoin, 8. Gemini, 9. Bitstamp, 10. Bittrex. These platforms all provide high security and a variety of trading options, suitable for different user needs.

This groundbreaking development will enable financial institutions to leverage the globally recognized ISO20022 standard to automate banking processes across different blockchain ecosystems. The Ease protocol is an enterprise-level blockchain platform designed to promote widespread adoption through easy-to-use methods. It announced today that it has successfully integrated the ISO20022 messaging standard and directly incorporated it into blockchain smart contracts. This development will enable financial institutions to easily automate banking processes in different blockchain ecosystems using the globally recognized ISO20022 standard, which is replacing the Swift messaging system. These features will be tried soon on "EaseTestnet". EaseProtocolArchitectDou

Use the EXPLAIN command to analyze the execution plan of MySQL queries. 1. The EXPLAIN command displays the execution plan of the query to help find performance bottlenecks. 2. The execution plan includes fields such as id, select_type, table, type, possible_keys, key, key_len, ref, rows and Extra. 3. According to the execution plan, you can optimize queries by adding indexes, avoiding full table scans, optimizing JOIN operations, and using overlay indexes.
