Coder Social home page Coder Social logo

cvi-szu / stylegene Goto Github PK

View Code? Open in Web Editor NEW
33.0 4.0 3.0 1015 KB

[CVPR 2023 Highlight] StyleGene: Crossover and Mutation of Region-level Facial Genes for Kinship Face Synthesis

Home Page: https://wmpscc.github.io/stylegene/

Python 84.52% C++ 2.05% Cuda 13.43%
face-generation kinship

stylegene's Introduction

StyleGene (CVPR2023 Highlight)

This repository contains the implementation of the following paper:

StyleGene: Crossover and Mutation of Region-level Facial Genes for Kinship Face Synthesis
Hao Li, Xianxu Hou, Zepeng Huang, Linlin Shen
From CVI@SZU, Shenzhen University
IEEE/CVF International Conference on Computer Vision (CVPR), 2023
[Paper] | [Project Page] | [Video] | [Slide] | [Huggingface]


teaser The first row is the input grandparents, and the second and third rows are their descendants generated by our method.

Abstract

High-fidelity kinship face synthesis has many potential applications, such as kinship verification, missing child identification, and social media analysis. However, it is challenging to synthesize high-quality descendant faces with genetic relations due to the lack of large-scale, high-quality annotated kinship data. This paper proposes RFG (Region-level Facial Gene) extraction framework to address this issue. We propose to use IGE (Image-based Gene Encoder), LGE (Latent-based Gene Encoder) and Gene Decoder to learn the RFGs of a given face image, and the relationships between RFGs and the latent space of StyleGAN2. As cycle-like losses are designed to measure the $L_2$ distances between the output of Gene Decoder and image encoder, and that between the output of LGE and IGE, only face images are required to train our framework, i.e. no paired kinship face data is required. Based upon the proposed RFGs, a crossover and mutation module is further designed to inherit the facial parts of parents. A Gene Pool has also been used to introduce the variations into the mutation of RFGs. The diversity of the faces of descendants can thus be significantly increased. Qualitative, quantitative, and subjective experiments on FIW, TSKinFace, and FF-Databases clearly show that the quality and diversity of kinship faces generated by our approach are much better than the existing state-of-the-art methods.

Getting Started

Clone repo

git clone https://github.com/CVI-SZU/StyleGene.git
cd StyleGene

Environment Setup

It is suggested to create a Conda environment and install the following requirements

pip3 install -r requirements.txt

Requirements:

  • Python 3.9
  • torch 1.12.1
  • Pillow 9.2.0
  • einops 0.3.2
  • easydict 1.10
  • gradio 3.32.0
  • opencv-python 4.5.4.60
  • pandas 1.4.4
  • numpy 1.21.5
  • ninja

Download Checkpoints

We have uploaded all the necessary weights, please clone to the checkpoints/ directory.

mkdir checkpoints
cd checkpoints
git clone https://huggingface.co/wmpscc/StyleGene

Put the pre-trained models under checkpoints/ as follows:

StyleGene
└── checkpoints
    ├── e4e_ffhq_encode.pt
    ├── geneFactorPool.pkl
    ├── res34_fair_align_multi_7_20190809.pt
    ├── shape_predictor_68_face_landmarks.dat.bz2
    ├── stylegan2-ffhq-config-f.pt
    └── stylegene_N18.ckpt

Generation

Start the interactive interface and start playing.

cd StyleGene
python app.py

The default URL is http://127.0.0.1:7860/. If you are running on the server, please pay attention to open port 7860.

demo

Citation

If you are using our code, please consider citing our paper.

@inproceedings{li2023stylegene,
  title={StyleGene: Crossover and Mutation of Region-Level Facial Genes for Kinship Face Synthesis},
  author={Li, Hao and Hou, Xianxu and Huang, Zepeng and Shen, Linlin},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={20960--20969},
  year={2023}
}

Disclaimer

This method is intended for academic research purposes only and is strictly prohibited for commercial use. Users are required to comply with all local laws and regulations when using this method.

Acknowledgement

Part of the code comes from other repo, please abide by the original open source license for the relevant code.

stylegene's People

Contributors

wmpscc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

stylegene's Issues

Difference between your FF-database and the original one

Hi, thanks for your excellent work!

It seems that your images of FF-database is somewhat different with the original dataset accessed from CityU.
For example, I found that the original ones are cropped only on facial features (i.e., without ears, hair, and background), but yours have those components that the original ones do not have.

Therefore, I wonder that if you crawled the images via ChildPredictor and cropped with different size or you have other preprocessing pipelines.

What version of CUDA to use?

I use cuda11.3,but it has a few errors.Can Anyone help me?

[0/2] /usr/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUD...ylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
[1/2] /usr/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUD...ylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
FAILED: fused_bias_act_kernel.cuda.o
/usr/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1011" -isystem /home/aiyun/anaconda3/envs/gene/lib/python3.9/site-packages/torch/include -isystem /home/aiyun/anaconda3/envs/gene/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -isystem /home/aiyun/anaconda3/envs/gene/lib/python3.9/site-packages/torch/include/TH -isystem /home/aiyun/anaconda3/envs/gene/lib/python3.9/site-packages/torch/include/THC -isystem /home/aiyun/anaconda3/envs/gene/include/python3.9 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS_ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /ssd/aiyun/skinship/StyleGene-main/models/stylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
435 | function(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:435:145: note: ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
530 | operator=(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:530:146: note: ‘_ArgTypes’
ninja: build stopped: subcommand failed.

Training code release?

Thanks for your excellent work!
Could you release the training code? If so, it would be really helpful for my future research.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.