All Projects → google → Portrait Shadow Manipulation

google / Portrait Shadow Manipulation

Licence: apache-2.0

Projects that are alternatives of or similar to Portrait Shadow Manipulation

Epidemiology101
Epidemic Modeling for Everyone
Stars: ✭ 215 (-0.92%)
Mutual labels:  jupyter-notebook
Rl Adventure 2
PyTorch0.4 implementation of: actor critic / proximal policy optimization / acer / ddpg / twin dueling ddpg / soft actor critic / generative adversarial imitation learning / hindsight experience replay
Stars: ✭ 2,633 (+1113.36%)
Mutual labels:  jupyter-notebook
Stock market prediction
This is the code for "Stock Market Prediction" by Siraj Raval on Youtube
Stars: ✭ 217 (+0%)
Mutual labels:  jupyter-notebook
Chinese sentiment
中文情感分析,CNN,BI-LSTM,文本分类
Stars: ✭ 216 (-0.46%)
Mutual labels:  jupyter-notebook
Tensorface
This repo is deprecated, please use Deep Video Analytics which implements face recognition using TensorFlow and Facenet.
Stars: ✭ 215 (-0.92%)
Mutual labels:  jupyter-notebook
Tutorials
AI-related tutorials. Access any of them for free → https://towardsai.net/editorial
Stars: ✭ 204 (-5.99%)
Mutual labels:  jupyter-notebook
Stereo Transformer
Official Repo for Stereo Transformer: Revisiting Stereo Depth Estimation From a Sequence-to-Sequence Perspective with Transformers.
Stars: ✭ 211 (-2.76%)
Mutual labels:  jupyter-notebook
Paddlehelix
Bio-Computing Platform featuring Large-Scale Representation Learning and Multi-Task Deep Learning “螺旋桨”生物计算工具集
Stars: ✭ 213 (-1.84%)
Mutual labels:  jupyter-notebook
Notebooker
Productionise your Jupyter Notebooks as easily as you wrote them.
Stars: ✭ 215 (-0.92%)
Mutual labels:  jupyter-notebook
Tensorflow
Deep Learning Zero to All - Tensorflow
Stars: ✭ 216 (-0.46%)
Mutual labels:  jupyter-notebook
Understanding tensorflow nn
🔮Getting started with TensorFlow: Classifying Text with Neural Networks
Stars: ✭ 215 (-0.92%)
Mutual labels:  jupyter-notebook
Hyperspectral
Deep Learning for Land-cover Classification in Hyperspectral Images.
Stars: ✭ 215 (-0.92%)
Mutual labels:  jupyter-notebook
Deeplearning
Stars: ✭ 216 (-0.46%)
Mutual labels:  jupyter-notebook
Pytorch Superpoint
Superpoint Implemented in PyTorch: https://arxiv.org/abs/1712.07629
Stars: ✭ 214 (-1.38%)
Mutual labels:  jupyter-notebook
Malware Detection
Malware Detection and Classification Using Machine Learning
Stars: ✭ 217 (+0%)
Mutual labels:  jupyter-notebook
Pytorch Byol
PyTorch implementation of Bootstrap Your Own Latent: A New Approach to Self-Supervised Learning
Stars: ✭ 213 (-1.84%)
Mutual labels:  jupyter-notebook
Text Classification
Text Classification through CNN, RNN & HAN using Keras
Stars: ✭ 216 (-0.46%)
Mutual labels:  jupyter-notebook
How To Read Pytorch
Quick, visual, principled introduction to pytorch code through five colab notebooks.
Stars: ✭ 218 (+0.46%)
Mutual labels:  jupyter-notebook
Python Sonic
Programming Music with Python, Sonic Pi and Supercollider
Stars: ✭ 217 (+0%)
Mutual labels:  jupyter-notebook
Amazon Sagemaker Mlops Workshop
Machine Learning Ops Workshop with SageMaker: lab guides and materials.
Stars: ✭ 215 (-0.92%)
Mutual labels:  jupyter-notebook

Portrait Shadow Manipulation (SIGGRAPH 2020)

UC Berkeley, Google & Google Research

Project Website


Tensorflow 1.15.2 has been tested for the following implementation.

