关于mmdection一些问题
- 不同数据集的evaluation配置不同
# evaluation = dict(interval=1, metric='bbox') //coco格式
# evaluation = dict(interval=1, metric='mAP') //voc格式 - 数据集的图片格式问题
在mmdet/datasets/xml_style.py下更改jpg或者png等格式
- 数据集labels_name
mmdet/datasets/voc.py文件下更改成自定义数据集的label_name
模型的配置文件中更改类别数量
mmdet/core/evaluation/class_names.py文件中对应的数据格式,改成自己数据集的label_name
- tools工具箱下的可视化使用方法
python analyze_logs.py plot_curve log.json --keys loss_cls --legend loss_cls
python analyze_logs.py plot_curve log.json --keys loss_cls loss_bbox --out losses.pdf
python analyze_logs.py plot_curve log.json log2.json --keys loss_bbox --legend run1 run2
python analyze_logs.py plot_curve log.json log2.json --keys bbox_mAP --legend run1 run2
python analyze_logs.py cal_train_time log.json --include-outliers
此外,必须先test_robustness.py,然后才能robustness_eval.py
- 使用tools下的数据集转换工具
mmdet/core/evaluation/class_names.py中voc_name()修改为自己数据集的labels_name
下面这段代码是用来生成train、val
import os # 定义VOC文件存放的路径 xml_dir = r'annotations' img_dir = r'images' train_txt_path = r'train.txt' valid_txt_path = r'val.txt' label_list_txt_path = r'label_list.txt' # 读取标注文件 xml_files = os.listdir(xml_dir) print('数据集含有 ' + str(len(xml_files)) + '张图片') # 训练集和测试集占比 radio = 0.8 trainset = xml_files[:int(radio*len(xml_files))] validset = xml_files[int(radio*len(xml_files)):] with open(train_txt_path, 'w') as f: #for i in trainset: # img_path = './images/'+ i[:-4] + '.png' #xml_path = './annotations/'+ i #text = img_path + ' ' + xml_path + '\n' #f.write(text) for i in trainset: #img_path = i[:-4]+ '\n' #xml_path = './annotations/'+ i xml_path = i+'\n' text = xml_path f.write(text) f.close() print('生成train.txt完毕...') with open(valid_txt_path, 'w') as f: for i in validset: img_path = i[:-4]+ '\n' #xml_path = './annotations/'+ i xml_path = i+'\n' text = xml_path f.write(text) #for i in validset: #img_path = './images/'+ i[:-4] + '.png' # xml_path = './annotations/'+ i #text = img_path + ' ' + xml_path + '\n' #f.write(text) f.close() print('生成valid.txt完毕...') labels = ['helmet', 'head'] with open(label_list_txt_path, 'w') as f: for label in labels: f.write(label+'\n') f.close() print('生成label_list.txt完毕...')
使用tools/benchmark.py开启分布式出错,在py文件开头加入:
os.environ['RANK']='0' # os.environ['local_rank']='0' os.environ['WORLD_SIZE']='1' os.environ['MASTER_ADDR'] = 'localhost' os.environ['MASTER_PORT'] = '5678' # dist.init_process_group(backend='nccl', init_method='env://', rank = 0, world_size = 1)