DALI icon indicating copy to clipboard operation
DALI copied to clipboard

[Cutmix] Make fn.multi_paste more flexible, fix validation

Open stiepan opened this issue 1 year ago • 3 comments

Category:

New feature (non-breaking change which adds functionality) Bug fix (non-breaking change which fixes an issue)

Description:

This PR reworks arguments and their parsing for fn.multi_paste to make it more flexible and easier to use (with cutmix augmentation in mind; namely ability to mix different batches and no need to use image shape explicitly if the inputs are uniformly shaped). It fixes a couple of bugs.

Fixes:

  • There was no validation of in_ids leading to out-of-bound accesses for incorrect input
  • The number of channels was handled incorrectly
    • GPU assumed 3 channels no matter the actual number of channels - leading to incorrect cuda mem accesses.
    • Both backends did not verify if all the pasted regions have the same number of channels (and if the output number of channels matches). The number of output channels was copied from the corresponding input sample. The PR changes that - the number of output channels is inferred from the actually pasted regions and uses the old behaviour only if there are none (to be compatible with the only case it could have worked previously).

New features:

  • The in_anchors, region shapes and out_anchors have now relative counterparts - they can be specified as [0, 1] floats relative to input/output shape for simplicity.
  • To allow mixing images of diffrent batches, the operator can accept multiple inputs - in that case the in_ids must not be specified and the regions are pasted elementwise.
  • If all the input shapes are uniform and no output size is provided, the output shape is assumed to be the same.

Other changes:

  • The args are parsed once and saved to not recompute them along the way
  • No intersection check is moved to the CPU impl, it's outputs were ignored by the GPU impl anyway.
  • Added video support.

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

Tests:

  • [ ] Existing tests apply
  • [x] New tests added
    • [x] Python tests
    • [ ] GTests
    • [ ] Benchmark
    • [ ] Other
  • [ ] N/A

Checklist

Documentation

  • [ ] Existing documentation applies
  • [x] Documentation updated
    • [x] Docstring
    • [ ] Doxygen
    • [ ] RST
    • [ ] Jupyter
    • [ ] Other
  • [ ] N/A

DALI team only

Requirements

  • [ ] Implements new requirements
  • [ ] Affects existing requirements
  • [ ] N/A

REQ IDs: N/A

JIRA TASK: DALI-3496

stiepan avatar Feb 19 '24 23:02 stiepan

!build

stiepan avatar Feb 19 '24 23:02 stiepan

CI MESSAGE: [12935254]: BUILD STARTED

dali-automaton avatar Feb 19 '24 23:02 dali-automaton

CI MESSAGE: [12935254]: BUILD FAILED

dali-automaton avatar Feb 20 '24 01:02 dali-automaton

!build

stiepan avatar Feb 26 '24 12:02 stiepan

CI MESSAGE: [13087567]: BUILD STARTED

dali-automaton avatar Feb 26 '24 12:02 dali-automaton

CI MESSAGE: [13087567]: BUILD PASSED

dali-automaton avatar Feb 26 '24 15:02 dali-automaton

!build

stiepan avatar Mar 01 '24 12:03 stiepan

CI MESSAGE: [13201260]: BUILD STARTED

dali-automaton avatar Mar 01 '24 12:03 dali-automaton

!build

stiepan avatar Mar 01 '24 13:03 stiepan

CI MESSAGE: [13202219]: BUILD STARTED

dali-automaton avatar Mar 01 '24 13:03 dali-automaton

CI MESSAGE: [13202219]: BUILD PASSED

dali-automaton avatar Mar 01 '24 15:03 dali-automaton