Paddegan takes you to immersive space travel (ノェェノ): achieve high-quality style migration

Keywords: AI Computer Vision Deep Learning

[PaddleGAN Immersive space travel 👨‍🚀] Teach you to quickly realize the transfer of high-quality artistic style

Can roam the universe without a spaceship?! 👨‍🚀👩‍🚀

You're not dreaming! 🚀

AI art style migration makes your dream come true!!! 🛰

Don't feel out of reach today PaddleGAN Just use the power of AI to lead you on the fantastic journey of the five planets, so that you can "immerse" in the fantastic universe!

It can combine the magic of the planet with the grass flying around us! While experiencing the daily natural scenery and urban scenery, you can experience a series of unexpected and interesting scenes (kindly remind you to buy "surprise insurance", "scare insurance", "shock insurance", "over hi insurance" and other relevant insurance ╮ (╯▽) ╭)

OK, everything is ready. The spaceship paddegan is about to take off. Developers who haven't boarded the plane hurry to scan the code and get on the bus!

Analysis of LapStyle principle

LapStyle, a high-quality stylization method based on Laplacian pyramid developed by Baidu vision team, not only takes into account the quality and speed of style migration, but also flexibly trains various styles! It is a leader in the field of style migration!

How good is it? His paper "drafting and revision: Laplacian pyramid network for fast high quality artistic style transfer" has been included in CVPR2021!

The most conscience is that its relevant code has been open source in the propeller generation countermeasure network development kit PaddleGAN And provides four pre training style models, one line of code direct reasoning! GET the same style of international famous paintings every minute!!

Download paddegan & install related dependencies

# Clone paddegan code from github (if the download speed is too slow, use gitee source)
#!git clone https://github.com/PaddlePaddle/PaddleGAN
#!git clone https://gitee.com/PaddlePaddle/PaddleGAN

# Installation dependency
%cd /home/aistudio/PaddleGAN
!pip install -r requirements.txt
%cd PaddleGAN
!git checkout develop

Using the pre training model

Four styles are built into paddegan's official website. You can realize style migration by running one line of code!

Corresponding to the following: StarryNew, Stars, Ocean, Circuit

In addition, this project helps you train the style model of five planets + pink planets, which can be used by one click reasoning

Pre training model path: / home/aistudio / planet style pre training model

  • --content_img (str): enter the content image path.
  • --output_path (str): the output image path. The default is output_dir.
  • --weight_path (str): the model weight path. When setting None, the pre training model will be downloaded by itself. The default is None.
  • --style (str): generate image style when weight_ When the path is None, it can be selected from starrynew, circuit, ocean and stars. The default is starrynew.
  • --style_image_path (str): enter the style image path, when weight_ If the path is not None, you need to enter it. The default is None.

You just need to replace -- content_img (str) makes stylized original drawings and -- output for itself_ Path (STR) is the path and -- weight of the result output_path (str) is the pre training parameter of the desired style, -- style_image_path (str) is a picture of the planet in the desired style.

!python applications/tools/lapstyle.py  \
        --content_img '/home/aistudio/Scenery on earth&Architecture/Jade Hare.png' \
        --output_path '/home/aistudio/Lunar scenery/Jade Hare' \
        --weight_path '/home/aistudio/Planet style pre training model/moon_iter_30000_weight.pdparams' \
        --style_image_path '/home/aistudio/Planet pictures/Moon.png'

Training custom style

If you are not satisfied with the above four styles, paddegan also supports you to train your own custom styles. Just download the training dataset coco2017 and replace the specific style you want~

A total of three models need to be trained: lapstyle_draft, lapstyle_rev_first, lapstyle_rev_second

Train in sequence. The model parameters of the previous training are used as the input of the next model until the training of the three models is completed and the final model training parameters are obtained~

  • Friendly tips: each training takes about 4 hours. It takes about 12 hours (GPU) to complete all the training of style model
#Decompress dataset
!unzip -oq /home/aistudio/data/data97273/annotations_trainval2017.zip
!unzip -oq /home/aistudio/data/data97273/train2017.zip
!unzip /home/aistudio/data/data7122/test2017.zip
#Train the first model
!python -u tools/main.py --config-file configs/lapstyle_draft.yaml 
#Train the second model
!python -u tools/main.py --config-file configs/lapstyle_rev_first.yaml --resume output_dir/lapstyle_rev_first-2021-09-09-18-02/iter_20000_checkpoint.pdparams
#Training the third model
!python -u tools/main.py --config-file configs/lapstyle_rev_second.yaml --resume output_dir/lapstyle_rev_second-2021-09-10-12-38/iter_25000_checkpoint.pdparams

Result display

Paddegan takes you to immersive space travel (ノェェノ): achieve high-quality style migration

Posted by atdawgie on Fri, 22 Oct 2021 08:04:50 -0700