All Projects → lukasuz → stylegan2-landmark-projection

lukasuz / stylegan2-landmark-projection

Licence: other
Experimental repository attempting to project facial landmarks into the StyleGAN2 latent space.

Programming Languages

python
139335 projects - #7 most used programming language
Cuda
1817 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to stylegan2-landmark-projection

latent space adventures
Buckle up, adventure in the styleGAN2-ada-pytorch network latent space awaits
Stars: ✭ 59 (+321.43%)
Mutual labels:  projection, stylegan2, stylegan2-ada
steam-stylegan2
Train a StyleGAN2 model on Colaboratory to generate Steam banners.
Stars: ✭ 30 (+114.29%)
Mutual labels:  stylegan, stylegan2
HistoGAN
Reference code for the paper HistoGAN: Controlling Colors of GAN-Generated and Real Images via Color Histograms (CVPR 2021).
Stars: ✭ 158 (+1028.57%)
Mutual labels:  stylegan, stylegan2
overlord
Official pytorch implementation of "Scaling-up Disentanglement for Image Translation", ICCV 2021.
Stars: ✭ 35 (+150%)
Mutual labels:  stylegan, stylegan2
Alae
[CVPR2020] Adversarial Latent Autoencoders
Stars: ✭ 3,178 (+22600%)
Mutual labels:  face-generation, stylegan
cft
Climate futures toolbox: easy MACA (MACAv2) climate data access 📦
Stars: ✭ 16 (+14.29%)
Mutual labels:  projection
EasyWayLocation
This library contain all utils related to google location. like, getting lat or long, Address and Location Setting dialog, many more...
Stars: ✭ 142 (+914.29%)
Mutual labels:  projection
mapshaper-proj
A JavaScript port of the Proj.4 map projection library.
Stars: ✭ 29 (+107.14%)
Mutual labels:  projection
dataset-histology-landmarks
Dataset: landmarks for registration of histology images
Stars: ✭ 26 (+85.71%)
Mutual labels:  landmarks
KJCategories
Collection of native ios extensions and classes to boost development process. Such as UIKit, Foundation, QuartzCore, Accelerate, OpenCV, CoreGraphics, os and more. 超实用开发加速工具收集
Stars: ✭ 423 (+2921.43%)
Mutual labels:  projection
StyleGAN-nada
stylegan-nada.github.io/
Stars: ✭ 1,018 (+7171.43%)
Mutual labels:  stylegan
pmod
Native cross platform library with language projection support for native code.
Stars: ✭ 22 (+57.14%)
Mutual labels:  projection
Tools Merge Image PointCloud
Project the PointCloud to the image & Generate the LiDAR PointCloud with color.
Stars: ✭ 39 (+178.57%)
Mutual labels:  projection
laravel-quasar
⏰📊✨Laravel Time Series - Provides an API to create and maintain data projections (statistics, aggregates, etc.) from your Eloquent models, and convert them to time series.
Stars: ✭ 78 (+457.14%)
Mutual labels:  projection
mgrs
🌐 An R Package to Convert 'MGRS' (Military Grid Reference System) References From/To Other Coordiante Systems
Stars: ✭ 20 (+42.86%)
Mutual labels:  projection
PTI
Official Implementation for "Pivotal Tuning for Latent-based editing of Real Images" (ACM TOG 2022) https://arxiv.org/abs/2106.05744
Stars: ✭ 523 (+3635.71%)
Mutual labels:  stylegan
BIRL
BIRL: Benchmark on Image Registration methods with Landmark validations
Stars: ✭ 66 (+371.43%)
Mutual labels:  landmarks
pypoman
Python module for polyhedral geometry
Stars: ✭ 26 (+85.71%)
Mutual labels:  projection
PHPCoord
PHPCoord is a PHP library to aid in handling coordinates. It can convert coordinates for a point from one system to another and also calculate distance between points
Stars: ✭ 78 (+457.14%)
Mutual labels:  projection
GraphQL.RepoDB
A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that enca…
Stars: ✭ 25 (+78.57%)
Mutual labels:  projection

You can also generate face animations now. Check this blog post to find out how.

Google Colab

StyleGAN2 Facial Landmark Projection

This is an experimental repository with the aim to project facial landmark into the StyleGAN2 latent space. The code is an adaptation from the original StyleGAN2-ADA repository [0]. For projection of facial landmarks, the l2 norm of the landmark heat maps between projection image and target landmark image is minimized, next to the original LPIPS loss [2]. For heat maps of the landmarks, [1] is used. Thus, there are two target images, one for the look and one for the landmarks. The objective becomes (noise regularization omitted):

,

with HL being the heat map loss defined as

,

where N is the number of pixels, and FAN is the landmark heat map extraction model which outputs a three-dimensional matrix, where the depth dimension encodes each single landmark. LPIPS as in [1, 2]. The factor is a vector containing the weights for each group of landmarks. Groups are for example: Eye brows, eyes, mouth, etc. Check [1] for more info. By tweaking this vector you can determine what facial features you want to project more strongly into the generated images. See below for an example.

This repository is work in progress. Happy about input and contributions.

How to use

For quick testing, you can run this repository in Google Colab. Check it out here. Otherwise, install dependencies

pip install click requests tqdm pyspng ninja imageio-ffmpeg==0.4.3 face_alignment

and run it like so:

python projector.py --lpips_weight=1 --landmark_weight=0.05 --device=cuda --num-steps=1000 --outdir=./ --target_look=./look_img.png --target_landmarks=./landmark_img.png --save_video=1  --network=https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada-pytorch/pretrained/ffhq.pkl

Examples

Almost no weighting of eyes in vector, strong focus on mouth area:

drawing


Here the facial landmarks are weighted mostly uniformly:

Images from FFHQ data set.

Todos:

  • Allow for different landmark weights via command line. This will probably improve the above example.
  • Check out why the style look of the facial expression image leaks into the projection. Apparently the heat maps contain some "style" signal (normalization factor in heat map calculation was the culprit, seems to work quite well now. This also improved quality of generated images immensely)
  • Add face cropping as preprocessing for non ffhq images
  • Face cropping does not match completly ffhq preprocessing, also uniform background are degrading results strongly. Improve face cropping.
  • Add discriminator loss / regularization. Heat maps are some times wrongly extracted resulting in a very wrongly propagated error
  • Attempt to remove landmark information from VGG embedding for lpips calculation.

References

[0]: Karras, Tero, et al. "Training generative adversarial networks with limited data." arXiv preprint arXiv:2006.06676 (2020). Code: https://github.com/NVlabs/stylegan2-ada-pytorch

[1]: Bulat, Adrian, and Georgios Tzimiropoulos. "How far are we from solving the 2d & 3d face alignment problem?(and a dataset of 230,000 3d facial landmarks)." Proceedings of the IEEE International Conference on Computer Vision. 2017. Code: https://github.com/1adrianb/face-alignment

[2]: Zhang, Richard, et al. "The unreasonable effectiveness of deep features as a perceptual metric." Proceedings of the IEEE conference on computer vision and pattern recognition. 2018.

License

This repository is mainly based on the orignal StyleGAN2-ADA code, thus the NVIDIA license applies.

Copyright © 2021, NVIDIA Corporation. All rights reserved.

This work is made available under the Nvidia Source Code License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].