Skip to content

zhyj3038/AlphaGAN-Matting

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AlphaGAN

This project is an unofficial implementation of AlphaGAN: Generative adversarial networks for natural image matting published at the BMVC 2018. As for now, the result of my experiment is not as good as the paper's.

This is a course project of mine and there may exists some mistakes in this project.

Dataset

Adobe Deep Image Matting Dataset

Follow the instruction to contact the author for the dataset

You might need to follow the method mentioned in the Deep Image Matting to generate the trimap using the alpha mat.

The trimap are generated while the data are loaded.

import numpy as np
import cv2 as cv

def generate_trimap(alpha):
   k_size = random.choice(range(2, 5))
   iterations = np.random.randint(5, 15)
   kernel = cv.getStructuringElement(cv.MORPH_ELLIPSE, (k_size, k_size))
   dilated = cv.dilate(alpha, kernel, iterations=iterations)
   eroded = cv.erode(alpha, kernel, iterations=iterations)
   trimap = np.zeros(alpha.shape, dtype=np.uint8)
   trimap.fill(128)

   trimap[eroded >= 255] = 255
   trimap[dilated <= 0] = 0

   return trimap

The Dataset structure in my project

Train
  ├── alpha  # the alpha ground-truth
  ├── fg     # the foreground image
  ├── input  # the real image composed by the fg & bg
MSCOCO
  ├── train2014 # the background image

Differences from the original paper

  • SyncBatchNorm instead of pytorch original BatchNorm when use multi GPU.

Records

  • Achieved SAD=78.22 after 21 epoches. The method seems to be right and there is still lots of work to do.

Acknowledgments

My code is inspired by:

About

This project is an unofficial implementation of AlphaGAN: Generative adversarial networks for natural image matting published at the BMVC 2018

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 89.1%
  • Jupyter Notebook 10.9%