Python code realizes static pictures to move
Article directory
foreword
Recently, Douyin’s popular ancient paintings have been revived, and video accounts such as ancient paintings and singing are very popular, so I want to try how to realize it. Various Baidu, git, and found a case made by a big guy using open source algorithms. Thanks for sharing here. The content of this article is to record the bitter journey of realizing this function.
1. Project acquisition
Project address: Daxie's
Project address: my
2. Environment construction
Download the virtual environment creation tool: "pip install virtualenv"
Create a virtual environment: "virtualenv env"
Activate the virtual environment:: "env/Script/activate" (Note that my method here is)
Download dependencies: "pip install -r requirements. txt"
3. Reference the pytorch library
PyTorch是一个开源的Python机器学习库,基于Torch,用于自然语言处理等应用程序。
工程提示使用torch库的版本如下:
pip install torch===1.0.0 torchvision===0.2.1 -f https://download.pytorch.org/whl/cu100/torch_stable.html
Pay attention to the system GPU version CMD input: nvcc -V to view the version, if the command reports an error, it means that CUDA is not installed. Download address: cuda
must pay attention to the version, I was stuck here for several days. The reason is that the CUDA version supported by my graphics card is 11.1, and the CUDA version is backward compatible, and the CUDA version supported by the torch1. Because I downloaded a version above 11.1 (because I have downloaded and tried multiple versions), I was prompted that the GPU cannot be used; with the help of the boss, it was suggested that I use a lower version, and then I got out of the bitter sea of environment configuration.
Four, ffmpeg video processing tools
1. Tool download
Tool official website download address: ffmpeg
chooses to download according to your own system, mine is win10, click the button in Figure 1 below, and then select any one in Figure 2 below to enter the git download address; select the corresponding version. I use win104.2;
2. Environment configuration
After downloading, unzip it to the specified address (you can do as you like), then configure the system environment variables, and add the installation directory to the system environment variable PATH.
D:\Software\FFmpeg\ffmpeg-4.2.1-win64-static\ffmpeg-4.2.1-win64-static\bin
5. Function realization (results)
Summarize
At present, my technical level can only write some simple gadgets, can read codes, and cannot use Python to do commercial-level projects, so it is a great challenge for me. After two weeks of groping, I have been stuck in the environment Configuration, you have to be thick-skinned on the way of seeking knowledge. I was too embarrassed to ask questions at first, because I am too good at it. The basic environment has been stuck for a long time, and then I boldly asked the boss. But the boss is too busy. Then the environment configuration was completed under the guidance of former colleagues. This effect was finally achieved. Two weeks was too long, especially during the difficult period, and I almost gave up.