Teach you how to realize the comic face in Douyin

Teach you how to realize the comic face in Douyin

There is a comic face special effect in Douyin. Upload a selfie profile picture, and a comic face will be automatically generated for you. Some camera software on the market provides the function of caricature faces, but it needs to be paid. I believe that many people would like to have a comic avatar of their own. This article will unpack for you how manga style images are generated.

When it comes to manga style, it is naturally inseparable from various algorithms such as machine learning and image processing. I will not introduce complex theories and various mathematical formulas here, but explain how to operate the current open source program ganilla .

Effect

Wukang Road

insert image description here

landscape

insert image description here
insert image description here

Qiandao Lake

insert image description here
insert image description here

Westward Journey

insert image description here

insert image description here

How to achieve

1. Download https://github.com/giddyyupp/ganilla from Github

2. Install Anaconda (all the following operations are performed on Anaconda's terminal command line interface)

3. Open Anaconda's terminal and install Pytorch and torchvision

pip install torch
pip install torchvision

4. Enter the ganilla directory just downloaded and install the relevant dependent files

pip install -r requirements.txt

5. After installation, we choose an image style. The specific style can be viewed through https://github.com/giddyyupp/ganilla/blob/master/docs/datasets.md. Here we choose a monet2photo to install. Enter the downloaded ganilla datasets directory and perform the following operations

download_cyclegan_dataset.sh monet2photo

Then we choose the model link that has been trained , and download one from it, such as the model file of AS.

insert image description here

Create a new as_pretrained folder under the checkpoints folder of ganilla, and put the downloaded pth file in it.

6. Put the pictures that need to be processed into manga into the monet2photo directory of the datasets directory of ganilla.

7. Enter under the ganilla directory

python test.py --dataroot ./datasets/monet2photo/ --name as_pretrained --model test

The directory after –dataroot above is the directory of the pictures to be processed, and the parameter after –name is the location directory of the model we downloaded, just enter it and press Enter.

8. The generated picture will be under the as_pretrained directory (named according to the style name) of ganilla's results.

FAQ

1. Those who have not installed cuda should report the error of SetDevice, you can modify the gpu_ids parameter in the ganilla/options/base_options.py file, and modify its default value from 0 to -1

2. The default size of the generated image is 256*256, and the original image will be scaled during image processing. If we want to generate a picture with a size of 512, we can modify the fineSize parameter in the ganilla/options/base_options.py file and change its default value from 256 to 512

Outlook

If the slice is 512 in size, you can modify the fineSize parameter in the ganilla/options/base_options.py file, and modify its default value from 256 to 512

Outlook

The transformation of this technology can actually be used in games. For example, players upload avatars and change the style of their avatars to comic style.

Guess you like

Origin blog.csdn.net/onelei1994/article/details/114178508