Пример #1
0
def test_fusion_happens(img_5x5):
    ppl = slc.Stream([
        slt.Scale((0.5, 1.5), (0.5, 1.5), p=1),
        slt.Rotate((-50, 50), padding='z', p=1),
        slt.Shear((-0.5, 0.5), (-0.5, 0.5), padding='z', p=1),
    ])
    dc = slc.DataContainer(img_5x5, 'I')
    st = ppl.optimize_transforms_stack(ppl.transforms, dc)
    assert len(st) == 1
Пример #2
0
def my_transforms():
    train_trf = solt.Stream([
        slt.Scale(range_x=(0.9, 1.1), same=False, p=0.5),
        slt.Shear(range_x=(-0.05, 0.05), p=0.5),
        slt.Rotate((-5, 5), p=0.5),
        slt.Pad(pad_to=(32, 32))
    ])

    test_trf = solt.Stream([slt.Pad(pad_to=(32, 32))])

    return {'train': train_trf, 'eval': test_trf}
Пример #3
0
def test_stream_settings():
    ppl = slc.Stream([
        slt.Rotate((45, 45), interpolation='bicubic', padding='z', p=1),
        slt.Rotate((45, 45), padding='r', p=1),
        slt.Rotate((45, 45), interpolation='bicubic', padding='z', p=1),
        slt.Shear(0.1, 0.1, interpolation='bilinear', padding='z'),
    ],
                     interpolation='nearest',
                     padding='z')

    for trf in ppl.transforms:
        assert trf.interpolation[0] == 'nearest'
        assert trf.padding[0] == 'z'
Пример #4
0
def test_stream_settings():
    ppl = slc.Stream(
        [
            slt.Rotate((45, 45), interpolation="bicubic", padding="z", p=1),
            slt.Rotate((45, 45), padding="r", p=1),
            slt.Rotate((45, 45), interpolation="bicubic", padding="z", p=1),
            slt.Shear(0.1, 0.1, interpolation="bilinear", padding="z"),
        ],
        interpolation="nearest",
        padding="z",
    )

    for trf in ppl.transforms:
        assert trf.interpolation[0] == "nearest"
        assert trf.padding[0] == "z"
Пример #5
0
def test_random_proj_and_selective_stream(img):
    dc = slc.DataContainer((img, ), "I")

    ppl = slt.Projection(
        slc.SelectiveStream(
            [
                slt.Rotate(angle_range=(90, 90), p=0),
                slt.Scale(range_y=(0, 0.1), same=True, p=0),
                slt.Shear(range_y=(-0.1, 0.1), p=0),
            ],
            n=3,
        ),
        v_range=(0, 0),
    )

    dc_res = ppl(dc)

    assert np.array_equal(dc.data, dc_res.data)
Пример #6
0
def test_stream_settings_strict():
    ppl = slc.Stream([
        slt.Rotate((45, 45), interpolation='bicubic', padding='z', p=1),
        slt.Rotate((45, 45), padding='r', p=1),
        slt.Rotate((45, 45),
                   interpolation=('bicubic', 'strict'),
                   padding=('r', 'strict'),
                   p=1),
        slt.Shear(0.1, 0.1, interpolation='bilinear', padding='z'),
    ],
                     interpolation='nearest',
                     padding='z')

    for idx, trf in enumerate(ppl.transforms):
        if idx == 2:
            assert trf.interpolation[0] == 'bicubic'
            assert trf.padding[0] == 'r'
        else:
            assert trf.interpolation[0] == 'nearest'
            assert trf.padding[0] == 'z'
Пример #7
0
def test_stream_settings_strict():
    ppl = slc.Stream(
        [
            slt.Rotate((45, 45), interpolation="bicubic", padding="z", p=1),
            slt.Rotate((45, 45), padding="r", p=1),
            slt.Rotate((45, 45),
                       interpolation=("bicubic", "strict"),
                       padding=("r", "strict"),
                       p=1),
            slt.Shear(0.1, 0.1, interpolation="bilinear", padding="z"),
        ],
        interpolation="nearest",
        padding="z",
    )

    for idx, trf in enumerate(ppl.transforms):
        if idx == 2:
            assert trf.interpolation[0] == "bicubic"
            assert trf.padding[0] == "r"
        else:
            assert trf.interpolation[0] == "nearest"
            assert trf.padding[0] == "z"
Пример #8
0
def test_shear_range_none():
    trf = slt.Shear(None, None)
    assert trf.range_x == (0, 0)
    assert trf.range_y == (0, 0)