Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

This is a test ready version of foamliu/Deep-Image-Matting. This project added a new prediction function by using the original pre-trained model.

License

Notifications You must be signed in to change notification settings

MRYingLEE/Deep-Image-Matting

 
 

Repository files navigation

What's the difference from the original implementation?

Actually I didn't touch the training part. I only create a new prediction function.

The original prediction functions have some problem to run:

demo.py depends on a lot of external data, which is actually not necessary.

test.py uses a discarded model, which is different from the final one.

The new prediction function only needs the model design and the pretrained model data. You don't need to train the model to test it.

The precedure to use the prediction function

After you install all dependencies, say Numpy, Tensorflow, Keras, OpenCV.

  1. Download pre-trained Deep Image Matting Model to "models" folder

  2. Run the prediction function

$ python test-new.py -i "test/image.png" -b "test/background.png"

I have put 2 images there. You may replace it at your will.

Is there a browser version?

I used to think to port the prediction function to web by using Tensorflow.js or Keras.js. But I found it was hard to do so for the model used some custom layers, which are not supported by Tensorflow.js or Keras.js. Also, the pretrained model file is bigger than 300M.

If anyone finds a way to do so, please let me know.

Is the prediction function practical?

At first, the model supports photos with a fixed size only. Secondly, as an amature photographer, I tested some photos and foud the results are not always good. I prefer to use commercial photo tools, such as Photoshop, to do manually.

BTW, Is AI practical on image matting?

I am afraid I don't think so, especially for professional photographers. Later, maybe 3D camera will be a revolutionary technology to solve this problem.

=================================== The following are original readme of foamliu/Deep-Image-Matting.

Deep Image Matting

This repository is to reproduce Deep Image Matting.

Dependencies

Dataset

Adobe Deep Image Matting Dataset

Follow the instruction to contact author for the dataset.

MSCOCO

Go to MSCOCO to download:

PASCAL VOC

Go to PASCAL VOC to download:

ImageNet Pretrained Models

Download VGG16 into models folder.

Usage

Data Pre-processing

Extract training images:

$ python pre-process.py

Train

$ python train.py

If you want to visualize during training, run in your terminal:

$ tensorboard --logdir path_to_current_dir/logs

Demo

Download pre-trained Deep Image Matting Model to "models" folder then run:

$ python demo.py
Image/Trimap Output/GT New BG/Compose
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image

About

This is a test ready version of foamliu/Deep-Image-Matting. This project added a new prediction function by using the original pre-trained model.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Shell 0.1%