All Projects → lizhengwei1992 → Semantic_human_matting

lizhengwei1992 / Semantic_human_matting

Semantic Human Matting

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Semantic human matting

Fastmaskrcnn
Mask RCNN in TensorFlow
Stars: ✭ 3,069 (+690.98%)
Mutual labels:  segmentation
Pointnet
PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation
Stars: ✭ 3,517 (+806.44%)
Mutual labels:  segmentation
Rectlabel Support
RectLabel - An image annotation tool to label images for bounding box object detection and segmentation.
Stars: ✭ 338 (-12.89%)
Mutual labels:  segmentation
Retentioneering Tools
Retentioneering: product analytics, data-driven customer journey map optimization, marketing analytics, web analytics, transaction analytics, graph visualization, and behavioral segmentation with customer segments in Python. Opensource analytics, predictive analytics over clickstream, sentiment analysis, AB tests, machine learning, and Monte Carlo Markov Chain simulations, extending Pandas, Networkx and sklearn.
Stars: ✭ 291 (-25%)
Mutual labels:  segmentation
Segmentation models.pytorch
Segmentation models with pretrained backbones. PyTorch.
Stars: ✭ 4,584 (+1081.44%)
Mutual labels:  segmentation
Tianchi Medical Lungtumordetect
天池医疗AI大赛[第一季]:肺部结节智能诊断 UNet/VGG/Inception/ResNet/DenseNet
Stars: ✭ 314 (-19.07%)
Mutual labels:  segmentation
Dhsegment
Generic framework for historical document processing
Stars: ✭ 282 (-27.32%)
Mutual labels:  segmentation
Animal Matting
Github repository for the paper End-to-end Animal Image Matting
Stars: ✭ 363 (-6.44%)
Mutual labels:  segmentation
Erfnet pytorch
Pytorch code for semantic segmentation using ERFNet
Stars: ✭ 304 (-21.65%)
Mutual labels:  segmentation
Unet
unet for image segmentation
Stars: ✭ 3,751 (+866.75%)
Mutual labels:  segmentation
Cascaded Fcn
Source code for the MICCAI 2016 Paper "Automatic Liver and Lesion Segmentation in CT Using Cascaded Fully Convolutional NeuralNetworks and 3D Conditional Random Fields"
Stars: ✭ 296 (-23.71%)
Mutual labels:  segmentation
Segmentation keras
DilatedNet in Keras for image segmentation
Stars: ✭ 300 (-22.68%)
Mutual labels:  segmentation
Bcdu Net
BCDU-Net : Medical Image Segmentation
Stars: ✭ 314 (-19.07%)
Mutual labels:  segmentation
Cvpods
All-in-one Toolbox for Computer Vision Research.
Stars: ✭ 277 (-28.61%)
Mutual labels:  segmentation
Inaspeechsegmenter
CNN-based audio segmentation toolkit. Allows to detect speech, music and speaker gender. Has been designed for large scale gender equality studies based on speech time per gender.
Stars: ✭ 352 (-9.28%)
Mutual labels:  segmentation
Segmentation models
Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
Stars: ✭ 3,575 (+821.39%)
Mutual labels:  segmentation
Awesome Iccv
ICCV2019最新录用情况
Stars: ✭ 305 (-21.39%)
Mutual labels:  segmentation
Fbrs interactive segmentation
[CVPR2020] f-BRS: Rethinking Backpropagating Refinement for Interactive Segmentation https://arxiv.org/abs/2001.10331
Stars: ✭ 366 (-5.67%)
Mutual labels:  segmentation
Instaboost
Code for ICCV2019 paper "InstaBoost: Boosting Instance Segmentation Via Probability Map Guided Copy-Pasting"
Stars: ✭ 368 (-5.15%)
Mutual labels:  segmentation
Deepcut
A Thai word tokenization library using Deep Neural Network
Stars: ✭ 330 (-14.95%)
Mutual labels:  segmentation

Semantic_Human_Matting

