mmsegmentation
mmsegmentation copied to clipboard
Add support for multiple random flips
Motivation
This PR addresses #1781 by adding support for multiple RandomFlip
operations in the training_pipeline
.
Modification
With this PR it is possible to define multiple random flip operations by adding something like
dict(type='RandomFlip', prob=(0.5, 0.5), direction=("vertical", "horizontal"))
to the training_pipeline
, e.g.
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', reduce_zero_label=True),
...
dict(type='RandomFlip', prob=(0.5, 0.5), direction=("vertical", "horizontal"))`
...
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
]
Legacy inputs such as dict(type='RandomFlip', prob=0.5, direction="vertical"
are still allowed (i.e. the patch is backward compatible).
Use cases (Optional)
For specific image domains it is reasonable to flip the data in both directions.
Checklist
- Pre-commit or other linting tools are used to fix the potential lint issues. [Yes]
- The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness. [There are already unit tests covering the random flip operator. Is it necessary to adjust these?]
- The documentation has been modified accordingly, like docstring or example tutorials. [Yes]
Codecov Report
Merging #1812 (1dd0bc1) into master (13d4c39) will increase coverage by
0.00%
. The diff coverage is95.65%
.
@@ Coverage Diff @@
## master #1812 +/- ##
=======================================
Coverage 89.04% 89.04%
=======================================
Files 144 144
Lines 8636 8648 +12
Branches 1458 1463 +5
=======================================
+ Hits 7690 7701 +11
Misses 706 706
- Partials 240 241 +1
Flag | Coverage Δ | |
---|---|---|
unittests | 89.04% <95.65%> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
mmseg/datasets/pipelines/transforms.py | 97.91% <95.65%> (-0.15%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 03c2447...1dd0bc1. Read the comment docs.
See https://github.com/open-mmlab/mmsegmentation/pull/1918