WBF (Weighted-Boxes-Fusion) is the method combining predictions of object detection models.
Original paper: Weighted boxes fusion: Ensembling boxes from different object detection models (Image and Vision Computing, 2021)
This is repository for implementing bounding box ensemble method (weighted-boxes-fusion) with multiple detection models (YOLOv4 and YOLOv5). The overall process for using weighted-boxes-fusion method is described in below section. If you have an issue of using my code, please make issue on my repo. If my repo could help you, your one star can help me a lot. Thanks
And note that this repo was created for the purpose of participating in the hackathon competition. (Competition info: Illegal object detection part from Busan metropolitan City artificial intelligence model competition)
pip install -r requirements.txt
cd ROOT
conda env create -f test_env.yaml
Weighted-Boxes-Fusion-implementation
you can organize your dataset folder with this cite (https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data)
cd ROOT/model/yolov4 # ROOT is the root directory of your project
python train.py --weights yolov4.weight --data v4_data/custon.yaml
cd ROOT/model/yolov5
python train.py --weights yolov5s.pt --data data/custon.yaml
If you want to test wbf result with your models, please put the weight file of your model in the wbf folders.
Also, change the configuration.yaml in ROOT folder.
In configuration.yaml, you must change the path and name of your models and dataset.
Or you can test your model with command line like below command with your model and dataset path.
python test.py --data your_yamlpath.yaml --model2_weight weight_path_of_model2 --model1_weight weight_path_of_model1 --model2_cfg cfg_path_of_model2
if you want to check my result with hackathon dataset, please follow the below direction.
and put the yolov4 weight in ROOT/model/yolov4/weights put the yolov5 weight in ROOT/model/yolov5
cd ROOT
python test.py --data dataset/custon.yaml --model2_weight model/yolov4/weights/v4_best.pt --model1_weight model/yolov5/v5_best.pt --model2_cfg model/yolov4/cfg/yolov4-pacsp-x.cfg
Precision | Recall | $mAP0.5 | $mAP0.5 - 0.95 | |
---|---|---|---|---|
YOLOv4 | 0.5261 | 0.8096 | 0.696 | 0.5838 |
YOLOv5 | 0.6018 | 0.7129 | 0.5344 | 0.6673 |
Ensemble | 0.8158 | 0.8988 | 0.9192 | 0.8184 |
Weighted-boxes-fusion: https://github.com/ZFTurbo/Weighted-Boxes-Fusion
Original paper: https://arxiv.org/abs/1910.13302
YOLOv4: https://github.com/WongKinYiu/PyTorch_YOLOv4
YOLOv5: https://github.com/ultralytics/yolov5
Thank you! If you have any question on my repo, please feel free to contact to me with your issue.