Example #1
0
def test_api_repair(image, size):
    src = PIL.ImageOps.mirror(image)
    repair = Repair(target=image.convert("RGBA"), source=src)
    for r in process_octaves(repair, size=size):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)
Example #2
0
def test_patch_single(image, size=(64, 48)):
    remix = Remix(image(size), mode="patch")
    for r in process_octaves(remix, octaves=2, size=size, threshold=1e-3):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)
        assert r.loss < 5e-0
Example #3
0
def test_hist_single(image, size=(32, 48)):
    remix = Remix(image(size), mode="hist")
    for r in process_octaves(remix, octaves=2, size=size):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)
        assert r.loss < 1e-1
Example #4
0
def test_gram_single(image, size=(96, 88)):
    remix = Remix(image(size), mode="gram")
    for r in process_octaves(remix, octaves=2, size=size):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)
        assert abs(r.iteration) < 200
        assert r.loss < 5e-1
Example #5
0
def test_gram_single(image, size=(96, 88)):
    for _, loss, images in process_octaves(image(size),
                                           octaves=2,
                                           size=size,
                                           mode="gram"):
        assert len(images) == 1
        assert all(isinstance(img, PIL.Image.Image) for img in images)
        assert all(img.size == size for img in images)
        assert loss < 5e-2
Example #6
0
def test_patch_single(image, size=(64, 48)):
    for _, loss, images in process_octaves(image(size),
                                           octaves=2,
                                           size=size,
                                           mode="patch",
                                           threshold=1e-3):
        assert len(images) == 1
        assert all(isinstance(img, PIL.Image.Image) for img in images)
        assert all(img.size == size for img in images)
        assert loss < 5.0
Example #7
0
def test_gram_variations(image, size=(72, 64)):
    for _, loss, images in process_octaves(image(size),
                                           variations=2,
                                           octaves=2,
                                           size=size,
                                           mode="gram"):
        assert len(images) == 2
        assert all(isinstance(img, PIL.Image.Image) for img in images)
        assert all(img.size == size for img in images)
        assert loss < 5e-1
Example #8
0
def test_api_expand(image, size):
    expand = Expand(target=image, source=image, factor=(2.0, 2.0))
    for r in process_octaves(expand, size=size):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)
Example #9
0
def test_api_enhance(image, size):
    mashup = Enhance(target=image, source=image, zoom=2)
    for r in process_octaves(mashup, size=size):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)
Example #10
0
def test_api_mashup(image, size):
    mashup = Mashup(sources=[image, image])
    for r in process_octaves(mashup, size=size):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)
Example #11
0
def test_api_remake(image, size):
    remake = Remake(target=image, source=image)
    for r in process_octaves(remake, size=size):
        assert len(r.images) == 1
        assert isinstance(r.images, torch.Tensor)
        assert r.images.shape[2:] == (size[1] // r.scale, size[0] // r.scale)