{"record":{"id":"6735dbaa4c13d687","repo":"open-mmlab/mmdetection","slug":"invalid-flipping-direction-flip-direction","errorCode":null,"errorMessage":"Invalid flipping direction '{flip_direction}'","messagePattern":"Invalid flipping direction '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mmdet/models/test_time_augs/merge_augs.py","lineNumber":212,"sourceCode":"    recovered_masks = []\n    for i, mask in enumerate(aug_masks):\n        if weights is not None:\n            assert len(weights) == len(aug_masks)\n            weight = weights[i]\n        else:\n            weight = 1\n        flip = img_metas.get('flip', False)\n        if flip:\n            flip_direction = img_metas['flip_direction']\n            if flip_direction == 'horizontal':\n                mask = mask[:, :, :, ::-1]\n            elif flip_direction == 'vertical':\n                mask = mask[:, :, ::-1, :]\n            elif flip_direction == 'diagonal':\n                mask = mask[:, :, :, ::-1]\n                mask = mask[:, :, ::-1, :]\n            else:\n                raise ValueError(\n                    f\"Invalid flipping direction '{flip_direction}'\")\n        recovered_masks.append(mask[None, :] * weight)\n\n    merged_masks = torch.cat(recovered_masks, 0).mean(dim=0)\n    if weights is not None:\n        merged_masks = merged_masks * len(weights) / sum(weights)\n    return merged_masks\n","sourceCodeStart":194,"sourceCodeEnd":220,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/test_time_augs/merge_augs.py#L194-L220","documentation":"merge_aug_masks reverts test-time-augmentation flips on predicted masks and only understands 'horizontal', 'vertical', and 'diagonal' flip directions. When the augmentation config produced another direction string, it raises ValueError.","triggerScenarios":"Calling merge_aug_masks (via multi-scale / flip TTA predict) where aug_masks metadata carries a flip_direction other than the three supported values, e.g. 'diag' or a custom string set in the test pipeline.","commonSituations":"Custom flip transforms in the test pipeline, or configs migrated from other repos (mmdet3d uses 'DIAGONAL') where direction casing/values differ.","solutions":["Use only 'horizontal', 'vertical', or 'diagonal' in flip_direction in the test-time aug pipeline","Check custom Flip transforms to ensure they emit these exact lowercase strings"],"exampleFix":"# before\ntta_pipeline=[..., dict(type='Flip', flip_direction='diag')]\n# after\ntta_pipeline=[..., dict(type='Flip', flip_direction='diagonal')]","handlingStrategy":"validation","validationCode":"assert flip_direction in ('horizontal', 'vertical', 'diagonal'), flip_direction","typeGuard":"def is_valid_flip_direction(d: str) -> bool:\n    return d in ('horizontal', 'vertical', 'diagonal')","tryCatchPattern":"try:\n    merge_aug_masks(masks, cfg)\nexcept ValueError as e:\n    if 'Invalid flipping direction' in str(e):\n        # normalize or drop unsupported flips\n        ...\n    raise","preventionTips":["Only emit lowercase canonical direction strings from Flip transforms","Add an enum/literal check in custom TTA pipelines"],"tags":["mmdetection","test-time-augmentation","flip","mask"],"backgroundTag":"invalid-enum-value","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}