Deep Automatic Portrait Matting and Automatic Portrait Segmentation for Image Stylization implementation which predicts alpha or binary masks of portrait images automatically.
This is NOT official implementation.
This software is released under the GPL License except data_original
directory.
Data under data_original
directory is copied from the paper author's.
Rights of the data belong to them.
We created our original alpha masks and the following results are generated by them.
- FCN8s for binary segmentation with RGB image
- FCN8s for binary segmentation with RGB image, mean mask and grid images
- FCN8s for trimap segmentation with RGB image, mean mask and grid images
- FCN8s and matting layer with RGB image, mean mask and grid images
- OS: Ubuntu 16.04 and Latest Arch Linux
- Python: 3.5
- Chainer: 3.4.0
- OpenCV: 3.4.0
- Dlib: 19.9.0
Training data which is contained this repository is binary mask for segmentation created by paper's author.
For training of trimap and matting, extra alpha masks are needed.
# Download images from the internet.
$ python scripts/prepare_seg_dataset.py
# Generate mean masks and grids.
$ python scripts/prepare_seg_plus_dataset.py
# Generate trimaps from alpha masks. (extra alpha mask are needed)
$ python scripts/prepare_seg_tri_dataset.py
# Computes loss weight matrixs. (extra alpha mask are needed)
$ python scripts/prepare_matting_dataset.py
$ python scripts/train.py --mode {seg,seg+,seg_tri,mat}
$ python scripts/train.py --mode {seg,seg+,seg_tri,mat} --model_path <path> -i <image path>
First column is input image. Second column is output alpha mask. Third column is background replacement result.
- Collect more data.
- Seek more effective training method about matting layer.
- Tune hyper parameters automatically.