Skip to content

Commit b5fee62

Browse files
committed
Update maps.py
1 parent e9e11c8 commit b5fee62

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/maps.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def standardize(self, converter):
2626
logging.info(f"Normalizing the data in [-1, 1] using {converter.__class__.__name__}")
2727
#TODO Ishaan
2828
# (self.converter.get_char(mapReader.data[i + x][j + y]) / (len(self.converter.char_groups) - 1)) * -2 + 1
29+
maxVal = len(converter.char_groups) - 1
30+
for i in range(0, self.size[0]):
31+
for j in range(0, self.size[1]):
32+
self.data[i][j] = (converter.get_char(self.data[i][j]) / maxVal) * -2 + 1
2933
pass
3034

3135
# Converter object that can return character for OpenStreetMap layer group
@@ -118,20 +122,20 @@ def generate_patches(self, mapReader, image_groups=3, outDirectory=None):
118122
def extractSample(self, mapReader, topLeft):
119123
i = topLeft[0]
120124
j = topLeft[1]
121-
sample = [
122-
[
123-
(self.converter.get_char(mapReader.data[i + x][j + y]) / (len(self.converter.char_groups) - 1)) * -2 + 1 # TODO this conversion should be done once in the original data instead of patches.
124-
for y in range(self.window_size[1])
125-
]
126-
for x in range(self.window_size[0])
127-
]
128125
# sample = [
129126
# [
130-
# mapReader.data[i + x][j + y]
127+
# (self.converter.get_char(mapReader.data[i + x][j + y]) / (len(self.converter.char_groups) - 1)) * -2 + 1 # TODO this conversion should be done once in the original data instead of patches.
131128
# for y in range(self.window_size[1])
132129
# ]
133130
# for x in range(self.window_size[0])
134131
# ]
132+
sample = [
133+
[
134+
mapReader.data[i + x][j + y]
135+
for y in range(self.window_size[1])
136+
]
137+
for x in range(self.window_size[0])
138+
]
135139
return np.asarray(sample)
136140

137141

0 commit comments

Comments
 (0)