def gen_face_data(basedir):
    image_files = glob.glob(join(basedir, IMG_SUBDIR, '*'))
    face_dir = join(basedir, FACE_SUBDIR)
    face_lm_dir = join(basedir, FACE_LM_SUBDIR)
    if not os.path.exists(face_dir):
        os.mkdir(face_dir)
    if not os.path.exists(face_lm_dir):
        os.mkdir(face_lm_dir)
    for idx, image_file in enumerate(image_files):
        # processing face
        im = imread(image_file, False)
        face_rects = facedet(im) if im != None else []
        if len(face_rects) != 1:
            # don't know exactly what to do, skipping
            continue
        i, j, h, w = face_rects[0]
        cropped_face = im[i : i+h+30, j : j+w] # extend height and crop
        face = standartize(cropped_face)
        face_file = join(face_dir, os.path.basename(image_file))
        cv2.imwrite(face_file, face)
        # processing landmarks
        lm_file_base = (os.path.basename(face_file).split('.')[0] +
                        '_landmarks.txt')
        lm_file = join(basedir, LM_SUBDIR, lm_file_base)
        lms = read_landmarks(lm_file)
        cropped_face_lms = move_landmarks(lms, (i, j))
        face_lms = standartize_landmarks(cropped_face_lms, 
                                         cropped_face.shape[:2])
        face_lm_file = join(face_lm_dir, lm_file_base)
        write_landmarks(face_lm_file, face_lms)
        if idx % 50 == 0 and idx != 0:
            print('%d files processed' % idx)
    print('Done.')
Create a RangeIterator.
dataset/ETHPy150Open dfdx/masque/bin/datagen.py/gen_face_data--crossover with--dataset/ETHPy150Open GoogleCloudPlatform/appengine-mapreduce/python/src/mapreduce/datastore_range_iterators.py/RangeIteratorFactory.create_multi_property_range_iterator