This repo contains the following contents:

$PWD
│   README.md
│   utils.py: foreign shadow synthesis steps
│	  including color jitter, subsurface scattering approximation,
│	  spatially-varying blur and per-pixel variations, and common util functions.
│   datasets.py: build the computational graph for training data generation.
│   mkdataset.py: offline data generatin script, saving generated images to disk.
│   mkfilelist.py: generate training / evaluation / test txt file for training.
│	test.txt: an example txt for training.
│
└───input: portrait image that is free of foreign shadow (ok to contain facial shadow)
│   │   000.png
│   │   001.png
│   │	  ...
│
└───input_mask_ind: segmentation and bounding box for each individual face
│   │   000_0.png
│   │   000.txt
│   │   001_0.png
│   │   001_1.png
│   │   001.txt
│   │   ...
│
└───silhouette
│   │   ...

Prepare your (foreign shadows) training dataset

If you want to get a quick idea how the images are generated, you can jump to step 4 and refer to the jupyter notebook.

Step 0 (pre-req):

For each image, you need to have a portarit segmentation and face bounding box for each face in the image. We used the model from this paper, but there are other publicly avaialble portrait segmentation and face detectors that you can use.

We provide some exmples in this repo, see step 1.

Step 1:

Here's the structure of our datasets:

input/: folder that contains input images (no foreign shadows but may contain facial shadows)

input_mask_ind/: folder that contains individual face segmentation (.png) and bounding box (i.e. bbox) stored in .txt (each line corresponds to one face bbox). For example, for an input image 0.png in input/, 0_0.png denotes the first face in 0.png and 0_1.png denotes the second face in 0.png. 0.txt will contain two lines corresponding to the two bbox of the faces in 0.png.

silhouette/: We randomly choose to generate shadow using either perlin noise or silhouette, and this folder is to store all the random silhouette images.

Step 2:

Generate train / eval txt file, run mkfilelist.py. For example:

python3 mkfilelist.py \
	--image_base_paths ${your_parent_path}/input \
	--silhouette_paths ${your_parent_path}/silhouette \
	--file_types png \
	--output_dir ${your_parent_path}/test.txt

example.txt is an example .txt file that this script generates. During training or offline data generation, it reads in this .txt file.

Step 3:

Decide how you want to use the training data. There are two ways (both are provided) to use the training dataset:

  1. Offline: you can use the script (mkdataset.py) to generate and save out generated image pairs to disk.
  2. On-the-fly: you can use the datasets.py to build the data generation graph as part of the training computation graph, and generate data on the fly while training.

All the key synthesis functions described in paper Section 3 are implemented in utils.py* with detailed function documentation. To generate image pairs offline, run mkdataset.py. For example:

python3 mkdataset.py \
	--mode train \
	--trainwildpaths ${your_parent_path}/train.txt \
	--silhouette_paths ${your_parent_path}/eval.txt \
	--out_dir ${your_parent_path}/shadow_data \

Example ouput can be found under ./example_out/. You should expect generated image pairs to be similar to this.

*All synthesis functions in utils.py are implemented in tensorflow and it was meant for on-the-fly training data generation. If you use the script only for offline data generation and you don't have hardware for parallelization, some of the operation may not be computational efficient.

Step 4 (optional):

For a quick demo of each synthesis step, we also provide a jupyter notebook (foreign_syn.ipynb) that goes through the entire synthesis process. A few control parameters can be visualized interactively. For example, the strength of subsurface scattering approximation and spatially varying blur size:

ss_map sv_map


Test

To download all test and evaluation dataset, please see project website.

Some of the test images come from:

Helen dataset: Face dataset with landmarks

HDR+ Burst Photography Dataset: Test images with faces

At this point, we cannot make the trained model public due to legal reasons.


Relevant links

These resources help me directly and indirectly understand this problem better:

Marc Levoy Lecture: Photographic lighting

cambridgeincolour: Introduction to portrai lighting with interactive demo

Lighting setup taxonomy: Pro portrait lighting setups with illustration

Canon tutorial: Natural Light Portraiture


Acknowledgement

We are grateful for people who agree to appear in all the photographs. Please use these photos only for academic purpose, and use with respect. Thank you.

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].