summaryrefslogtreecommitdiff
path: root/neural_style.py
diff options
context:
space:
mode:
authorJonathan Böcker <jonathan.e.m.bocker@gmail.com>2016-12-04 17:13:54 +0100
committerJonathan Böcker <jonathan.e.m.bocker@gmail.com>2016-12-04 17:13:54 +0100
commit939faca825404d24556742b26b202c293964bae7 (patch)
tree67f153f28f1921197356cabed52df749182735b7 /neural_style.py
parent6ff2d3aec356560d84ecb207075107393ff9a762 (diff)
Python 3 compatibility
Map objects is not subscriptable in Python 3
Diffstat (limited to 'neural_style.py')
-rw-r--r--neural_style.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/neural_style.py b/neural_style.py
index 5373e5e..8d40e1b 100644
--- a/neural_style.py
+++ b/neural_style.py
@@ -535,14 +535,14 @@ def read_flow_file(path):
def read_weights_file(path):
lines = open(path).readlines()
- header = map(int, lines[0].split(' '))
+ header = list(map(int, lines[0].split(' ')))
w = header[0]
h = header[1]
vals = np.zeros((h, w), dtype=np.float32)
for i in range(1, len(lines)):
line = lines[i].rstrip().split(' ')
- vals[i-1] = np.array(map(np.float32, line))
- vals[i-1] = map(lambda x: 0. if x < 255. else 1., vals[i-1])
+ vals[i-1] = np.array(list(map(np.float32, line)))
+ vals[i-1] = list(map(lambda x: 0. if x < 255. else 1., vals[i-1]))
# expand to 3 channels
weights = np.dstack([vals.astype(np.float32)] * 3)
return weights