MaGGIe
[CVPR24] MaGGIe: Mask Guided Gradual Human Instance Matting
Install / Use
/learn @hmchuong/MaGGIeREADME
<img src="figs/maggie.png" alt="maggie" width="28"/> MaGGIe: Mask Guided Gradual Human Instance Matting
[Project Page] [Hugging Face] [Paper] [Model Zoo] [Datasets]
Instance-awareness alpha human matting with binary mask guidance for images and video
Accepted at CVPR 2024
Chuong Huynh, Seoung Wug Oh, Abhinav Shrivastava, Joon-Young Lee
Work is a part of Summer Internship 2023 at Adobe Research
<img src="figs/teaser_hd.gif" alt="maggie" width="800"/>Release
- [2024/12/26] Update the demo with Samurai - SOTA Video Object Segmentation method!
- [2024/04/10] Demo with Gradio is ready!
- [2024/04/07] Code, dataset and paper are released!
- [2024/04/04] Webpage is up!
Contents
Install
We tested our model on Linux CUDA 12.0, for other OS, the framework should work fine!
- Clone this repository and navigate to
MaGGIefolder:
git clone https://github.com/hmchuong/MaGGIe.git
cd MaGGIe
- Make sure you install CUDA 12.0 and install dependencies via:
conda create -n maggie python=3.8 pip
conda activate maggie
conda install -y pytorch torchvision pytorch-cuda=12.1 -c pytorch -c nvidia
pip install -r requirements.txt
MaGGIe Weights
Please check our Model Zoo for all public MaGGIe checkpoints, and instructions for how to use weights.
Demo
Please check Demo for more information.
Evaluation
Please check the Model Zoo for all model weight information.
M-HIM2K and HIM2K
The script scripts/test_maggie_image.sh contains the full evaluation on the whole M-HIM2K. The results.csv in the log directory contains all the results needed. To get the number in the paper, you can run this command on 4 GPUs:
sh scripts/eval_image.sh configs/maggie_image.yaml 4 maggie
You can also run one subset (e.g, natural) with one model mask (e.g, r50_c4_3x) by:
NGPUS=4
CONFIG=configs/maggie_image.yaml
SUBSET=natural
MODEL=r50_c4_3x
torchrun --standalone --nproc_per_node=$NGPUS tools/main.py --config $CONFIG --eval-only \
name eval_full \
dataset.test.split $SUBSET \
dataset.test.downscale_mask False \
dataset.test.mask_dir_name masks_matched_${MODEL} \
test.save_results False \
test.postprocessing False \
test.log_iter 10
If you want to save the alpha mattes, please set test.save_results True and change the test.save_dir
V-HIM60
The script scripts/test_maggie_video.sh contains the full evaluation on the V-HIM60. This evaluation is only compatible with a single GPU. To get the number in the paper, you can run this command:
sh scripts/eval_video.sh configs/maggie_video.yaml maggie
If you want to evaluate on a subset (e.g, easy), you can run:
CONFIG=configs/maggie_video.yaml
SUBSET=easy
torchrun --standalone --nproc_per_node=1 tools/main.py --config $CONFIG --eval-only \
name eval_full \
dataset.test.split comp_$SUBSET \
test.save_results False \
test.log_iter 10
If you want to save the alpha mattes, please set test.save_results True and change the test.save_dir.
Training
-
Please firstly follow DATASET to prepare the training data.
-
Download pretrained weights of the encoder from GCA-Matting
-
Training the image instance matting.
It is recommended to use 4 A100-40GB GPUs or (any GPUs with VRAM>=24GB) for this step.
Please check the config and set wandb settings to your project.
NAME=<name of the experiment>
NGPUS=4
torchrun --standalone --nproc_per_node=$NGPUS tools/main.py \
--config configs/maggie_image.yaml \
--precision 16 name $NAME model.weights ''
If you want to resume training from the last checkpoint, you can turn on train.resume_last or set train.resume to the checkpoint folder you want to resume from. You can also set wandb.id to continue logging to the same experiment id.
- Training the video instance matting
It is recommend to use 8 A100-80GB GPUs for this step. Please check the config and set `wandb to your project.
NAME=<name of the experiment>
PRETRAINED=<best weight from previous step>
NGPUS=8
torchrun --standalone --nproc_per_node=$NGPUS tools/main.py \
--config configs/maggie_video.yaml \
--precision 16 name $NAME model.weights $PRETRAINED
If you want to resume training from the last checkpoint, you can turn on train.resume_last or set train.resume to the checkpoint folder you want to resume from. You can also set wandb.id to continue logging to the same experiment id.
Citation
If you find MaGGIE useful for your research and applications, please cite using this BibTeX:
@inproceedings{huynh2024maggie,
title={MaGGIe: Masked Guided Gradual Human Instance Matting},
author={Huynh, Chuong and Oh, Seoung Wug and and Shrivastava, Abhinav and Lee, Joon-Young},
booktitle={Proceedings of the {IEEE} Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2024}
}
Baselines
We also provide baselines' training and evaluation scripts at BASELINES
Terms of Use
The project is under the CC BY-NC 4.0 License for non-commercial purpose only.
Acknowledgement
We thank Markus Woodson for his early project discussion. Our code is based on the OTVM and MGM.
Contact
If you have any question, please drop an email to chuonghm@umd.edu or create an issue on this repository.
Related Skills
qqbot-channel
351.8kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.6k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
351.8kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
project-overview
FlightPHP Skeleton Project Instructions This document provides guidelines and best practices for structuring and developing a project using the FlightPHP framework. Instructions for AI Coding A
