-
Notifications
You must be signed in to change notification settings - Fork 81
/
train_pointgroup.py
44 lines (37 loc) · 1.16 KB
/
train_pointgroup.py
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
import open3d as o3d
import sys
import os
from multiprocessing import cpu_count
import argparse
import torch
from torch import optim
from torch.utils import data
import numpy as np
import yaml
import glob
import random
code_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(code_dir)
sys.path.append(f'{code_dir}/PointGroup')
from trainer_pointgroup import *
from Utils import *
if __name__ == '__main__':
code_dir = os.path.dirname(os.path.realpath(__file__))
cfg_dir = '{}/config/config_pointgroup.yaml'.format(code_dir)
with open(cfg_dir, 'r') as ff:
cfg = yaml.safe_load(ff)
random_seed = cfg['random_seed']
np.random.seed(random_seed)
random.seed(random_seed)
torch.manual_seed(random_seed)
torch.cuda.manual_seed_all(random_seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
code_dir = os.path.dirname(os.path.realpath(__file__))
save_dir = f'{code_dir}/logs/{cfg["class_name"]}_seg'
os.system('rm -rf {} && mkdir -p {}'.format(save_dir,save_dir))
cfg['save_dir'] = save_dir
with open(f'{save_dir}/config_pointgroup.yaml','w') as ff:
yaml.safe_dump(cfg,ff)
trainer = TrainerPointGroup(cfg)
trainer.train()