Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
achanhon committed Mar 11, 2024
1 parent 88561d5 commit 966b368
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions geometry/baseline/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self):
self.paths.append("/scratchf/DFC2015/BE_ORTHO_27032011_315130_56865.tif")

tmp = torch.arange(65536).long()
self.broad = ((tmp / 256).long(), (tmp % 256).long())
self.broad = ((tmp / 256).long().cuda(), (tmp % 256).long().cuda())

def oldCoordinate(self, r, c, a, b, d):
dr_ = a[0] + r * d[0], a[1] + r * d[1]
Expand All @@ -21,17 +21,16 @@ def get(self):
tirage = torch.rand(6)

i = int(tirage[0] * len(self.paths))
image = PIL.Image.open(self.paths[i])
image = image.resize((5000, 5000))
image = torch.Tensor(numpy.asarray(image))

r = int(tirage[1] * image.shape[0] - 1030)
c = int(tirage[2] * image.shape[1] - 1030)
x = image[r : r + 1024, c : c + 1024, :].clone() / 255
x = PIL.Image.open(self.paths[i])
x = torch.Tensor(numpy.asarray(x)).clone().cuda()
x = torch.stack([x[:, :, 0], x[:, :, 1], x[:, :, 2]], dim=0)
x = torch.nn.functional.avg_pool2d(x, kernel_size=2)

a = int(tirage[3] * 400 + 300), int(tirage[4] * 400 + 300)
r = int(tirage[1] * x.shape[1] - 1030)
c = int(tirage[2] * x.shape[2] - 1030)
x = x[:, r : r + 1024, c : c + 1024] / 255

a = int(tirage[3] * 400 + 300), int(tirage[4] * 400 + 300)
angle = tirage[5] * 3.1415 / 2

dbx = int(256 * torch.cos(angle))
Expand All @@ -44,7 +43,7 @@ def get(self):

p = self.oldCoordinate(self.broad[0], self.broad[1], a, b, d)
p = torch.clamp(p[0], 0, 1023), torch.clamp(p[1], 0, 1023)
x_ = torch.zeros(3, 256, 256)
x_ = torch.zeros(3, 256, 256).cuda()
x_[:, self.broad[0], self.broad[1]] = x[:, p[0], p[1]]

return x, x_, (a, b, d)
Expand Down

0 comments on commit 966b368

Please sign in to comment.