コード例 #1
0
    'latent_nn', 'chamfer_nn_complete'
], 'wrong target_pc_idx_type: %s' % flags.target_pc_idx_type

# define basic parameters
top_out_dir = osp.dirname(osp.dirname(
    osp.abspath(__file__)))  # Use to save Neural-Net check-points etc.
data_path = osp.join(top_out_dir, flags.ae_folder, 'eval')
files = [
    f for f in os.listdir(data_path) if osp.isfile(osp.join(data_path, f))
]

output_path = create_dir(osp.join(data_path, flags.output_folder_name))

# load data
point_clouds, latent_vectors, pc_classes, slice_idx, ae_loss = \
    load_data(data_path, files, ['point_clouds_test_set', 'latent_vectors_test_set', 'pc_classes', 'slice_idx_test_set', 'ae_loss_test_set'])

assert np.all(
    ae_loss > 0
), 'Note: not all autoencoder loss values are larger than 0 as they should!'

nn_idx_dict = {
    'latent_nn': 'latent_nn_idx_test_set',
    'chamfer_nn_complete': 'chamfer_nn_idx_complete_test_set'
}
nn_idx = load_data(data_path, files, [nn_idx_dict[flags.target_pc_idx_type]])

correct_pred = None
if flags.correct_pred_only:
    pc_labels, pc_pred_labels = load_data(
        data_path, files, ['pc_label_test_set', 'pc_pred_labels_test_set'])
コード例 #2
0
                 'defense_configuration'))
elif flags.data_type == 'after_defense':
    conf = Conf.load(osp.join(classifier_data_path, 'defense_configuration'))
else:
    assert False, 'wrong data_type: %s' % flags.data_type

# update classifier configuration
conf.classifier_path = classifier_path
conf.classifier_restore_epoch = flags.classifier_restore_epoch
conf.classifier_data_path = classifier_data_path

conf.save(osp.join(output_path, 'classifier_configuration'))

# load data
point_clouds, pc_classes, slice_idx, reconstructions = \
    load_data(data_path, files, ['point_clouds_test_set', 'pc_classes', 'slice_idx_test_set', 'reconstructions_test_set'])

nn_idx_dict = {
    'latent_nn': 'latent_nn_idx_test_set',
    'chamfer_nn_complete': 'chamfer_nn_idx_complete_test_set'
}
nn_idx = load_data(data_path, files, [nn_idx_dict[conf.target_pc_idx_type]])

correct_pred = None
if conf.correct_pred_only:
    pc_labels, pc_pred_labels = load_data(
        data_path, files, ['pc_label_test_set', 'pc_pred_labels_test_set'])
    correct_pred = (pc_labels == pc_pred_labels)

# load indices for attack
attack_pc_idx = np.load(osp.join(top_out_dir, flags.attack_pc_idx))
コード例 #3
0
                    help="Batch size of source point clouds [default: 100]")

flags = parser.parse_args()

print('Prepare indices flags:', flags)

# define basic parameters
project_dir = osp.dirname(osp.dirname(osp.abspath(__file__)))
data_path = create_dir(osp.join(project_dir, flags.ae_folder, 'eval'))
files = [
    f for f in os.listdir(data_path) if osp.isfile(osp.join(data_path, f))
]

# load data
point_clouds, latent_vectors, pc_classes, slice_idx = \
    load_data(data_path, files, ['point_clouds_test_set', 'latent_vectors_test_set', 'pc_classes', 'slice_idx_test_set'])

show = False
if show:
    n = 0
    plot_3d_point_cloud(point_clouds[n])

slice_idx_file_name = [f for f in files if 'slice_idx_test_set' in f][0]
file_name_parts = slice_idx_file_name.split('_')

# constants
num_classes = len(pc_classes)
range_num_classes = range(num_classes)

# reproducibility
seed = 55