def img_seg(volpath, segpath, batch_size=1, verbose=False, nb_restart_cycle=None, name='img_seg', ext='.png', vol_rand_seed=None, **kwargs):
    '\n    generator for (image, segmentation)\n    '

    def imggen(path, ext, nb_restart_cycle=None):
        '\n        TODO: should really use the volume generators for this\n        '
        files = _get_file_list(path, ext, vol_rand_seed)
        if (nb_restart_cycle is None):
            nb_restart_cycle = len(files)
        idx = (- 1)
        while 1:
            idx = np.mod((idx + 1), nb_restart_cycle)
            im = scipy.misc.imread(os.path.join(path, files[idx]))[:, :, 0]
            (yield im.reshape(((1,) + im.shape)))
    img_gen = imggen(volpath, ext, nb_restart_cycle)
    seg_gen = imggen(segpath, ext)
    while 1:
        input_vol = np.vstack([(next(img_gen).astype('float16') / 255) for i in range(batch_size)])
        input_vol = np.expand_dims(input_vol, axis=(- 1))
        output_vols = [np_utils.to_categorical(next(seg_gen).astype('int8'), num_classes=2) for i in range(batch_size)]
        output_vol = np.vstack([np.expand_dims(f, axis=0) for f in output_vols])
        (yield (input_vol, output_vol))
generator for (image, segmentation)
def img_seg(volpath, segpath, batch_size=1, verbose=False, nb_restart_cycle=None, name='img_seg', ext='.png', vol_rand_seed=None, **kwargs):
    '\n    \n    '

    def imggen(path, ext, nb_restart_cycle=None):
        '\n        TODO: should really use the volume generators for this\n        '
        files = _get_file_list(path, ext, vol_rand_seed)
        if (nb_restart_cycle is None):
            nb_restart_cycle = len(files)
        idx = (- 1)
        while 1:
            idx = np.mod((idx + 1), nb_restart_cycle)
            im = scipy.misc.imread(os.path.join(path, files[idx]))[:, :, 0]
            (yield im.reshape(((1,) + im.shape)))
    img_gen = imggen(volpath, ext, nb_restart_cycle)
    seg_gen = imggen(segpath, ext)
    while 1:
        input_vol = np.vstack([(next(img_gen).astype('float16') / 255) for i in range(batch_size)])
        input_vol = np.expand_dims(input_vol, axis=(- 1))
        output_vols = [np_utils.to_categorical(next(seg_gen).astype('int8'), num_classes=2) for i in range(batch_size)]
        output_vol = np.vstack([np.expand_dims(f, axis=0) for f in output_vols])
        (yield (input_vol, output_vol))