a38ac8958ebf1c61a10c4d5320f1e31d3d0b73dd,tests/test_retina.py,,main,#,59

Before Change


    for i in range(len(paths)):
        img = img2array(paths[i], desired_size=[512, 512], expand=True)
        imgs.append(torch.from_numpy(img))
    imgs = Variable(torch.cat(imgs))
    imgs = imgs.permute(0, 3, 1, 2)

    // loc = torch.Tensor(2, 2).uniform_(-1, 1)
    loc = torch.from_numpy(np.array([[0., 0.], [0., 0.]]))
    loc = Variable(loc)

    ret = retina(g=64, k=3, s=2)
    glimpse = ret.foveate(imgs, loc).data.numpy()

    glimpse = np.reshape(glimpse, [2, 3, 3, 64, 64])
    glimpse = np.transpose(glimpse, [0, 1, 3, 4, 2])

    merged = []
    for i in range(len(glimpse)):
        g = glimpse[i]
        g = list(g)
        g = [array2img(l) for l in g]
        res = reduce(merge_images, list(g))
        merged.append(res)

    merged = [np.asarray(l, dtype="float32")/255.0 for l in merged]

After Change


    for i in range(len(paths)):
        img = img2array(paths[i], desired_size=[512, 512], expand=True)
        imgs.append(torch.from_numpy(img))
    imgs = torch.cat(imgs).permute(0, 3, 1, 2)

    // loc = torch.Tensor(2, 2).uniform_(-1, 1)
    loc = torch.from_numpy(np.array([[0.0, 0.0], [0.0, 0.0]]))

    num_patches = 5
    scale = 2
    patch_size = 10

    ret = Retina(g=patch_size, k=num_patches, s=scale)
    glimpse = ret.foveate(imgs, loc).data.numpy()

    glimpse = np.reshape(glimpse, [2, num_patches, 3, patch_size, patch_size])
    glimpse = np.transpose(glimpse, [0, 1, 3, 4, 2])

    merged = []
    for i in range(len(glimpse)):
        g = glimpse[i]
        g = list(g)
        g = [array2img(l) for l in g]
        res = reduce(merge_images, list(g))
        merged.append(res)

    merged = [np.asarray(l, dtype="float32") / 255.0 for l in merged]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 2

Instances


Project Name: kevinzakka/recurrent-visual-attention
Commit Name: a38ac8958ebf1c61a10c4d5320f1e31d3d0b73dd
Time: 2020-05-23
Author: kevinarmandzakka@gmail.com
File Name: tests/test_retina.py
Class Name:
Method Name: main


Project Name: ClementPinard/FlowNetPytorch
Commit Name: 678ac413ce55cb3db09d1f24532920582af54f43
Time: 2018-11-12
Author: clement.pinard@parrot.com
File Name: run_inference.py
Class Name:
Method Name: main