Beispiel #1
0
def write_dets_results(res, data_id, save_path, dataset):
    batch_size, win_size, max_dets, _ = res.shape
    classes = dataset.object_cfg.classes
    with open(save_path, 'a+') as f:
        for b in range(batch_size):
            for w in range(win_size):
                for d in range(max_dets):
                    cla_id = int(res[b, w, d, 0])
                    if cla_id == -1:
                        continue
                    row_id = res[b, w, d, 1]
                    col_id = res[b, w, d, 2]
                    conf = res[b, w, d, 3]
                    f.write("%d %s %d %d %s\n" % (data_id + w, get_class_name(cla_id, classes), row_id, col_id, conf))
Beispiel #2
0
def write_dets_results_single_frame(res, data_id, save_path, dataset):
    max_dets, _ = res.shape
    classes = dataset.object_cfg.classes
    with open(save_path, 'a+') as f:
        for d in range(max_dets):
            cla_id = int(res[d, 0])
            if cla_id == -1:
                continue
            row_id = res[d, 1]
            col_id = res[d, 2]
            conf = res[d, 3]
            f.write(
                "%d %s %d %d %.4f\n" % (data_id, get_class_name(
                    cla_id, classes), row_id, col_id, conf))
Beispiel #3
0
def write_dets_results_single_frame(res, data_id, save_path, dataset):
    max_dets, _  = res.shape
    classes = dataset.object_cfg.classes
    with open(save_path, 'a+') as f:
        for d in range(max_dets):
            cla_id = int(res[d, 0])
            if cla_id == -1:
                continue
            row_id = res[d, 1]
            col_id = res[d, 2]
            conf = res[d, 3]
            rid = int(row_id)
            aid =  int(col_id)
            rng, azm = idx2ra(rid, aid, dataset.range_grid, dataset.angle_grid)
            f.write("%d %f %f %s %s\n" % (data_id , rng, azm, get_class_name(cla_id, classes), conf))
Beispiel #4
0
def visualize_test_img(fig_name,
                       img_path,
                       input_radar,
                       confmap_pred,
                       confmap_gt,
                       res_final,
                       dataset,
                       viz=False,
                       sybl=False):
    max_dets, _ = res_final.shape
    classes = dataset.object_cfg.classes

    img_data = mpimg.imread(img_path)
    if img_data.shape[0] > 864:
        img_data = img_data[:img_data.shape[0] // 5 * 4, :, :]

    fig.add_subplot(2, 2, 1)
    plt.imshow(img_data.astype(np.uint8))
    plt.axis('off')
    plt.title("Image")

    fig.add_subplot(2, 2, 2)
    plt.imshow(input_radar, origin='lower', aspect='auto')
    plt.axis('off')
    plt.title("RA Heatmap")

    fig.add_subplot(2, 2, 3)
    confmap_pred = np.transpose(confmap_pred, (1, 2, 0))
    confmap_pred[confmap_pred < 0] = 0
    confmap_pred[confmap_pred > 1] = 1
    plt.imshow(confmap_pred, vmin=0, vmax=1, origin='lower', aspect='auto')
    for d in range(max_dets):
        cla_id = int(res_final[d, 0])
        if cla_id == -1:
            continue
        row_id = res_final[d, 1]
        col_id = res_final[d, 2]
        conf = res_final[d, 3]
        conf = 1.0 if conf > 1 else conf
        cla_str = get_class_name(cla_id, classes)
        if sybl:
            text = symbols[cla_str]
            plt.text(col_id,
                     row_id + 3,
                     text,
                     fontproperties=fp,
                     color='white',
                     size=20,
                     ha="center")
        else:
            plt.scatter(col_id, row_id, s=10, c='white')
            text = cla_str + '\n%.2f' % conf
            plt.text(col_id + 5, row_id, text, color='white', fontsize=10)
    plt.axis('off')
    plt.title("RODNet Detection")

    fig.add_subplot(2, 2, 4)
    confmap_gt = np.transpose(confmap_gt, (1, 2, 0))
    plt.imshow(confmap_gt, vmin=0, vmax=1, origin='lower', aspect='auto')
    plt.axis('off')
    plt.title("Ground Truth")

    plt.savefig(fig_name)
    if viz:
        plt.pause(0.1)
    plt.clf()