[Python] Rotation with Pytorch Torchvision but from two specific angles

Discussão em 'Python' iniciado por Stack, Setembro 3, 2025.

  1. Stack

    Stack Membro Participativo

    I want to randomly rotate my images at 45 degrees or -45 degrees, but only these two, no in between. 50% chances for 45 and 50% for -45.

    I know that I can use RandomRotation of torchvision, but if I do like in this example:

    import torchvision.transforms as T

    transforms = T.Compose([
    T.RandomRotation((-45, 45))
    ])


    The rotation will be random between -45 and 45 degrees, so that's not what I want. How to be sure the rotation will be specifically these two angles?

    Thanks in advance for your answers.

    Continue reading...

Compartilhe esta Página