Unverified Commit 0d5233a3 authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

Make data pre-processing pipeline customizable (#935)

* define data pipelines

* update two config files

* minor fix for config files

* allow img_scale to be optional and update config

* add some docstrings

* add extra aug to transform

* bug fix for mask resizing

* fix cropping

* add faster rcnn example

* fix imports

* fix robustness testing

* add img_norm_cfg to img_meta

* fix the inference api with the new data pipeline

* fix proposal loading

* delete args of DefaultFormatBundle

* add more configs

* update configs

* bug fix

* add a brief doc

* update gt_labels in RandomCrop

* fix key error for new apis

* bug fix for masks of crowd bboxes

* add argument data_root

* minor fix

* update new hrnet configs

* update docs

* rename MultiscaleFlipAug to MultiScaleFlipAug

* add __repr__ for all transforms

* move DATA_PIPELINE.md to docs/

* fix image url
parent 7bb38af4
...@@ -127,6 +127,31 @@ dataset_type = 'CocoDataset' ...@@ -127,6 +127,31 @@ dataset_type = 'CocoDataset'
data_root = 'data/coco/' data_root = 'data/coco/'
img_norm_cfg = dict( img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 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', with_bbox=True),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
data = dict( data = dict(
imgs_per_gpu=2, imgs_per_gpu=2,
workers_per_gpu=2, workers_per_gpu=2,
...@@ -134,35 +159,17 @@ data = dict( ...@@ -134,35 +159,17 @@ data = dict(
type=dataset_type, type=dataset_type,
ann_file=data_root + 'annotations/instances_train2017.json', ann_file=data_root + 'annotations/instances_train2017.json',
img_prefix=data_root + 'train2017/', img_prefix=data_root + 'train2017/',
img_scale=(1333, 800), pipeline=train_pipeline),
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0.5,
with_mask=False,
with_crowd=True,
with_label=True),
val=dict( val=dict(
type=dataset_type, type=dataset_type,
ann_file=data_root + 'annotations/instances_val2017.json', ann_file=data_root + 'annotations/instances_val2017.json',
img_prefix=data_root + 'val2017/', img_prefix=data_root + 'val2017/',
img_scale=(1333, 800), pipeline=test_pipeline),
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0,
with_mask=False,
with_crowd=True,
with_label=True),
test=dict( test=dict(
type=dataset_type, type=dataset_type,
ann_file=data_root + 'annotations/instances_val2017.json', ann_file=data_root + 'annotations/instances_val2017.json',
img_prefix=data_root + 'val2017/', img_prefix=data_root + 'val2017/',
img_scale=(1333, 800), pipeline=test_pipeline))
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0,
with_mask=False,
with_label=False,
test_mode=True))
# optimizer # optimizer
optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
......
...@@ -84,6 +84,31 @@ dataset_type = 'CocoDataset' ...@@ -84,6 +84,31 @@ dataset_type = 'CocoDataset'
data_root = 'data/coco/' data_root = 'data/coco/'
img_norm_cfg = dict( img_norm_cfg = dict(
mean=[102.9801, 115.9465, 122.7717], std=[1.0, 1.0, 1.0], to_rgb=False) mean=[102.9801, 115.9465, 122.7717], std=[1.0, 1.0, 1.0], to_rgb=False)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
data = dict( data = dict(
imgs_per_gpu=2, imgs_per_gpu=2,
workers_per_gpu=2, workers_per_gpu=2,
...@@ -91,36 +116,17 @@ data = dict( ...@@ -91,36 +116,17 @@ data = dict(
type=dataset_type, type=dataset_type,
ann_file=data_root + 'annotations/instances_train2017.json', ann_file=data_root + 'annotations/instances_train2017.json',
img_prefix=data_root + 'train2017/', img_prefix=data_root + 'train2017/',
img_scale=(1333, 800), pipeline=train_pipeline),
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0.5,
with_mask=False,
with_crowd=False,
with_label=True),
val=dict( val=dict(
type=dataset_type, type=dataset_type,
ann_file=data_root + 'annotations/instances_val2017.json', ann_file=data_root + 'annotations/instances_val2017.json',
img_prefix=data_root + 'val2017/', img_prefix=data_root + 'val2017/',
img_scale=(1333, 800), pipeline=test_pipeline),
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0,
with_mask=False,
with_crowd=False,
with_label=True),
test=dict( test=dict(
type=dataset_type, type=dataset_type,
ann_file=data_root + 'annotations/instances_val2017.json', ann_file=data_root + 'annotations/instances_val2017.json',
img_prefix=data_root + 'val2017/', img_prefix=data_root + 'val2017/',
img_scale=(1333, 800), pipeline=test_pipeline))
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0,
with_mask=False,
with_crowd=False,
with_label=False,
test_mode=True))
# optimizer # optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment