Skip to content

Implementation of "Automatic Portrait Segmentation" and "Deep Automatic Portrait Matting" with Chainer.

License

Notifications You must be signed in to change notification settings

takiyu/portrait_matting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portrait Matting

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.

Notice of License

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.

Implemented Models

  • 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

Testing Environments

  • OS: Ubuntu 16.04 and Latest Arch Linux
  • Python: 3.5
  • Chainer: 3.4.0
  • OpenCV: 3.4.0
  • Dlib: 19.9.0

Training

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.

Preparation

# 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

Training

$ python scripts/train.py --mode {seg,seg+,seg_tri,mat}

Testing

$ python scripts/train.py --mode {seg,seg+,seg_tri,mat} --model_path <path> -i <image path>

Results

Matting

First column is input image. Second column is output alpha mask. Third column is background replacement result.

ToDo

  • Collect more data.
  • Seek more effective training method about matting layer.
  • Tune hyper parameters automatically.

About

Implementation of "Automatic Portrait Segmentation" and "Deep Automatic Portrait Matting" with Chainer.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages