最近在github上看到一個部落客開源的YOLOv7倉庫都驚呆了,YOLOv6都還沒出來怎麼就到YOLOv7了
稍微看了下,原來作者是基于這兩年來很火的transformer做的檢測和分割模型,測試的效果都非常棒,比YOLOv5效果好很多。由此可見,基于Transformer based的檢測模型才是未來。你會發現它學到的東西非常合理,比從一大堆boudingbox裡面選擇機率的範式要好一點。話不多說,先上代碼連結:https://github.com/jinfagang/yolov7
開源的YOLOv7功能很強大,支援 YOLO, DETR, AnchorDETR等等。作者聲稱發現很多開源檢測架構,比如YOLOv5、EfficientDetection都有自己的弱點。例如,YOLOv5實際上設計過度,太多混亂的代碼。更令人驚訝的是,pytorch中至少有20多個不同版本的YOLOv3-YOLOv4的重新實作,其中99.99%是完全錯誤的,你既不能訓練你的資料集,也不能使其與原paper相比。是以有了作者開源的這個倉庫!該repo 支援DETR等模型的ONNX導出,并且可以進行tensorrt推理。
該repo提供了以下的工作:
- YOLOv4 contained with CSP-Darknet53;
- YOLOv7 arch with resnets backbone;
- GridMask augmentation from PP-YOLO included;
- Mosiac transform supported with a custom datasetmapper;
- YOLOv7 arch Swin-Transformer support (higher accuracy but lower speed);
- RandomColorDistortion, RandomExpand, RandomCrop, RandomFlip;
- CIoU loss (DIoU, GIoU) and label smoothing (from YOLOv5 & YOLOv4);
- YOLOv7 Res2net + FPN supported;
- Pyramid Vision Transformer v2 (PVTv2) supported
- YOLOX s,m,l backbone and PAFPN added, we have a new combination of YOLOX backbone and pafpn;
- YOLOv7 with Res2Net-v1d backbone, we found res2net-v1d have a better accuracy then darknet53;
- Added PPYOLOv2 PAN neck with SPP and dropblock;
- YOLOX arch added, now you can train YOLOX model (anchor free yolo) as well;
- DETR: transformer based detection model and onnx export supported, as well as TensorRT acceleration;
- AnchorDETR: Faster converge version of detr, now supported!
倉庫提供了快速檢測Quick start和train自己資料集的代碼及操作流程,也提供了許多預訓練模型可供下載下傳,讀者可依據自己的需要選擇下載下傳對應的檢測模型。
快速運作demo代碼
python3 demo.py --config-file configs/wearmask/darknet53.yaml --input ./datasets/wearmask/images/val2017 --opts MODEL.WEIGHTS output/model_0009999.pth
執行個體分割
python demo.py --config-file configs/coco/sparseinst/sparse_inst_r50vd_giam_aug.yaml --video-input ~/Movies/Videos/86277963_nb2-1-80.flv -c 0.4 --opts MODEL.WEIGHTS weights/sparse_inst_r50vd_giam_aug_8bc5b3.pth
基于detectron2新推出的LazyConfig系統,使用LazyConfig模型運作
python3 demo_lazyconfig.py --config-file configs/new_baselines/panoptic_fpn_regnetx_0.4g.py --opts train.init_checkpoint=output/model_0004999.pth
訓練資料集
python train_net.py --config-file configs/coco/darknet53.yaml --num-gpus 1
如果你想訓練YOLOX,使用 config file configs/coco/yolox_s.yaml
導出 ONNX && TensorRT && TVM
detr
python export_onnx.py --config-file detr/config/file
SparseInst
python export_onnx.py --config-file configs/coco/sparseinst/sparse_inst_r50_giam_aug.yaml --video-input ~/Videos/a.flv --opts MODEL.WEIGHTS weights/sparse_inst_r50_giam_aug_2b7d68.pth INPUT.MIN_SIZE_TEST 512
具體的操作流程可以去原倉庫看,都有詳細的解析!