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

[CVS-94911] Fix difference between train and validation normalization pipeline #1310

Merged
merged 2 commits into from
Nov 23, 2022
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
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)
jaegukhyun marked this conversation as resolved.
Show resolved Hide resolved
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