-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Feature] Support Delving into High-Quality Synthetic Face Occlusion Segmentation Datasets #2194
Changes from 7 commits
e9e196f
d5e79fa
23c9fd7
f4022fb
e1cc800
33156d0
1ca1780
69b49cd
e4a9dd7
1fc898c
f537397
c222684
280b175
2aaa757
dd59be3
62bcc1a
70b2853
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
dataset_type = 'FaceOccludedDataset' | ||
data_root = 'data/occlusion-aware-face-dataset' | ||
crop_size = (512, 512) | ||
img_norm_cfg = dict( | ||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) | ||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='LoadAnnotations'), | ||
dict(type='Resize', img_scale=(512, 512)), | ||
dict(type='RandomFlip', prob=0.5), | ||
dict(type='RandomRotate', degree=(-30, 30), prob=0.5), | ||
dict(type='PhotoMetricDistortion'), | ||
dict( | ||
type='Normalize', | ||
mean=[123.675, 116.28, 103.53], | ||
std=[58.395, 57.12, 57.375], | ||
to_rgb=True), | ||
dict(type='DefaultFormatBundle'), | ||
dict(type='Collect', keys=['img', 'gt_semantic_seg']) | ||
] | ||
test_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict( | ||
type='MultiScaleFlipAug', | ||
img_scale=(512, 512), | ||
img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], | ||
flip=True, | ||
transforms=[ | ||
dict(type='Resize', keep_ratio=True), | ||
dict(type='ResizeToMultiple', size_divisor=32), | ||
dict(type='RandomFlip'), | ||
dict( | ||
type='Normalize', | ||
mean=[123.675, 116.28, 103.53], | ||
std=[58.395, 57.12, 57.375], | ||
to_rgb=True), | ||
dict(type='ImageToTensor', keys=['img']), | ||
dict(type='Collect', keys=['img']) | ||
]) | ||
] | ||
|
||
dataset_train_A = dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='CelebAMask-HQ-original/image', | ||
ann_dir='CelebAMask-HQ-original/mask_edited', | ||
split='CelebAMask-HQ-original/split/train.txt', | ||
pipeline=train_pipeline) | ||
|
||
dataset_train_B = dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='NatOcc-SOT/image', | ||
ann_dir='NatOcc-SOT/mask', | ||
split='NatOcc-SOT/split/train.txt', | ||
pipeline=train_pipeline) | ||
|
||
|
||
dataset_valid = dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='RealOcc/image', | ||
ann_dir='RealOcc/mask', | ||
split='RealOcc/split/val.txt', | ||
pipeline=test_pipeline) | ||
|
||
dataset_test = dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='RealOcc/image', | ||
ann_dir='RealOcc/mask', | ||
split='RealOcc/test.txt', | ||
pipeline=test_pipeline) | ||
|
||
data = dict( | ||
samples_per_gpu=2, | ||
workers_per_gpu=2, | ||
train=[ | ||
dataset_train_A,dataset_train_B | ||
], | ||
val= dataset_valid, | ||
test=dataset_test) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# + | ||
_base_ = '../_base_/datasets/occlude_face.py' | ||
norm_cfg = dict(type='SyncBN', requires_grad=True) | ||
model = dict( | ||
type='EncoderDecoder', | ||
pretrained='open-mmlab:https://resnet101_v1c', | ||
backbone=dict( | ||
type='ResNetV1c', | ||
depth=101, | ||
num_stages=4, | ||
out_indices=(0, 1, 2, 3), | ||
dilations=(1, 1, 2, 4), | ||
strides=(1, 2, 1, 1), | ||
norm_cfg=dict(type='SyncBN', requires_grad=True), | ||
norm_eval=False, | ||
style='pytorch', | ||
contract_dilation=True), | ||
decode_head=dict( | ||
type='DepthwiseSeparableASPPHead', | ||
in_channels=2048, | ||
in_index=3, | ||
channels=512, | ||
dilations=(1, 12, 24, 36), | ||
c1_in_channels=256, | ||
c1_channels=48, | ||
dropout_ratio=0.1, | ||
num_classes=2, | ||
norm_cfg=dict(type='SyncBN', requires_grad=True), | ||
align_corners=False, | ||
loss_decode=dict( | ||
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), | ||
sampler=dict(type='OHEMPixelSampler', thresh=0.7, min_kept=10000)), | ||
auxiliary_head=dict( | ||
type='FCNHead', | ||
in_channels=1024, | ||
in_index=2, | ||
channels=256, | ||
num_convs=1, | ||
concat_input=False, | ||
dropout_ratio=0.1, | ||
num_classes=2, | ||
norm_cfg=dict(type='SyncBN', requires_grad=True), | ||
align_corners=False, | ||
loss_decode=dict( | ||
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), | ||
train_cfg=dict(), | ||
test_cfg=dict(mode='whole')) | ||
log_config = dict( | ||
interval=50, hooks=[dict(type='TextLoggerHook', by_epoch=False)]) | ||
dist_params = dict(backend='nccl') | ||
log_level = 'INFO' | ||
load_from = None | ||
resume_from = None | ||
workflow = [('train', 1)] | ||
cudnn_benchmark = True | ||
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) | ||
optimizer_config = dict() | ||
lr_config = dict(policy='poly', power=0.9, min_lr=0.0001, by_epoch=False) | ||
runner = dict(type='IterBasedRunner', max_iters=30000) | ||
checkpoint_config = dict(by_epoch=False, interval=400) | ||
evaluation = dict( | ||
interval=400, metric=['mIoU', 'mDice', 'mFscore'], pre_eval=True) | ||
|
||
work_dir = './work_dirs/deeplabv3plus_r101_512x512_C-CM+C-WO-NatOcc-SOT' | ||
gpu_ids = range(0, 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, we do not need to set these two configs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay i will delete this |
||
auto_resume = False |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<!-- #region --> | ||
## Prepare datasets | ||
|
||
It is recommended to symlink the dataset root to `$MMSEGMENTATION/data`. | ||
|
@@ -376,3 +377,58 @@ python tools/convert_datasets/isaid.py /path/to/iSAID | |
``` | ||
|
||
In our default setting (`patch_width`=896, `patch_height`=896, `overlap_area`=384), it will generate 33978 images for training and 11644 images for validation. | ||
|
||
|
||
### Delving into High-Quality Synthetic Face Occlusion Segmentation Datasets | ||
|
||
The dataset is generated by two techniques, Naturalistic occlusion generation, Random occlusion generation. you must install face-occlusion-generation and dataset. see more guide in https://github.com/kennyvoo/face-occlusion-generation.git | ||
|
||
|
||
## Dataset Preparation | ||
|
||
Please download the masks from this [drive](https://drive.google.com/drive/folders/15nZETWlGMdcKY6aHbchRsWkUI42KTNs5?usp=sharing) and the images from [CelebAMask-HQ](https://github.com/switchablenorms/CelebAMask-HQ), [11k Hands](https://sites.google.com/view/11khands) and [DTD](https://www.robots.ox.ac.uk/~vgg/data/dtd/). | ||
|
||
The extracted and upsampled COCO objects images and masks can be found in this [drive](https://drive.google.com/drive/folders/15nZETWlGMdcKY6aHbchRsWkUI42KTNs5?usp=sharing). | ||
|
||
Please extract CelebAMask-HQ and 11k Hands images based on the splits found in [drive](https://drive.google.com/drive/folders/15nZETWlGMdcKY6aHbchRsWkUI42KTNs5?usp=sharing). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to provide a script to help other users extract and split these images. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
**Dataset Organization:** | ||
|
||
```none | ||
|
||
├── dataset | ||
│ ├── CelebAMask-HQ-WO-Train_img | ||
│ │ ├── {image}.jpg | ||
│ ├── CelebAMask-HQ-WO-Train_mask | ||
│ │ ├── {mask}.png | ||
│ ├── DTD | ||
│ │ ├── images | ||
│ │ │ ├── {classA} | ||
│ │ │ │ ├── {image}.jpg | ||
│ │ │ ├── {classB} | ||
│ │ │ │ ├── {image}.jpg | ||
│ ├── 11k-hands_img | ||
│ │ ├── {image}.jpg | ||
│ ├── 11k-hands_mask | ||
│ │ ├── {mask}.png | ||
│ ├── object_image_sr | ||
│ │ ├── {image}.jpg | ||
│ ├── object_image_x4 | ||
│ │ ├── {mask}.png | ||
|
||
``` | ||
|
||
## Data Generation | ||
|
||
Example script to generate NatOcc dataset | ||
|
||
bash NatOcc.sh | ||
|
||
Example script to generate RandOcc dataset | ||
|
||
bash RandOcc.sh | ||
<!-- #endregion --> | ||
|
||
```python | ||
|
||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to use codes from the original repo as a reference and redevelop a script? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import os.path as osp | ||
|
||
from .builder import DATASETS | ||
from .custom import CustomDataset | ||
|
||
|
||
@DATASETS.register_module() | ||
class FaceOccludedDataset(CustomDataset): | ||
"""Face Occluded dataset. | ||
|
||
Args: | ||
split (str): Split txt file for Pascal VOC. | ||
""" | ||
|
||
CLASSES = ('background', 'face') | ||
|
||
PALETTE = [[0, 0, 0], [128, 0, 0]] | ||
|
||
def __init__(self, split, **kwargs): | ||
super(FaceOccludedDataset, self).__init__( | ||
img_suffix='.jpg', seg_map_suffix='.png', split=split, **kwargs) | ||
assert osp.exists(self.img_dir) and self.split is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure of the folder is not consistent with what the readme writes, could you also write the directory structure after conversion in the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done