import numpy as np from scipy import misc, io from glob import glob import random from itertools import izip from random import random as rand from random import shuffle import h5py def gen_embedding_otf(cover_dir, beta_dir, shuf_pair, \ thread_idx=0, n_threads=1): cover_list = sorted(glob(cover_dir + '/*')) beta_list = sorted(glob(beta_dir + '/*')) nb_data = len(cover_list) assert len(beta_list) != 0, "the beta directory '%s' is empty" % beta_dir assert nb_data != 0, "the cover directory '%s' is empty" % cover_dir assert len(beta_list) == nb_data, "the cover directory and " + \ "the beta directory don't " + \ "have the same number of files " + \ "respectively %d and %d" % (nb_data, \ len(beta_list)) img = misc.imread(cover_list[0]) img_shape = img.shape batch = np.empty((2, img_shape[0], img_shape[1], 1), dtype='uint8') beta_map = np.empty(img_shape, dtype='