From 71d6d05e4c479480585796c3cc0b76aafaf01117 Mon Sep 17 00:00:00 2001 From: 4F2E4A2E <4F2E4A2E@users.noreply.github.com> Date: Sun, 6 Jan 2019 19:26:19 +0100 Subject: [PATCH] feat: extending python 3 support The project runs fine with python 3.6 and tf.1.10, but these changes are not compatible with python2. [1]: Python 3 changes return values of several basic functions from list to iterator. The main reason for this change is that iterators usually cause better memory consumption than lists. 1: https://portingguide.readthedocs.io/en/latest/iterators.html --- neural_style.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neural_style.py b/neural_style.py index a5f8fc7..b820ec4 100644 --- a/neural_style.py +++ b/neural_style.py @@ -524,7 +524,7 @@ def read_weights_file(path): for i in range(1, len(lines)): line = lines[i].rstrip().split(' ') 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])) + vals[i-1] = list([0. if x < 255. else 1. for x in vals[i-1]]) # expand to 3 channels weights = np.dstack([vals.astype(np.float32)] * 3) return weights