The project is my reimplement of paper (Semantatic Human Matting) from Alibaba, it proposes a new end-to-end scheme to predict human alpha from image. SHM is the first algorithm that learns to jointly fit both semantic information and high quality details with deep networks.

One of the main contributions of the paper is that: A large scale high quality human matting dataset is created. It contains 35,513 unique human images with corresponding alpha mattes. But, the dataset is not avaiable.

I collected 6k+ images as my dataset of the project. Worth noting that, the architecture of my network, which builded with mobilenet and shallow encoder-decoder net, is a light version compaired to original implement.

update 2019/04/08

👍 👍 The company 爱分割 shared their dataset recently !

Requirements

  • python3.5 / 3.6
  • pytorch >= 0.4
  • opencv-python

Usage

Directory structure of the project:

Semantic_Human_Matting
│   README.md
│   train.py
│   train.sh
|   test_camera.py
|   test_camera.sh
└───model
│   │   M_Net.py
│   │   T_Net.py
│   │   network.py
└───data
    │   dataset.py
    │   gen_trimap.py
    |   gen_trimap.sh
    |   knn_matting.py
    |   knn_matting.sh
    └───image
    └───mask
    └───trimap
    └───alpha

Step 1: prepare dataset

./data/train.txt contain image names according to 6k+ images(./data/image) and corresponding masks(./data/mask).

Use ./data/gen_trimap.sh to get trimaps of the masks.

Use ./data/knn_matting.sh to get alpha mattes(it will take long time...).

Step 2: build network

SHM

  • Trimap generation: T-Net

    The T-Net plays the role of semantic segmentation. I use mobilenet_v2+unet as T-Net to predict trimap.

  • Matting network: M-Net

    The M-Net aims to capture detail information and generate alpha matte. I build M-Net same as the paper, but reduce channels of the original net.

  • Fusion Module

    Probabilistic estimation of alpha matte can be written as

Step 3: build loss

The overall prediction loss for alpha_p at each pixel is

The total loss is

Read papers for more details, and my codes for two loss functions:

    # -------------------------------------
    # classification loss L_t
    # ------------------------
    criterion = nn.CrossEntropyLoss()
    L_t = criterion(trimap_pre, trimap_gt[:,0,:,:].long())

    # -------------------------------------
    # prediction loss L_p
    # ------------------------
    eps = 1e-6
    # l_alpha
    L_alpha = torch.sqrt(torch.pow(alpha_pre - alpha_gt, 2.) + eps).mean()

    # L_composition
    fg = torch.cat((alpha_gt, alpha_gt, alpha_gt), 1) * img
    fg_pre = torch.cat((alpha_pre, alpha_pre, alpha_pre), 1) * img
    L_composition = torch.sqrt(torch.pow(fg - fg_pre, 2.) + eps).mean()
    L_p = 0.5*L_alpha + 0.5*L_composition

Step 4: train

Firstly, pre_train T-Net, use ./train.sh as :

python3 train.py \
	--dataDir='./data' \
	--saveDir='./ckpt' \
	--trainData='human_matting_data' \
	--trainList='./data/train.txt' \
	--load='human_matting' \
	--nThreads=4 \
	--patch_size=320 \
	--train_batch=8 \
	--lr=1e-3 \
	--lrdecayType='keep' \
	--nEpochs=1000 \
	--save_epoch=1 \
	--train_phase='pre_train_t_net'

Then, train end to end, use ./train.sh as:

python3 train.py \
	--dataDir='./data' \
	--saveDir='./ckpt' \
	--trainData='human_matting_data' \
	--trainList='./data/train.txt' \
	--load='human_matting' \
	--nThreads=4 \
	--patch_size=320 \
	--train_batch=8 \
	--lr=1e-4 \
	--lrdecayType='keep' \
	--nEpochs=2000 \
	--save_epoch=1 \
	--finetuning \
	--train_phase='end_to_end'

Test

run ./test_camera.sh

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].