-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain_pcn.py
More file actions
70 lines (59 loc) · 2.68 KB
/
Copy pathmain_pcn.py
File metadata and controls
70 lines (59 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import argparse
import logging
import os
import numpy as np
import sys
import torch
from pprint import pprint
from config_pcn import cfg
from core.train_pcn import train_net
from core.test_pcn import test_net
from core.test import test
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = cfg.CONST.DEVICE
def set_seed(seed):
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
def get_args_from_command_line():
parser = argparse.ArgumentParser(description='The argument parser of SnowflakeNet')
parser.add_argument('--test', dest='test', help='Test neural networks', action='store_true')
parser.add_argument('--inference', dest='inference', help='Inference for benchmark', action='store_true')
args = parser.parse_args()
return args
def main():
# Get args from command line
args = get_args_from_command_line()
print('cuda available ', torch.cuda.is_available())
# Print config
print('Use config:')
pprint(cfg)
if not args.test and not args.inference:
train_net(cfg)
else:
if cfg.CONST.WEIGHTS is None:
raise Exception('Please specify the path to checkpoint in the configuration file!')
test_net(cfg)
if __name__ == '__main__':
# Check python version
parser = argparse.ArgumentParser('Point Cloud Completion Testing')
parser.add_argument('--exp_name', type=str, help='Tag of experiment')
parser.add_argument('--result_dir', type=str, default='results', help='Results directory')
parser.add_argument('--ckpt_path', type=str, help='The path of pretrained model.')
parser.add_argument('--category', type=str, default='all', help='Category of point clouds')
parser.add_argument('--batch_size', type=int, default=1, help='Batch size for data loader')
parser.add_argument('--num_workers', type=int, default=8, help='Num workers for data loader')
parser.add_argument('--device', type=str, default='cuda:0', help='Device for testing')
parser.add_argument('--novel', type=bool, default=False, help='unseen categories for testing')
parser.add_argument('--test_point_num', type=int, default=2048, help='number of point cloud when testing')
parser.add_argument('--test', type=bool, default=False, help='number of point cloud when testing')
parser.add_argument('--test_dataset_path', type=str, default='/mnt/data/PCN', help='number of point cloud when testing')
params = parser.parse_args()
if params.test:
test(params)
else:
seed = 1
set_seed(seed)
logging.basicConfig(format='[%(levelname)s] %(asctime)s %(message)s', level=logging.DEBUG)
main()