auto_augment/best_policies.py [407:439]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def to_scale(magnitude):
    """Returns a scale between [0.28, 1/.28].

    Args:
        magnitude (int): between 0 and 9 indicating magnitude.
            0 doesn't change scale
            1-5: zooms out. 6-9: zooms in
    """
    if magnitude < 0.0 or magnitude > 9.0:
        raise ValueError("magnitude must be within 0 and 9")
    zoom_out_step = 0.75 / 5.0
    zoom_in_step = (3.5 - 1.0) / 4.0

    magnitude_to_scale = {
        0: 1.0,
        1: 1.0 - zoom_out_step,
        2: 1.0 - 2 * zoom_out_step,
        3: 1.0 - 3 * zoom_out_step,
        4: 1.0 - 4 * zoom_out_step,
        5: 0.25,
        6: 1.0 + zoom_in_step,
        7: 1.0 + 2 * zoom_in_step,
        8: 1.0 + 3 * zoom_in_step,
        9: 3.5,
    }

    return magnitude_to_scale[int(magnitude)]


def rescale(img, magnitude):
    """Scales using pytorch"""
    scale = to_scale(magnitude)
    return torchvision.transforms.functional.affine(img, 0.0, (0.0, 0.0), scale, 0.0)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



per_class_augmentation/augmentations.py [126:158]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def to_scale(magnitude):
    """Returns a scale between [0.28, 1/.28].

    Args:
        magnitude (int): between 0 and 9 indicating magnitude.
            0 doesn't change scale
            1-5: zooms out. 6-9: zooms in
    """
    if magnitude < 0.0 or magnitude > 9.0:
        raise ValueError("magnitude must be within 0 and 9")
    zoom_out_step = 0.75 / 5.0
    zoom_in_step = (3.5 - 1.0) / 4.0

    magnitude_to_scale = {
        0: 1.0,
        1: 1.0 - zoom_out_step,
        2: 1.0 - 2 * zoom_out_step,
        3: 1.0 - 3 * zoom_out_step,
        4: 1.0 - 4 * zoom_out_step,
        5: 0.25,
        6: 1.0 + zoom_in_step,
        7: 1.0 + 2 * zoom_in_step,
        8: 1.0 + 3 * zoom_in_step,
        9: 3.5,
    }

    return magnitude_to_scale[int(magnitude)]


def rescale(img, magnitude):
    """Scales using pytorch"""
    scale = to_scale(magnitude)
    return torchvision.transforms.functional.affine(img, 0.0, (0.0, 0.0), scale, 0.0)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



