关于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
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 | 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)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律