Exemplo n.º 1
0
def prepare(dataset, epochs, batch_size, base_path):
    get_masks = load_masks(dataset, base_path)

    stream = ds.epochs(dataset.image_ids, epochs)
    stream = ds.stream(lambda x: (dataset.load_image(x), get_masks(x)), stream)

    stream = ds.bufferize(stream, size=batch_size)
    batch = ds.stream_batch(stream, size=batch_size, fun=ds.pack_elements)

    return batch
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
Exemplo n.º 3
0
def prepare(dataset, epochs, batch_size, input_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_xn(ds.resize(input_shape[:2])), stream)
    #  stream = ds.stream(ds.apply_to_x(check), stream)

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

    batch = ds.stream_batch(stream, size=batch_size)
    batch = ds.stream(
        ds.apply_to_y(lambda x: ds.mask2image(x).reshape(x.shape + (1, ))),
        batch)

    return batch
Exemplo n.º 4
0
def prepare(dataset, input_shape, output_shape):
    stream = ds.epochs(dataset.image_ids, epochs=1)
    stream = ds.stream(
        lambda x: (dataset._img_filenames[x], (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(dataset, output_shape)),
                       stream)

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

    batch = ds.stream_batch(stream, size=10, fun=ds.pack_elements)
    #  batch = ds.stream(ds.apply_to_y(check), batch)
    batch = ds.stream(
        ds.apply_to_y(ds.apply_to_xn(lambda x: ds.image2mask(x))), batch)

    return batch