def reconstruct(pc_data, conf, batch_size): n_examples = pc_data.num_examples n_batch = n_examples/batch_size result = list() for _ in xrange(n_batch): feed_pc, feed_model_names, _ = pc_data.next_batch(batch_size) if z_rotate == 'True': feed_pc = apply_augmentations(feed_pc, conf) rec, _ = ae.reconstruct(feed_pc) result.append(rec) result = np.concatenate(result, axis=0) return result
test_step = 200 ) # How often to evaluate/print out loss on held_out data (if any). # epochs conf.save(osp.join(train_dir, 'configuration')) reset_tf_graph() ae = PointNetAutoEncoder(conf.experiment_name, conf) buf_size = 1 # flush each line fout = open(osp.join(conf.train_dir, 'train_stats.txt'), 'a', buf_size) train_stats = ae.train(train_pc, conf, log_file=fout, val_data=val_pc, test_data=test_pc) fout.close() print('On train hidden transform') train_hidden, _, _ = train_pc.full_epoch_data() train_hidden = apply_augmentations(train_hidden, conf) train_hidden = ae.transform(train_hidden) np.save(osp.join(train_dir, 'hidden.npy'), train_hidden) print('On val hidden transform') val_hidden, _, _ = val_pc.full_epoch_data() val_hidden = apply_augmentations(val_hidden, conf) val_hidden = ae.transform(val_hidden) np.save(osp.join(val_dir, 'hidden.npy'), val_hidden) print('On test hidden transform') test_hidden, _, _ = test_pc.full_epoch_data() test_hidden = apply_augmentations(test_hidden, conf) test_hidden = ae.transform(test_hidden) np.save(osp.join(test_dir, 'hidden.npy'), test_hidden)
from latent_3d_points.src.general_utils import apply_augmentations from latent_3d_points.src.load_ae_model import load as load_ae, unpickle_pc_file, get_feed_data model_path = sys.argv[1] # mode namel, e.g. path single_class_ae_plane_chamfer_zrotate pc_file = sys.argv[2] z_rotate = sys.argv[3] # 'True' or 'False' num_points = int(sys.argv[4]) ae, conf = load_ae(model_path, z_rotate, num_points) pc_data = unpickle_pc_file(pc_file) feed = get_feed_data(pc_data, conf) hidden = ae.transform(feed) reconstr, _ = ae.reconstruct(feed) file_idx = 0 for _ in xrange(100): feed_pc, feed_model_names, _ = pc_data.next_batch(1) if z_rotate == 'True': feed_pc = apply_augmentations(feed_pc, conf) fake_pc, _ = ae.reconstruct(feed_pc) for real, fake in zip(feed_pc, fake_pc): np.savetxt(os.path.join(save_dir, "{0}_{1}_{2}".format(class_name, file_idx, "real")), real, delimiter=",") np.savetxt(os.path.join(save_dir, "{0}_{1}_{2}".format(class_name, file_idx, "fake")), fake, delimiter=",") file_idx += 1
def get_feed_data(pc_data, conf): data, _, _ = pc_data.full_epoch_data(shuffle=False) feed = apply_augmentations(data, conf) return feed