Пример #1
0
def save_result(train_image, train_polygon, train_y_coords, filepath):
    # Image with polygons overlaid
    im_res = train_image.shape[0]
    image = (train_image - INPUT_DYNAMIC_RANGE[0]) / (INPUT_DYNAMIC_RANGE[1] -
                                                      INPUT_DYNAMIC_RANGE[0])
    train_polygon = train_polygon * im_res
    train_y_coords = train_y_coords * im_res
    plt.cla()
    fig = plt.imshow(image)
    polygon_utils.plot_polygon(train_polygon,
                               color="#28ff0288",
                               draw_labels=False)
    polygon_utils.plot_polygon(train_y_coords,
                               color="#ff8800",
                               draw_labels=False)
    plt.margins(0)
    plt.axis('off')
    fig.axes.get_xaxis().set_visible(False)
    fig.axes.get_yaxis().set_visible(False)
    plt.savefig(filepath + ".png", bbox_inches='tight', pad_inches=0)
    # Save polygons
    train_polygon_array = np.array(train_polygon, dtype=np.float16)
    train_y_coords_array = np.array(train_y_coords, dtype=np.float16)
    np.save(filepath + ".gt.npy", train_polygon_array)
    np.save(filepath + ".pred.npy", train_y_coords_array)
Пример #2
0
 def plot_polygons(polygons, color):
     # print("plot_polygons(polygons, color)")  # TODO: remove
     for i, polygon in enumerate(polygons):
         # Remove coordinates after nans
         indexes_of_nans = np.where(np.isnan(polygon[:, 0]))[0]
         if len(indexes_of_nans):
             polygon_nans_crop = polygon[:indexes_of_nans[-1], :]
             polygon_utils.plot_polygon(polygon_nans_crop, color=color, draw_labels=False, indexing="ij")
         else:
             polygon_utils.plot_polygon(polygon, color=color, draw_labels=False, indexing="ij")
Пример #3
0
def plot_results(figure_index, image_batch, polygon_batch, y_image_batch):
    im_res = image_batch[0].shape[0]
    image = (image_batch[0] - INPUT_DYNAMIC_RANGE[0]) / (
        INPUT_DYNAMIC_RANGE[1] - INPUT_DYNAMIC_RANGE[0])
    y_image = y_image_batch[0]
    train_polygon = polygon_batch[0] * im_res
    plt.figure(figure_index)
    plt.cla()
    plt.imshow(image)
    plt.imshow(y_image[:, :, 0], alpha=0.5, cmap="gray")
    polygon_utils.plot_polygon(train_polygon, label_direction=1)
    plt.draw()
    plt.pause(0.001)
Пример #4
0
def plot_results(figure_index, train_image_batch, train_polygon_batch,
                 train_y_coords_batch):
    im_res = train_image_batch[0].shape[0]
    image = (train_image_batch[0] - INPUT_DYNAMIC_RANGE[0]) / (
        INPUT_DYNAMIC_RANGE[1] - INPUT_DYNAMIC_RANGE[0])
    train_polygon = train_polygon_batch[0] * im_res
    train_y_coords = train_y_coords_batch[0] * im_res
    plt.figure(figure_index)
    plt.cla()
    plt.imshow(image)
    polygon_utils.plot_polygon(train_polygon, label_direction=1)
    polygon_utils.plot_polygon(train_y_coords, label_direction=-1)
    plt.draw()
    plt.pause(0.001)
Пример #5
0
    # The op for initializing the variables.
    init_op = tf.group(tf.global_variables_initializer(),
                       tf.local_variables_initializer())

    with tf.Session() as sess:

        sess.run(init_op)

        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)

        # Let's read off 3 batches just for example
        for i in range(1):
            imgs, polys, raster_polys = sess.run(
                [image, polygon, raster_polygon])
            print(imgs.min(), imgs.max())
            print(polys.min(), polys.max())
            print(raster_polys.min(), raster_polys.max())

            for img, poly, raster_poly in zip(imgs, polys, raster_polys):
                img = (img - dynamic_range[0]) / (dynamic_range[1] -
                                                  dynamic_range[0])
                poly = poly * im_res
                io.imshow(img)
                io.imshow(raster_poly[:, :, 0], alpha=0.5, cmap="gray")
                polygon_utils.plot_polygon(poly, label_direction=1)
                io.show()

        coord.request_stop()
        coord.join(threads)