From 46c69eaca4831ceb0fbad2a94a47dff9c0cbb444 Mon Sep 17 00:00:00 2001 From: stefan <22373423+Stefan20162016@users.noreply.github.com> Date: Tue, 20 Aug 2019 19:01:35 +0200 Subject: [PATCH] faster convert_images.py see my github rep https://github.com/Stefan20162016/convert_images for even faster ones --- chapter7/eigenfaces/data/convert_images.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chapter7/eigenfaces/data/convert_images.py b/chapter7/eigenfaces/data/convert_images.py index c1fb4ab..bf47560 100755 --- a/chapter7/eigenfaces/data/convert_images.py +++ b/chapter7/eigenfaces/data/convert_images.py @@ -28,7 +28,9 @@ for index, filename in enumerate(files): if index % 1000 == 0: print index - data[index] = np.mean(imread(dirname+filename), axis=2)[::subx,::suby].flatten() + data[index] = np.mean(imread(dirname+filename)[::4,::4] , axis=2).ravel() + #data[index] = np.mean(imread(dirname+filename), axis=2)[::subx,::suby].flatten() with open("celebA_gray_lowres.%d_%d_%d_32.bin" % (data.shape[0], dimx, dimy), "wb") as f: - f.write(ar.array("f", data.flatten())) + np.asarray(data, dtype=np.float32).tofile(f) + #f.write(ar.array("f", data.flatten()))