Azmarie / Caricature-Your-Face

🧑🏻‍🎤 Generate geometry-aware face caricatures using Style Transfer
https://azmariewang.medium.com/geometry-aware-style-transfer-implementation-and-analysis-3a9034dfca2d
MIT License
38 stars 5 forks source link
caricatures facial-landmarks neural-style-transfer style-transfer

Caricature Your Face

💡 Using The Face of Arts and DST to generate geometry-aware face caricatures.

📖 This project in details with analysis on Medium: Geometry-Aware Style Transfer: Implementation and Analysis

Requirements

Set up the virtual environment:

python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt

after setup, you can just run source venv/bin/activate to activate the venv later on.

How To Run

preprocessing.sh is used to convert all Face of Art style images' correspondence points into .txt, this only need to be run once if you don't already have data/style/pts containing all Face of Art style images.

run.sh is a script automating the two steps for geometry style transfer.

Currently, run.sh serve as a demo with Barack Obama as the content image and Vincent van Gogh's self-portrait with the style image.

1. Obtain Facial Landmark

This step will obtain the facial landmarks for the content image with dlib.

python face_landmark_detection.py ${content_path} ${style_path} ${content_pts_path} ${style_pts_path_dlib}

2. Run Style Transfer

Now, run deformable style transfer, this step will take ~1.5 minutes on a single GPU.

Please check parameter adjustment in DST repo [code].

python main.py ${content_path} ${style_path} ${content_pts_path} ${style_pts_path} \
  ${output_dir} ${output_prefix} ${im_size} ${max_iter} \
  ${checkpoint_iter} ${content_weight} ${warp_weight} ${reg_weight} ${optim} \
  ${lr} ${verbose} ${save_intermediate} ${save_extra} ${device}

Results

Demo

Result from run.sh with Barack Obama as the content image and Vincent van Gogh's self-portrait with the style image. Images from left to right are: input content image, input style image, a standard style transfer output, demo output.

More Results

Acknowledgment