Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FBA data #203

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions tools/data/matting/comp1k/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,30 @@ mmediting
│ │ │ │ ├── fg
│ │ │ ├── merged (generated by tools/data/matting/comp1k/preprocess_comp1k_dataset.py)
│ │ │ ├── bg (generated by tools/data/matting/comp1k/preprocess_comp1k_dataset.py)
│ │ ├── test_list.json (generated by tools/data/matting/comp1k/preprocess_comp1k_dataset.py)
│ │ ├── training_list.json (generated by tools/data/matting/comp1k/preprocess_comp1k_dataset.py)
│ ├── coco
│ │ ├── train2014 (or train2017)
│ ├── VOCdevkit
│ │ ├── VOC2012
```
## Prepare the dataset for FBA

For FBA, adopt dynamic dataset augmentation tricks proposed in [Learning-base Sampling for Natural Image Matting](https://openaccess.thecvf.com/content_CVPR_2019/papers/Tang_Learning-Based_Sampling_for_Natural_Image_Matting_CVPR_2019_paper.pdf) for train set.
FBA adopts dynamic dataset augmentation proposed in [Learning-base Sampling for Natural Image Matting](https://openaccess.thecvf.com/content_CVPR_2019/papers/Tang_Learning-Based_Sampling_for_Natural_Image_Matting_CVPR_2019_paper.pdf).
In addition, to reduce artifacts during augmentation, it uses the extened version of foreground as foreground.
We provide scripts to estimate foregrounds.

Prepare the test set as follows:

```shell
# skip preprocessing training set
# skip preprocessing training set, as it composites online during training
python tools/data/matting/comp1k/preprocess_comp1k_dataset.py data/adobe_composition-1k data/coco data/VOCdevkit --skip_train
```

Extend the foreground as follows:
Extend the foreground of training set as follows:

```shell
python tools/data/matting/comp1k/extend_fg.py data/adobe_composition-1k data/coco
python tools/data/matting/comp1k/extend_fg.py data/adobe_composition-1k
```

## Check Directory Structure for DIM
Expand Down Expand Up @@ -125,6 +129,8 @@ mmediting
│ │ │ │ ├── alpha
│ │ │ │ ├── fg
│ │ │ │ ├── fg_extended (generated by tools/data/matting/comp1k/extend_fg.py)
│ │ ├── test_list.json (generated by tools/data/matting/comp1k/preprocess_comp1k_dataset.py)
│ │ ├── training_list_fba.json (generated by tools/data/matting/comp1k/extend_fg.py)
│ ├── coco
│ │ ├── train2014 (or train2017)
│ ├── VOCdevkit
Expand Down
5 changes: 1 addition & 4 deletions tools/data/matting/comp1k/extend_fg.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def extend(self, fg_name):
fix_png_file(osp.basename(extended_path), osp.dirname(extended_path))
data_info = dict()
data_info['alpha_path'] = alpha_path
data_info['fg_extended_path'] = extended_path
data_info['fg_path'] = extended_path
return data_info


Expand All @@ -80,7 +80,6 @@ def parse_args():
description='Prepare Adobe composition 1k dataset',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('data_root', help='Adobe composition 1k dataset root')
parser.add_argument('coco_root', help='COCO2014 or COCO2017 dataset root')
parser.add_argument(
'--nproc', type=int, default=4, help='number of processer')
args = parser.parse_args()
Expand All @@ -91,8 +90,6 @@ def main():
args = parse_args()
if not osp.exists(args.data_root):
raise FileNotFoundError(f'{args.data_root} does not exist!')
if not osp.exists(args.coco_root):
raise FileNotFoundError(f'{args.coco_root} does not exist!')

data_root = args.data_root

Expand Down