Skip to content

Instantly share code, notes, and snippets.

@makeyourownalgorithmicart
Created May 21, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makeyourownalgorithmicart/27fd5f3575050b1b8829028323a4c3f2 to your computer and use it in GitHub Desktop.
Save makeyourownalgorithmicart/27fd5f3575050b1b8829028323a4c3f2 to your computer and use it in GitHub Desktop.
coverts celebaA zip file of images to h5py dataset
# (c) Tariq Rashid 2019
# GPL v2
import h5py
import zipfile
import imageio
import os
with h5py.File('celeba_dataset/celeba_aligned_small.h5py', 'w') as hf:
count = 1
with zipfile.ZipFile('celeba_dataset/img_align_celeba.zip', 'r') as zf:
for i in zf.namelist():
if (i[-4:] == '.jpg'):
ofile = zf.extract(i)
img = imageio.imread(ofile)
#img_list.append(img)
os.remove(ofile)
count = count + 1
if (count%10000 == 0):
print(count, img.shape)
pass
hf.create_dataset(i, data=img, compression="gzip", compression_opts=9)
if (count == 20000):
break
pass
pass
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment