Skip to content

Commit

Permalink
[Api] vis hook and data flow api (#1185)
Browse files Browse the repository at this point in the history
* vis hook and data flow api

* fix comment

* add TODO for merging and rewriting after MultiDatasetWrapper
  • Loading branch information
Harold-lkk authored Aug 8, 2022
1 parent 6759bd4 commit ef68320
Show file tree
Hide file tree
Showing 36 changed files with 549 additions and 351 deletions.
9 changes: 8 additions & 1 deletion configs/_base_/default_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
param_scheduler=dict(type='ParamSchedulerHook'),
checkpoint=dict(type='CheckpointHook', interval=1),
sampler_seed=dict(type='DistSamplerSeedHook'),
sync_buffer=dict(type='SyncBuffersHook'))
visualization=dict(
type='VisualizationHook',
interval=1,
enable=False,
show=False,
draw_gt=False,
draw_pred=False),
)

env_cfg = dict(
cudnn_benchmark=True,
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/drrg/drrg_r50_fpn_unet_1200e_ctw1500.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(1024, 640), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/fcenet/fcenet_r50_fpn_1500e_icdar2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(2260, 2260), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/fcenet/fcenet_r50dcnv2_fpn_1500e_ctw1500.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(1080, 736), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/maskrcnn/mask_rcnn_r50_fpn_160e_ctw1500.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(1600, 1600), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/maskrcnn/mask_rcnn_r50_fpn_160e_icdar2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(1920, 1920), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/maskrcnn/mask_rcnn_r50_fpn_160e_icdar2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(1920, 1920), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/panet/panet_r18_fpem_ffm_600e_icdar2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@
scale_divisor=1,
ratio_range=(1.0, 1.0),
aspect_ratio_range=(1.0, 1.0)),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
10 changes: 8 additions & 2 deletions configs/textdet/psenet/psenet_r50_fpnf_600e_icdar2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(2240, 2240), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@
file_client_args=file_client_args,
color_type='color_ignore_orientation'),
dict(type='Resize', scale=(1333, 736), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True),
dict(
type='PackTextDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'scale_factor'))
]

train_dataloader = dict(
Expand Down
7 changes: 4 additions & 3 deletions configs/textrecog/abinet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@
]
test_pipeline = [
dict(type='LoadImageFromFile', file_client_args=file_client_args),
dict(type='LoadOCRAnnotations', with_text=True),
dict(type='Resize', scale=(128, 32)),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/crnn/crnn_academic_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
min_width=32,
max_width=None,
width_divisor=16),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/master/master_r31_12e_ST_MJ_SA.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/master/master_toy_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/nrtr/nrtr_modality_transform_academic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/nrtr/nrtr_modality_transform_toy_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/nrtr/nrtr_r31_1by16_1by8_academic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/nrtr/nrtr_r31_1by8_1by4_academic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
max_width=160,
width_divisor=4),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

# dataset settings
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/sar/sar_r31_parallel_decoder_academic.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
max_width=160,
width_divisor=4),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

# dataset settings
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/sar/sar_r31_sequential_decoder_academic.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
max_width=160,
width_divisor=4),
dict(type='PadToWidth', width=160),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

# dataset settings
Expand Down
6 changes: 4 additions & 2 deletions configs/textrecog/satrn/satrn_academic.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@
test_pipeline = [
dict(type='LoadImageFromFile', file_client_args=file_client_args),
dict(type='Resize', scale=(100, 32), keep_ratio=False),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]

train_dataloader = dict(
Expand Down
1 change: 1 addition & 0 deletions mmocr/engine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .hooks import * # NOQA
from .runner import * # NOQA
4 changes: 4 additions & 0 deletions mmocr/engine/hooks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .visualization_hook import VisualizationHook

__all__ = ['VisualizationHook']
Loading

0 comments on commit ef68320

Please sign in to comment.