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]