def get_dataset(dataset, epochs, input_shape, output_shape, colored=True):
    shapes = ds.epochs(dataset, epochs)
    shapes = ds.stream(
        ds.apply_to_x(
            ds.apply_to_xn(lambda x: ds.colorize(
                cv2.imread(x[0]), x[1] if colored else [255, 0, 0]))), shapes)
    #  shapes = ds.stream(ds.apply_to_x(check), shapes)
    shapes = ds.stream(ds.apply_to_x(sum), shapes)
    shapes = ds.stream(ds.apply_to_x(lambda x: cv2.resize(x, input_shape[:2])),
                       shapes)
    shapes = ds.stream(
        ds.apply_to_y(lambda x: to_categorical(x, output_shape)), shapes)
    shapes = ds.stream_batch(
        shapes, lambda x, y: [np.array(x), np.array(y)], batch_size)
    return shapes
예제 #2
0
def get_dataset(filenames, epochs, colorMap, batch_size, output_shape):
    shapes = load_shapes(ds.epochs(filenames, epochs), colorMap)
    shapes = ds.stream(ds.apply_to_x(lambda x: cv2.resize(x, input_shape[:2])),
                       shapes)
    shapes = ds.stream(
        ds.apply_to_y(lambda x: to_categorical(x, output_shape)), shapes)
    shapes = ds.stream_batch(
        shapes, lambda x, y: [np.array(x), np.array(y)], batch_size)
    return shapes
def prepare(dataset, epochs, batch_size, input_shape, base_path):
    lm = load_masks(dataset, base_path)
    stream = ds.epochs(dataset.image_ids, epochs)
    stream = ds.stream(lambda x: (dataset.load_image(x), lm(x)), stream)
    stream = ds.stream(ds.apply_to_x(ds.resize(input_shape)), stream)

    batch = ds.stream_batch(stream,
                            size=batch_size,
                            fun=lambda x, y: (np.array(x), fix_y(y)))

    return batch
예제 #4
0
def get_dataset(filenames, relations, epochs, colorMap, batch_size,
                input_shape, output_shape):
    shapes = load_shapes(ds.epochs(filenames, epochs), relations, colorMap)
    shapes = ds.stream(ds.apply_to_x(lambda x: cv2.resize(x, input_shape[:2])),
                       shapes)
    shapes = ds.stream(
        ds.apply_to_y(lambda x: np.array(
            [to_categorical(xv, output_shape) for xv in x]).sum(axis=0)),
        shapes)
    shapes = ds.stream_batch(
        shapes,
        lambda x, y: [np.array(x), generate_y(np.array(y))], batch_size)
    return shapes
def prepare(dataset, epochs, batch_size, input_shape, output_shape):
    stream = ds.epochs(dataset.image_ids, epochs)
    stream = ds.stream(
        lambda x: (dataset.load_image(x), dataset.load_output(x)),
        stream)
    stream = ds.stream(ds.apply_to_x(ds.resize(input_shape)), stream)
    stream = ds.stream(ds.apply_to_y(resize_all(output_shape)), stream)

    stream = ds.bufferize(stream, size=20)

    batch = ds.stream_batch(stream, size=batch_size, fun=ds.pack_elements)
    batch = ds.stream(ds.apply_to_y(ds.apply_to_xn(
        lambda x: ds.image2mask(x).reshape(x.shape + (1,)))), batch)

    return batch
def get_dataset(filenames, relations, epochs, colorMap, batch_size,
                input_shape, output_shape):
    shapes = load_shapes(ds.epochs(filenames, epochs), relations, colorMap)
    shapes = ds.stream(ds.apply_to_x(lambda x: cv2.resize(x, input_shape[:2])),
                       shapes)
    #  def fu(x):
    #      ba = list(np.array(
    #          [to_categorical(xv, output_shape) for xv in x]
    #      ).sum(axis=0))
    #      import ipdb; ipdb.set_trace()
    #      return ba
    shapes = ds.stream(
        ds.apply_to_y(lambda x: np.array(
            [to_categorical(xv, output_shape) for xv in x]).sum(axis=0)),
        shapes)
    shapes = ds.stream(ds.apply_to_y(generate_neg), shapes)
    shapes = ds.stream_batch(
        shapes, lambda x, y: [np.array(x), np.array(y)], batch_size)
    return shapes