Tim M 57b5cefde5 Updated all `.md` files to contain newest image vor 2 Jahren
..
examples a77fc155c7 Done FBA Matting vor 4 Jahren
networks a77fc155c7 Done FBA Matting vor 4 Jahren
LICENSE 5fa06616b3 Added LICENSE vor 4 Jahren
README.md 57b5cefde5 Updated all `.md` files to contain newest image vor 2 Jahren
dataloader.py a77fc155c7 Done FBA Matting vor 4 Jahren
demo.py a77fc155c7 Done FBA Matting vor 4 Jahren
generate_trimaps.py a77fc155c7 Done FBA Matting vor 4 Jahren
requirements.txt a77fc155c7 Done FBA Matting vor 4 Jahren

README.md

Image Matting with state-of-the-art Method F, B, Alpha Matting

This repository contains the code for Image Matting with state-of-the-art Method F, B, Alpha Matting blogpost.

download

Usage for test images

Please, follow the instruction to launch the demonstration script:

  • Download model weights from there;
  • Install the requirements with pip3 install -r requirements.txt;
  • Launch python3 demo.py to use default arguments. Use python3 demo.py -h for details.

The results will be saved into ./examples/predictions by default.

Usage for real life images

If you want to run the matting network on your own images you will need to generate the corresponding trimaps first. This process is supposed to be manual but that's too burdensome. Instead, please follow the instruction below to launch the trimap generation process using a semantic segmentation algorithm:

  • You need to generate trimap. In this repo we use PyTorch implementation of the DeepLabV3 for that purpose. Select the class of your foreground object using - target class key:
python generate_trimaps.py -i /path/to/your/images (should be a directory) --target_class cat (consult --help for other options)
  • Your trimaps will be stored into path/to/your/images/trimaps
  • Then launch python demo.py --image_dir path/to/your/images --trimap_dir path/to/your/images/trimaps --output_dir path/to/save to get predictions
  • Note that results may be imprecise due to rough trimap generation. You can try to play with the --conf_threshold to fix that.

AI Courses by OpenCV

Want to become an expert in AI? AI Courses by OpenCV is a great place to start.