Exemplo n.º 1
0
            interpolated_prob, axis=-1)  # (batch_size,)

    interpolated_common_label = _2common(interpolated_label,
                                         from_dataset)  # (N1,)
    interpolated_color = _label_to_colors_by_name(interpolated_label,
                                                  from_dataset)  # (N1, 3)
    interpolated_common_color = _label_to_colors_by_name(
        interpolated_common_label, 'common')  # (N1, 3)
    del interpolated_common_label

    # evaluate interpolation result if ground truth is available
    raw_label_path = os.path.join(raw_folder, fname_without_ext + '.labels')
    if from_dataset == to_dataset and os.path.exists(raw_label_path):
        label_gt = load_labels(raw_label_path)  # (N1,)
        ConfusionMatrix = ConfusionMatrix(num_classes)
        ConfusionMatrix.increment_from_list(label_gt.flatten(),
                                            interpolated_label.flatten())
        ConfusionMatrix.print_metrics()

    label_path = os.path.join(dense_folder, fname_without_ext + '.labels')
    np.savetxt(label_path, interpolated_label, fmt="%d")
    del interpolated_label
    print('writing labels for %s' % fname_without_ext)

    # output pcd with from_dataset label
    dense_pcd = open3d.geometry.PointCloud()
    dense_pcd.points = open3d.utility.Vector3dVector(raw_points)
    dense_pcd.colors = open3d.utility.Vector3dVector(interpolated_color)
    del interpolated_color
    dense_pcd_path = os.path.join(
        dense_folder, fname_without_ext + '_' + from_dataset + '.pcd')
    open3d.io.write_point_cloud(dense_pcd_path, dense_pcd)
Exemplo n.º 2
0
                                         global_step=global_step)
            print("Batch size: {}, time: {}".format(current_batch_size,
                                                    time.time() - s))

            common_gt = _2common(gt_labels, flags.to_dataset)  # (B, N)
            common_pd = _2common(pd_labels, flags.from_dataset)  # (B, N)

            # Save to collector for file output
            points_collector.extend(points)  # (B, N, 3)
            pd_labels_collector.extend(pd_labels)  # (B, N)
            pd_common_labels_collector.extend(common_pd)  # (B, N)
            pd_prob_collector.extend(pd_prob)  # (B, N, num_classes)

            # Increment confusion matrix

            common_cm.increment_from_list(common_gt.flatten(),
                                          common_pd.flatten())
            if flags.from_dataset == flags.to_dataset:
                cm.increment_from_list(gt_labels.flatten(),
                                       pd_labels.flatten())

        # Save sparse point cloud and predicted labels
        file_prefix = os.path.basename(file_data.file_path_without_ext)

        sparse_points = np.array(points_collector).reshape((-1, 3))  # (B*N, 3)
        sparse_common_labels = np.array(
            pd_common_labels_collector).flatten()  # (B*N,)
        pcd_common = open3d.geometry.PointCloud()
        pcd_common.points = open3d.utility.Vector3dVector(sparse_points)
        pcd_common.colors = open3d.utility.Vector3dVector(
            _label_to_colors_by_name(sparse_common_labels, 'common'))
        pcd_path = os.path.join(output_dir, file_prefix + "_common.pcd")