Skip to content

Commit

Permalink
[CVS-94911] Fix difference between train and validation normalization…
Browse files Browse the repository at this point in the history
… pipeline (#1310)

* Change _patch_datasets

* Solve ignore labels issue in Tiling method
  • Loading branch information
jaegukhyun authored Nov 23, 2022
1 parent 2f2068c commit 683aeb0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@
samples_per_gpu=10,
workers_per_gpu=4,
train=dict(
type="RepeatDataset",
times=1,
adaptive_repeat_times=True,
dataset=dict(
type=dataset_type,
ann_file="data/coco/annotations/instances_train2017.json",
img_prefix="data/coco/train2017",
pipeline=train_pipeline,
),
type=dataset_type,
ann_file="data/coco/annotations/instances_train2017.json",
img_prefix="data/coco/train2017",
pipeline=train_pipeline,
),
val=dict(
type=dataset_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,23 @@ def patch_color_conversion(pipeline):
elif pipeline_step.type == "MultiScaleFlipAug":
patch_color_conversion(pipeline_step.transforms)

def patch_data_pipeline(cfg):
pipeline = cfg.get("pipeline", None)
if pipeline is not None:
for pipeline_step in pipeline:
if pipeline_step.type == "LoadImageFromFile":
pipeline_step.type = "LoadImageFromOTEDataset"
if pipeline_step.type == "LoadAnnotations":
pipeline_step.type = "LoadAnnotationFromOTEDataset"
pipeline_step.domain = domain
pipeline_step.min_size = cfg.pop("min_size", -1)
if (subset == "train" and
pipeline_step.type == "Collect" and
cfg.type not in ["ImageTilingDataset"]):
pipeline_step = BaseTask._get_meta_keys(pipeline_step)
patch_color_conversion(cfg.pipeline)

# FIXME This code assume that max of wrapped data depth is 2
# remove redundant parameters introduced in self._recipe_cfg.merge_from_dict
remove_from_config(config, "ann_file")
remove_from_config(config, "img_prefix")
Expand All @@ -355,25 +372,17 @@ def patch_color_conversion(pipeline):
# remove redundant parameters introduced in self._recipe_cfg.merge_from_dict
remove_from_config(cfg, "ann_file")
remove_from_config(cfg, "img_prefix")
patch_data_pipeline(cfg)
if cfg.type in ["RepeatDataset", "MultiImageMixDataset", "ImageTilingDataset"]:
cfg = cfg.dataset
patch_data_pipeline(cfg)
cfg.type = "MPADetDataset"
cfg.domain = domain
cfg.ote_dataset = None
cfg.labels = None
remove_from_config(cfg, "ann_file")
remove_from_config(cfg, "img_prefix")
remove_from_config(cfg, "classes") # Get from DatasetEntity
for pipeline_step in cfg.pipeline:
if pipeline_step.type == "LoadImageFromFile":
pipeline_step.type = "LoadImageFromOTEDataset"
if pipeline_step.type == "LoadAnnotations":
pipeline_step.type = "LoadAnnotationFromOTEDataset"
pipeline_step.domain = domain
pipeline_step.min_size = cfg.pop("min_size", -1)
if subset == "train" and pipeline_step.type == "Collect":
pipeline_step = BaseTask._get_meta_keys(pipeline_step)
patch_color_conversion(cfg.pipeline)

@staticmethod
def _patch_evaluation(config: MPAConfig):
Expand Down

0 comments on commit 683aeb0

Please sign in to comment.