Giter Site home page Giter Site logo

deepfaceediting-jittor's Introduction

DeepFaceEditing: Deep Face Generation and Editing with Disentangled Geometry and Appearance Control

One version of our system is implemented using the Jittor, and you need to install Jittor first.

HomePage: http://www.geometrylearning.com/DeepFaceEditing/

Teaser Image

Abstract

Recent facial image synthesis methods have been mainly based on conditional generative models. Sketch-based conditions can effectively describe the geometry of faces, including the contours of facial components, hair structures, as well as salient edges (e.g., wrinkles) on face surfaces but lack effective control of appearance, which is influenced by color, material, lighting condition, etc. To have more control of generated results, one possible approach is to apply existing disentangling works to disentangle face images into geometry and appearance representations. However, existing disentangling methods are not optimized for human face editing, and cannot achieve fine control of facial details such as wrinkles. To address this issue, we propose DeepFaceEditing, a structured disentanglement framework specifically designed for face images to support face generation and editing with disentangled control of geometry and appearance. We adopt a local-to-global approach to incorporate the face domain knowledge: local component images are decomposed into geometry and appearance representations, which are fused consistently using a global fusion module to improve generation quality. We exploit sketches to assist in extracting a better geometry representation, which also supports intuitive geometry editing via sketching. The resulting method can either extract the geometry and appearance representations from face images, or directly extract the geometry representation from face sketches. Such representations allow users to easily edit and synthesize face images, with decoupled control of their geometry and appearance. Both qualitative and quantitative evaluations show the superior detail and appearance control abilities of our method compared to state-of-the-art methods.

Prerequisites

  1. System

 - Ubuntu 16.04 or later

 - NVIDIA GPU + CUDA 10.0

  1. Software

 - Python 3.7

 - Jittor. More details in Jittor

  • Pillow

  • numpy

 - Packages

pip install -r requirements.txt

How to use

Please download the pre-trained model [Google Drive], then put those under 'checkpoints'.

Extract sketches from real images:

python test_model.py --geo ./images/geometry.png --output ./results/sketch_gen.png --gen_sketch

geometry imagegeometry sketch

Reconstruct faces of image A:

images provide geometry:

python test_model.py --geo ./images/geometry.png --appear ./images/geometry.png --output ./results/recon_result.png --geo_type image

Generate faces with geometry of image A and appearance of image B:

images provide geometry:

python test_model.py --geo ./images/geometry.png --appear ./images/appearance.png --output ./results/image_result.png --geo_type image

sketches provide geometry:

python test_model.py --geo ./results/sketch_gen.png --appear ./images/appearance.png --output ./results/sketch_result.png --geo_type sketch

Coarse sketches provide geometry (with manifold projection):

python test_model_Projection.py --geo ./images/CoarseSketch.jpg --appear ./images/29042.jpg --output ./results/sketch_to_face.png --gender 0

geometry image geometry sketch

Citation

If you found this code useful please cite our work as:

@article {chenDeepFaceEditing2021,
    author = {Chen, Shu-Yu and Liu, Feng-Lin and Lai, Yu-Kun and Rosin, Paul L. and Li, Chunpeng and Fu, Hongbo and Gao, Lin},
    title = {{DeepFaceEditing}: Deep Generation of Face Images from Sketches},
    journal = {ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2021)},
    year = {2021},
    volume = 40,
    pages = {90:1--90:15},
    number = 4
}

deepfaceediting-jittor's People

Contributors

onlineplay 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  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  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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

deepfaceediting-jittor's Issues

About result

I followed your instructions to run this code, there is no issues, but the result images what I obtained is blank. Any suggestion about it?

Here is the running process:

(deepface) lisicheng@lisicheng-Z590-S01:~/DeepFaceEditing-Jittor$ python test_model.py --geo ./images/geometry.png --output ./results/sketch_gen.png --gen_sketch
[i 1021 21:22:46.292933 44 compiler.py:941] Jittor(1.3.1.9) src: /home/lisicheng/anaconda3/envs/deepface/lib/python3.7/site-packages/jittor
[i 1021 21:22:46.294142 44 compiler.py:942] g++ at /usr/local/bin/g++(7.5.0)
[i 1021 21:22:46.294178 44 compiler.py:943] cache_path: /home/lisicheng/.cache/jittor/jt1.3.1/g++7.5.0/py3.7.11/Linux-5.11.0-3x6e/11thGenIntelRCxdc/default
[i 1021 21:22:46.296077 44 init.py:372] Found nvcc(10.0.130) at /usr/local/cuda-10.0/bin/nvcc.
[i 1021 21:22:46.361783 44 init.py:372] Found gdb(9.2) at /usr/bin/gdb.
[i 1021 21:22:46.365229 44 init.py:372] Found addr2line(2.34) at /usr/bin/addr2line.
[i 1021 21:22:46.442669 44 compiler.py:993] cuda key:cu10.0.130_sm_86
[i 1021 21:22:46.564720 44 init.py:187] Total mem: 31.22GB, using 10 procs for compiling.
[i 1021 21:22:46.629541 44 jit_compiler.cc:27] Load cc_path: /usr/local/bin/g++
[i 1021 21:22:46.730638 44 init.cc:61] Found cuda archs: [86,]
[w 1021 21:22:46.808636 44 compiler.py:1326] CUDA arch(86)>75 will be backward-compatible
[i 1021 21:22:46.812635 44 compile_extern.py:497] mpicc not found, distribution disabled.
[i 1021 21:22:46.854007 44 compile_extern.py:29] found /usr/local/cuda-10.0/include/cublas.h
[i 1021 21:22:46.856392 44 compile_extern.py:29] found /usr/local/cuda-10.0/lib64/libcublas.so
[i 1021 21:23:35.793154 44 compile_extern.py:29] found /usr/local/cuda-10.0/include/cudnn.h
[i 1021 21:23:35.798631 44 compile_extern.py:29] found /usr/local/cuda-10.0/lib64/libcudnn.so
[i 1021 21:32:56.286736 44 compile_extern.py:29] found /usr/local/cuda-10.0/include/curand.h
[i 1021 21:32:56.305076 44 compile_extern.py:29] found /usr/local/cuda-10.0/lib64/libcurand.so
[i 1021 21:32:59.990031 44 cuda_flags.cc:32] CUDA enabled.

