Skip to content

RandZoomd align_corners incorrect #3983

@myron

Description

@myron

align_corners is handled incorrectly in RandZoomd (and possibly bugs in other transforms)

Example:
RandZoomd(keys=['image'], prob=0.5, min_zoom=0.9, max_zoom=1.1, mode=['trilinear'], align_corners=[False])

Will call Zoom transforms with mode = trilinear, but align_corners=None. Which will also show a lot of pytorch Warnings indicating that align_corners is not set.

Root cause:

when calling Zoom transform, for some reason we use parameters as

mode=look_up_option(mode or self.mode, InterpolateMode),
align_corners=align_corners or self.align_corners,

The use of 'or' is very ambiguous and leads to a bug in this case.

A or B -> returns A (if both A and B are strings or enums)
A or B -> returns B (if either A==None or B==None)

In our case
mode or self.mode -> returns mode
align_corners or self.align_corners -> returns self.align_corners (because align_corners==None)

as a result we get mode='trilinear', align_corners=None (the original option is lost)


We use this 'or' throughout the code for align_corners, and other parameters, which potentially created bugs if one of the options is None...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions