How to use dihedral transform?

With the dataset I am using it only makes sense to have one transform: k=(0, 1) dihedral transform.
I can’t figure out how to just pass that into the transform argument of the Datablock.

I am trying this:

def _dihedral_affine(k:partial(uniform_int,0,1)):
    "Randomly flip `x` image based on `k`."
    x = -1 if k&1 else 1
    y = -1 if k&2 else 1
    if k&4: return [[0, x, 0.],
                    [y, 0, 0],
                    [0, 0, 1.]]
    return [[x, 0, 0.],
            [0, y, 0],
            [0, 0, 1.]]
dihedral_affine = TfmAffine(_dihedral_affine)

tfms = [[dihedral_affine], []]

I then get the error in the datablock:

'TfmAffine' object has no attribute 'tfm'

In general, from the documentation I have no idea how one can build their own list of transformations like is created by get_transforms.

I figured it out. I need to call the dihedral_affine function, not just pass the function.

tfms = [[dihedral_affine()], []]
1 Like