Git Product home page Git Product logo

yahskapar / shadow-mask-face-relighting Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewhou1/shadow-mask-face-relighting

0.0 0.0 0.0 98.72 MB

Official Code for Towards High Fidelity Face Relighting with Realistic Shadows (CVPR 2021)

Home Page: https://openaccess.thecvf.com/content/CVPR2021/html/Hou_Towards_High_Fidelity_Face_Relighting_With_Realistic_Shadows_CVPR_2021_paper.html

License: MIT License

C++ 68.97% Python 21.71% C 2.52% MATLAB 6.80%

shadow-mask-face-relighting's Introduction

Towards High Fidelity Face Relighting with Realistic Shadows

Andrew Hou, Ze Zhang, Michel Sarkis, Ning Bi, Yiying Tong, Xiaoming Liu. In CVPR, 2021.

alt text alt text

The code for this project was developed using Python 3.6.8 and Tensorflow 1.9.0.

Trained model

To run our trained model on an input image and a target lighting:

python test_relight_single_image.py input_image_path target_lighting_path output_image_path gpu_id

An example of this is provided below:

python test_relight_single_image.py sample_images/01503.png sample_lightings/light_left.txt sample_outputs/01503_left.png 7

Training Code

To retrain the model, first download the data from the following drive link (note that the data within the zip file is about 100GB in total): https://drive.google.com/file/d/1S7iTc_seTkb_6-FX5xYSDkklwzoJYb9N/view?usp=sharing

After downloading the data, the only additional data we need are the training images. Please download the DPR dataset from https://drive.google.com/drive/folders/10luekF8vV5vo2GFYPRCe9Rm2Xy2DwHkT and the Extended Yale Face Database B from http://vision.ucsd.edu/~leekc/ExtYaleDatabase/ExtYaleB.html (select "original images").

For the DPR dataset:

cd CVPR2021_data/
mkdir uncropped_DPR_images/
mkdir cropped_DPR_images/

Next, copy all DPR images in all folders that have a corresponding .mat file in the provided folder DPR_landmarks/ to the uncropped_DPR_images/ folder (e.g. copy the 5 images imgHQ00000_00.png, imgHQ00000_01.png, imgHQ00000_02.png, imgHQ00000_03.png, and imgHQ00000_04.png found in folder imgHQ00000/ to uncropped_DPR_images/ if imgHQ00000.mat exists in DPR_landmarks/). You should have 123,800 images in total in uncropped_DPR_images/ if this is done correctly. Next, run crop_DPR.m to generate the cropped DPR images in the cropped_DPR_images/ folder.

For the Yale dataset:

First, place the ExtendedYaleB/ folder that you downloaded inside the CVPR2021_data/ folder. Next:

cd CVPR2021_data/
mkdir Yale_cropped_images/

Run crop_Yale.m to generate the cropped Yale images in the Yale_cropped_images/ folder.

To finish the data preparation procedure, we just need to rename some folders to align with the training code and create some new folders that store losses, saved epochs, etc.

mv cropped_DPR_images/ DPR_training_images_cropped_full/
cd ..
mv CVPR2021_data/ MP_data/
mkdir DPR_and_Yale_loss_curves_nonlinear_relighting_SH_model_gradual_skip_SSIM_ratio_image_log_loss_using_SSIM_loss_Yuv_shadow_map_loss_contrast_based_border_weights_with_corrected_patchgan_much_smaller_weights_larger_L1_losses_MR_dis_DPR_losses/
mkdir DPR_and_Yale_loss_curves_nonlinear_relighting_SH_model_gradual_skip_SSIM_ratio_image_log_loss_using_SSIM_loss_Yuv_shadow_map_loss_contrast_based_border_weights_with_corrected_patchgan_much_smaller_weights_larger_L1_losses_MR_dis_Yale_losses/
mkdir DPR_and_Yale_training_checkpoint_nonlinear_relighting_SH_gradual_skip_SSIM_ratio_image_log_loss_using_SSIM_loss_Yuv_shadow_map_loss_contrast_based_border_weights_with_corrected_patchgan_much_smaller_weights_larger_L1_losses_MR_dis/

Finally, to begin training:

python train_DPR_and_Yale.py

Citation

If you utilize our code in your work, please cite our CVPR 2021 paper.

@inproceedings{ towards-high-fidelity-face-relighting-with-realistic-shadows,
  author = { Andrew Hou and Ze Zhang and Michel Sarkis and Ning Bi and Yiying Tong and Xiaoming Liu },
  title = { Towards High Fidelity Face Relighting with Realistic Shadows },
  booktitle={IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year = { 2021 }
}

Contact

If there are any questions, please feel free to post here or contact the first author at [email protected]

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.