Giter VIP home page Giter VIP logo

one_shot_face_reenactment's Introduction

One-shot Face Reenactment

[Project] [Paper] [Demo]

Official test script for 2019 BMVC spotlight paper 'One-shot Face Reenactment' in PyTorch.

Installation

Requirements

  • Linux
  • Python 3.6
  • PyTorch 0.4+
  • CUDA 9.0+
  • GCC 4.9+

Easy Install

pip install -r requirements.txt

Getting Started

Prepare Data

It is recommended to symlink the dataset root to $PROJECT/data.

Project
├── data
│   ├── poseGuide
│   │   ├── imgs
│   │   ├── lms
│   ├── reference
│   │   ├── imgs
│   │   ├── lms
  • imgs : store images
  • lms : store landmarks extracted from images
    • format : 106 common facial key points & 20+20 gaze key points

Example input data is organized in folder 'data'. Please organize your data in the format the same as the example input data if you want to test with your own data.

Output images are saved in folder 'output'.

Due to the protocol of company, the model to extract 106 + 40 facial landmarks cannot be released, however, if you want to get access to the following dataset, please fill in the license file in the repo (license/celebHQlms_license.pdf), then email the signed copy to [email protected] to get access to the annotation dataset.

  • our preprocessed 106 + 40 facial landmark annotations of celebHQ dataset
  • additional 80 images as pose guide with corresponding 106 + 40 facial landmark annotations

Inference with pretrained model

python test.py --pose_path PATH/TO/POSE/GUIDE/IMG/DIR --ref_path PATH/TO/REF/IMG/DIR --pose_lms PATH/TO/POSE/LANDMARK/FILE --ref_lms PATH/TO/REF/LANDMARK/FILE
output sequence: 
		ref1-pose1, ref1-pose2,  ref1-pose3, ... &
		ref2-pose1, ref2-pose2,  ref2-pose3, ... &
		ref3-pose1, ref3-pose2,  ref3-pose3, ... &
		    .				
		    .				
		    .					

Pretrained model

You can download models from here

Project
├── pretrainModel
│   ├── id_200.pth
│   ├── vgg16-397923af.pth
├── trained_model
│   ├── latest_net_appEnc.pth
│   ├── latest_net_appDnc.pth
│   ├── latest_net_netG.pth
│   ├── latest_net_netD64.pth
│   ├── latest_net_netD128.pth
│   ├── latest_net_netD256.pth

Visualization of results

You can download our sample data and corresponding results from here

License and Citation

The use of this software follows MIT License.

@inproceedings{OneShotFace2019,
  title={One-shot Face Reenactment},
  author={Zhang, Yunxuan and Zhang, Siwei and He, Yue and Li, Cheng and Loy, Chen Change and Liu, Ziwei},
  booktitle={British Machine Vision Conference (BMVC)},
  year={2019}
}

one_shot_face_reenactment's People

Contributors

bj80heyue avatar liuziwei7 avatar sanweiliti 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  avatar  avatar  avatar  avatar  avatar  avatar

one_shot_face_reenactment's Issues

No train script

@sanweiliti
Thank Your Nice Work! But it seems the script for training is not yet be shared, Have any plan to share it later?
Besides, I notice your coding style is similar to Classic Pix2Pix and Pix2PixHD, so can I assume your training script just use Pix2Pix style training script replace with slight changes?

test in the wild

for testing on own images what is being used for cropping and extracting landmarks?

problem in Loss function

@sanweiliti
Hi, here some problems at loss design.
the original paper says 'Lreconstruct is the L1 loss between the reenactment result and
the input appearance after face contour resampling'.
And L_id, L_preceptual ware also computed
between result and appearance, but in the code, they ware computed between result and ground-truth(the pose guide)

so is there a mistake?
thanks

How to train?

Hi, there. Thanks for sharing this repository.
I'd like to train this model with my custom datasets. But I don't know how to do it.
Could you please help me with that?

Thanks.

MessageStream error in window

I run in Anaconda environment in window, and I got this Traceback.
How can i fix it??

Traceback (most recent call last):
  File "test.py", line 63, in <module>
    for step, data in tqdm(enumerate(data_loader)):
  File "C:\Anaconda3\envs\one\lib\site-packages\tqdm\_tqdm.py", line 1017, in __iter__
    for obj in iterable:
  File "C:\Anaconda3\envs\one\lib\site-packages\torch\utils\data\dataloader.py", line 336, in __next__
    return self._process_next_batch(batch)
  File "C:\Anaconda3\envs\one\lib\site-packages\torch\utils\data\dataloader.py", line 357, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
OSError: Traceback (most recent call last):
  File "C:\Anaconda3\envs\one\lib\site-packages\torch\utils\data\dataloader.py", line 106, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "C:\Anaconda3\envs\one\lib\site-packages\torch\utils\data\dataloader.py", line 106, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "C:\Users\전호범\Desktop\notebook\One_Shot_Face_Reenactment\loader\dataset_loader_demo.py", line 88, in __getitem__
    img_src = self.warp(img_src, pt_src, np.vstack([pt_dst[:33], pt_src[33:]]))
  File "C:\Users\전호범\Desktop\notebook\One_Shot_Face_Reenactment\loader\dataset_basic.py", line 52, in warp
    return warper.warping(img, srcPt.reshape(-1, 2), dstPt.reshape(-1, 2), (self.imgSize, self.imgSize))
  File "C:\Users\전호범\Desktop\notebook\One_Shot_Face_Reenactment\utils\warper.py", line 17, in warping
    res = warp_image(img, src_bound, dst_bound, size)
  File "C:\Users\전호범\Desktop\notebook\One_Shot_Face_Reenactment\utils\warper.py", line 106, in warp_image
    delaunay = spatial.Delaunay(dest_points)
  File "qhull.pyx", line 1813, in scipy.spatial.qhull.Delaunay.__init__
  File "qhull.pyx", line 266, in scipy.spatial.qhull._Qhull.__init__
  File "messagestream.pyx", line 36, in scipy._lib.messagestream.MessageStream.__init__
OSError: Failed to open file b'C:\\Users\\\xec\xa0\x84\xed\x98\xb8\xeb\xb2\x94\\AppData\\Local\\Temp\\scipy-sme_thdh'

why the gammaTrans?

Hi, nice work!
I found in you codes that you adjust the img_src's gamma before feeding to the network:

img_src = self.gammaTrans(img_src, 0.5)

may I ask why?

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.