yolov5参数解析 |
您所在的位置:网站首页 › tdp50参数 › yolov5参数解析 |
文章目录
一、模型配置文件二、超参文件三、运行过程参数解析3.1 `train.py`参数解析3.2 `detact.py`参数解析3.3 `val.py`参数解析
五、添加注意力机制
yolov5s:
img 640,adam,epoch300,obj.yaml时,40epoch内都在0.45-0.6震荡。改为voc.yaml和sgd,epoch=100时,后期0.7-0.73震荡 yolov5x:img=256.obj.yaml,0.75-0.8震荡。cache貌似没什么用
Class Images Instances P R mAP50 mAP50-95: 100% 7/7 [00:03=1.12.0的单GPU YOLOv5训练现在完全可再现local_rank:DistributedDataParallel 单机多卡训练,单GPU设备不需要设置entity:在线可视化工具wandbupload_dataset:是否上传dataset到wandb tabel,默认False 启用后,将数据集作为交互式 dsviz表 在浏览器中查看、查询、筛选和分析数据集bbox_interval:设置界框图像记录间隔 Set bounding-box image logging interval for W&B 默认-1artifact_alias:使用数据的版本
3.2 detact.py参数解析
下面是推理脚本detect.py的参数: def parse_opt(): parser = argparse.ArgumentParser() parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'yolov5s.pt', help='model path or triton URL') parser.add_argument('--source', type=str, default=ROOT / 'data/images', help='file/dir/URL/glob/screen/0(webcam)') parser.add_argument('--data', type=str, default=ROOT / 'data/coco128.yaml', help='(optional) dataset.yaml path') parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w') parser.add_argument('--conf-thres', type=float, default=0.25, help='confidence threshold') parser.add_argument('--iou-thres', type=float, default=0.45, help='NMS IoU threshold') parser.add_argument('--max-det', type=int, default=1000, help='maximum detections per image') parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu') parser.add_argument('--view-img', action='store_true', help='show results') parser.add_argument('--save-txt', action='store_true', help='save results to *.txt') parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels') parser.add_argument('--save-crop', action='store_true', help='save cropped prediction boxes') parser.add_argument('--nosave', action='store_true', help='do not save images/videos') parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --classes 0, or --classes 0 2 3') parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS') parser.add_argument('--augment', action='store_true', help='augmented inference') parser.add_argument('--visualize', action='store_true', help='visualize features') parser.add_argument('--update', action='store_true', help='update all models') parser.add_argument('--project', default=ROOT / 'runs/detect', help='save results to project/name') parser.add_argument('--name', default='exp', help='save results to project/name') parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)') parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels') parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences') parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference') parser.add_argument('--dnn', action='store_true', help='use OpenCV DNN for ONNX inference') parser.add_argument('--vid-stride', type=int, default=1, help='video frame-rate stride') opt = parser.parse_args() opt.imgsz *= 2 if len(opt.imgsz) == 1 else 1 # expand print_args(vars(opt)) return opt source:测试集文件/文件夹data:配置文件路径,和train.py里面的data是一样的conf-thres:置信度的阈值 超过这个阈值的预测框就会被预测出来。比如conf-thres参数依次设置成“0”, “0.25”,“0.8”![]() ![]() NMS步骤: 对 BBox 按置信度排序,选取置信度最高的 BBox(所以一开始置信度最高的 BBox 一定会被留下来);对剩下的 BBox 和已经选取的 BBox 计算 IOU,淘汰(抑制) IOU 大于设定阈值的 BBox(在图例中这些淘汰的 BBox 的置信度被设定为0)。重复上述两个步骤,直到所有的 BBox 都被处理完,这时候每一轮选取的 BBox 就是最后结果。 iou-thres=0.5时,NMS 只运行了两轮就选取出最终结果:第一轮选择了红色 BBox,淘汰了粉色 BBox;第二轮选择了黄色 BBox,淘汰了紫色 BBox 和青色 BBox。![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() val.py的作用: 我们在训练结束后会打印出每个类别的一些评价指标,但是如果当时忘记记录,那么我们就可以通过这个文件再次打印这些评价指标可以打印出测试集评价指标,测试集的图片也是需要标注的。 def parse_opt(): parser = argparse.ArgumentParser() parser.add_argument('--data', type=str, default=ROOT / 'data/coco128.yaml', help='dataset.yaml path') parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'yolov5s.pt', help='model path(s)') parser.add_argument('--batch-size', type=int, default=32, help='batch size') parser.add_argument('--imgsz', '--img', '--img-size', type=int, default=640, help='inference size (pixels)') parser.add_argument('--conf-thres', type=float, default=0.001, help='confidence threshold') parser.add_argument('--iou-thres', type=float, default=0.6, help='NMS IoU threshold') parser.add_argument('--max-det', type=int, default=300, help='maximum detections per image') parser.add_argument('--task', default='val', help='train, val, test, speed or study') parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu') parser.add_argument('--workers', type=int, default=8, help='max dataloader workers (per RANK in DDP mode)') parser.add_argument('--single-cls', action='store_true', help='treat as single-class dataset') parser.add_argument('--augment', action='store_true', help='augmented inference') parser.add_argument('--verbose', action='store_true', help='report mAP by class') parser.add_argument('--save-txt', action='store_true', help='save results to *.txt') parser.add_argument('--save-hybrid', action='store_true', help='save label+prediction hybrid results to *.txt') parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels') parser.add_argument('--save-json', action='store_true', help='save a COCO-JSON results file') parser.add_argument('--project', default=ROOT / 'runs/val', help='save to project/name') parser.add_argument('--name', default='exp', help='save to project/name') parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference') parser.add_argument('--dnn', action='store_true', help='use OpenCV DNN for ONNX inference') opt = parser.parse_args() opt.data = check_yaml(opt.data) # check YAML opt.save_json |= opt.data.endswith('coco.yaml') opt.save_txt |= opt.save_hybrid print_args(vars(opt)) return opt前六个参数和detect.py意义一样。 task:可以是train, val, test。比如:python val.py --task test表示打印测试集指标augment:测试是否使用TTA Test Time Augment,指定这个参数后各项指标会明显提升几个点。verbose:是否打印出每个类别的mAP,默认False。save-hybrid:将标签+预测混合结果保存到 .txtsave-json:是否按照coco的json格式保存预测框,并且使用cocoapi做评估(需要同样coco的json格式的标签) 默认Falsehalf:是否使用半精度推理 默认False其它参数内容同detect.py。 五、添加注意力机制 参考《手把手带你Yolov5 (v6.1)添加注意力机制(一)(并附上30多种顶会Attention原理图)》参考《手把手带你Yolov5 (v6.1)添加注意力机制(二)(在C3模块中加入注意力机制)》 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 98/99 3.81G 0.03403 0.0175 0.002002 72 256: 100% 75/75 [00:29 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |