In this repo, we use shared matting to replace knn matting method, caused by the error of knn matting. Furthermore, the knn matting is too slow.
numpy==1.14
tensorflow==1.12.0
opencv-python
scipy
imageio
scikit-learn
1.1. Download the images and mattes from alphamatting.com
.
1.2. Download the MSCOCO
dataset, then uncompress to any folder.
-
Modify the
config.py
to adapt to your customed environment and parameters. -
Run
python gen_alpha_from_closed_form.py
to generate the closed form mattes. -
Run
python gen_alpha_from_sharedmatting.py
to generate the shared matting mattes( Replace the knn matting). -
Run
python data_prepare.py --stage=gen_composite_images
to generate the composite images. -
RUN
python data_prepare.py --stage=gen_image_patches
to generate the image patches. -
RUN
python data_prepare.py --stage=train_val_test_split
to split the train, val, test datasets.
Then we use these patches to train this model. There are totally 270000 patches for all images.
- RUN
python train.py
to train this model, the log and ckpt will be stored in ./logs and ./ckpt
- RUN
python demo.py
to test one image matting.