PETR code note

  1. cfg = Config.fromfile(args.config)

#从args更新读取的config文件,args优先级>cfg优先级,args定义了cfg文件中没有定义的work_dir等参数,还有一部分需要覆盖cfg的参数

  1. cfg.merge_from_dict()

    合并字典到配置 通过 cfg.merge_from_dict 函数接口可以实现对字典内容进行合并,典型用法如下:

    cfg_file = osp.join(data_path, 'config/a.py')
    cfg = Config.fromfile(cfg_file)
    input_options = {'item2.a': 1, 'item2.b': 0.1, 'item3': False}
    cfg.merge_from_dict(input_options)
    
    # 原始 a.py 内容为:
    item1 = [1, 2]
    item2 = {'a': 0}
    item3 = True
    item4 = 'test'
    
    # 进行合并后, cfg 内容
    item1 = [1, 2]
    item2 = dict(a=1, b=0.1)
    item3 = False
    item4 = 'test'
  2. ```python if cfg.plugin: import importlib

​ #将plugin批量导入模型环境

​ #plugin_dir='projects/mmdet3d_plugin/'

  1. torch.backends.cudnn.benchmark = True

    对模型里的卷积层进行预先的优化,也就是在每一个卷积层中测试 cuDNN 提供的所有卷积实现算法,然后选择最快的那个。这样在模型启动的时候,只要额外多花一点点预处理时间,就可以较大幅度地减少训练时间。