text stringlengths 1 93.6k |
|---|
import numpy as np
|
import yaml
|
from easydict import EasyDict as edict
|
import torch
|
import torch.nn as nn
|
import torch.nn.parallel
|
import torch.optim
|
import torch.utils.data
|
import torch.distributed as dist
|
from tensorboardX import SummaryWriter
|
from util.common_util import AverageMeter, intersectionAndUnionGPU, to_device, init_seeds
|
from util.logger import get_logger
|
from util.lr import MultiStepWithWarmup, CosineAnnealingWarmupRestarts
|
from model_architecture import PointConvFormer_Segmentation as VI_PointConv
|
from model_architecture import get_default_configs
|
import scannet_data_loader_color_DDP as scannet_data_loader
|
def get_default_training_cfgs(cfg):
|
'''
|
Get default configurations w.r.t. the training and the dataset, note that this doesn't set the model default
|
configurations that is in model_architecture.get_default_configs()
|
'''
|
# Label smoothing regularization
|
if 'label_smoothing' not in cfg.keys():
|
cfg.label_smoothing = False
|
# Accumulation iterations, i.e. the number of iterations gradients are
|
# accumulated before a parameter update is computed
|
if 'accum_iter' not in cfg.keys():
|
cfg.accum_iter = 1
|
# Random rotations augmentation
|
if 'rotate_aug' not in cfg.keys():
|
cfg.rotate_aug = True
|
# Random flip in the xy plane
|
if 'flip_aug' not in cfg.keys():
|
cfg.flip_aug = False
|
# Random scaling of the points
|
if 'scale_aug' not in cfg.keys():
|
cfg.scale_aug = True
|
# Add random noise to the point coordinates
|
if 'transform_aug' not in cfg.keys():
|
cfg.transform_aug = False
|
# Random color drop augmentation
|
if 'color_aug' not in cfg.keys():
|
cfg.color_aug = True
|
# Crop the scene to remove outliers
|
if 'crop' not in cfg.keys():
|
cfg.crop = False
|
# Random shuffle point indices
|
if 'shuffle_index' not in cfg.keys():
|
cfg.shuffle_index = True
|
# Mix3D augmentation. Engelmann et al. Mix3D: Out-of-Context Data
|
# Augmentation for 3D Scenes. 3DV 2021
|
if 'mix3D' not in cfg.keys():
|
cfg.mix3D = False
|
return cfg
|
def get_parser():
|
'''
|
Get the arguments
|
'''
|
parser = argparse.ArgumentParser('ScanNet PointConvFormer')
|
parser.add_argument(
|
'--local_rank',
|
default=-1,
|
type=int,
|
help='local_rank')
|
parser.add_argument(
|
'--config',
|
default='./configWenxuanPCFDDPL5WarmUP.yaml',
|
type=str,
|
help='config file')
|
args = parser.parse_args()
|
assert args.config is not None
|
cfg = edict(yaml.safe_load(open(args.config, 'r')))
|
# get_default_configs gets the configurations about the model architecture
|
cfg = get_default_configs(cfg, cfg.num_level, cfg.base_dim)
|
# get_default_training_configs gets the configurations about training and
|
# data augmentations
|
cfg = get_default_training_cfgs(cfg)
|
cfg.local_rank = args.local_rank
|
cfg.config = args.config
|
return cfg
|
def main_process():
|
return not args.DDP or (args.DDP and args.rank % args.num_gpus == 0)
|
def main():
|
'''
|
Main entry point for the training
|
--config specifies the config file used
|
'''
|
args = get_parser()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.