Can you share your training details?

Congratulations. But I have a little request, can you share your training details? I reproduced it according to your paper, but it didn't work. Thanks.

Cannot generate realistic facial images when using hand-drawn sketches.

Hi, I recently tested this model by using some hand-drawn sketches (rather sketches by sketch generators). I found the generated images look much worse than using generated sketches.

For example when the input sketch is

sketch_paper_1

Your model will just output such an immature unrealistic facial image.

sketch_result_paper_1

To make sure this is not the problem with my drawing, I also tested the sketches shown on your paper (e.g., Fig. 15). The generated results are still much worse than the ones shown on the paper.

For example, this sketched head shown in Fig. 15

Screen Shot 2022-04-20 at 12 02 34 PM

generates the face below,

sketch_result_paper_3

this is completely different from the results in Fig. 15.

Could you please explain why such differences exist, and how to generate the correct images.

Thanks in advance.

Wrong filename

self.netG.load('./checkpoints/global_fuse_25.pkl')

load the weight of global fuse
Traceback (most recent call last):
  File "test_model.py", line 55, in <module>
    model.initialize()
  File "/content/DeepFaceEditing-Jittor/combine_model.py", line 43, in initialize
    self.netG.load('./checkpoints/global_fuse_25.pkl')
  File "/usr/local/lib/python3.7/dist-packages/jittor/__init__.py", line 997, in load
    self.load_parameters(load(path))
  File "/usr/local/lib/python3.7/dist-packages/jittor/__init__.py", line 698, in load
    model_dict = safeunpickle(path)
  File "/usr/local/lib/python3.7/dist-packages/jittor/__init__.py", line 73, in safeunpickle
    with open(path, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: './checkpoints/global_fuse_25.pkl'

checkpoints

CUDA error at ~/.local/lib/python3.8/site-packages/jittor/src/ops/array_op.cc:32 code=222( cudaErrorUnsupportedPtxVersion ) cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking)

Hi:

My env:

  • OS: Ubuntu 20.04
  • Cuda: 11.3
  • cudnn 8.2.0
  • gcc/g++: 10.2

Failed to run test code as:

  DeepFaceEditing-Jittor git:(main) python test_model.py --geo ./results/sketch_gen.png --appear ./images/appearance.png --output ./results/sketch_result.png --geo_type sketch
[i 0512 11:37:12.017235 64 compiler.py:851] Jittor(1.2.2.71) src: ~/.local/lib/python3.8/site-packages/jittor
[i 0512 11:37:12.017286 64 compiler.py:852] g++ at /usr/bin/g++
[i 0512 11:37:12.017319 64 compiler.py:853] cache_path: ~/.cache/jittor/default/g++
[i 0512 11:37:12.019891 64 __init__.py:257] Found /usr/local/cuda/bin/nvcc(11.3.58) at /usr/local/cuda/bin/nvcc.
[i 0512 11:37:12.070950 64 __init__.py:257] Found gdb(9.2) at /usr/bin/gdb.
[i 0512 11:37:12.074234 64 __init__.py:257] Found addr2line(2.34) at /usr/bin/addr2line.
[i 0512 11:37:12.108394 64 compiler.py:893] pybind_include: -I/usr/include/python3.8 -I~/.local/lib/python3.8/site-packages/pybind11/include
[i 0512 11:37:12.116724 64 compiler.py:895] extension_suffix: .cpython-38-x86_64-linux-gnu.so
[i 0512 11:37:12.207914 64 __init__.py:169] Total mem: 31.27GB, using 10 procs for compiling.
terminate called after throwing an instance of 'std::runtime_error'
  what():  [f 0512 11:37:12.404950 64 helper_cuda.h:126] CUDA error at ~/.local/lib/python3.8/site-packages/jittor/src/ops/array_op.cc:32  code=222( cudaErrorUnsupportedPtxVersion ) cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking)

Any suggestions?

Why GeometryEncoder instead GlobalGenerator

Hello, nice job! I have a question, why don't use the encoder(including downsample and resnet-blocks) part of GlobalGenerator with ngf=32 as Geometry Encoder directly, but train a GeometryEncoder with ngf=64. Thanks.

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.