[![DOI](https://zenodo.org/badge/217881799.svg)](https://zenodo.org/badge/latestdoi/217881799)
## Weighted boxes fusion
Repository contains Python implementation of several methods for ensembling boxes from object detection models:
* Non-maximum Suppression (NMS)
* Soft-NMS [[1]](https://arxiv.org/abs/1704.04503)
* Non-maximum weighted (NMW) [[2]](http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w14/Zhou_CAD_Scale_Invariant_ICCV_2017_paper.pdf)
* **Weighted boxes fusion (WBF)** [[3]](https://arxiv.org/abs/1910.13302) - new method which gives better results comparing to others
## Requirements
Python 3.*, Numpy
# Installation
`pip install ensemble-boxes`
## Usage examples
Coordinates for boxes expected to be normalized e.g in range [0; 1]. Order: x1, y1, x2, y2.
Example of boxes ensembling for 2 models below.
* First model predicts 5 boxes, second model predicts 4 boxes.
* Confidence scores for each box model 1: [0.9, 0.8, 0.2, 0.4, 0.7]
* Confidence scores for each box model 2: [0.5, 0.8, 0.7, 0.3]
* Labels (classes) for each box model 1: [0, 1, 0, 1, 1]
* Labels (classes) for each box model 2: [1, 1, 1, 0]
* We set weight for 1st model to be 2, and weight for second model to be 1.
* We set intersection over union for boxes to be match: iou_thr = 0.5
* We skip boxes with confidence lower than skip_box_thr = 0.0001
```python
from ensemble_boxes import *
boxes_list = [[
[0.00, 0.51, 0.81, 0.91],
[0.10, 0.31, 0.71, 0.61],
[0.01, 0.32, 0.83, 0.93],
[0.02, 0.53, 0.11, 0.94],
[0.03, 0.24, 0.12, 0.35],
],[
[0.04, 0.56, 0.84, 0.92],
[0.12, 0.33, 0.72, 0.64],
[0.38, 0.66, 0.79, 0.95],
[0.08, 0.49, 0.21, 0.89],
]]
scores_list = [[0.9, 0.8, 0.2, 0.4, 0.7], [0.5, 0.8, 0.7, 0.3]]
labels_list = [[0, 1, 0, 1, 1], [1, 1, 1, 0]]
weights = [2, 1]
iou_thr = 0.5
skip_box_thr = 0.0001
sigma = 0.1
boxes, scores, labels = nms(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr)
boxes, scores, labels = soft_nms(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr, sigma=sigma, thresh=skip_box_thr)
boxes, scores, labels = non_maximum_weighted(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr, skip_box_thr=skip_box_thr)
boxes, scores, labels = weighted_boxes_fusion(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr, skip_box_thr=skip_box_thr)
```
#### Single model
If you need to apply NMS or any other method to single model predictions you can call function like that:
```python
from ensemble_boxes import *
# Merge boxes for single model predictions
boxes, scores, labels = weighted_boxes_fusion([boxes_list], [scores_list], [labels_list], weights=None, method=method, iou_thr=iou_thr, thresh=thresh)
```
More examples can be found in [example.py](./example.py)
## Accuracy and speed comparison
Comparison was made for ensemble of 5 different object detection models predictions trained on [Open Images Dataset](https://storage.googleapis.com/openimages/web/index.html) (500 classes).
Model scores at local validation:
* Model 1: mAP(0.5) 0.5164
* Model 2: mAP(0.5) 0.5019
* Model 3: mAP(0.5) 0.5144
* Model 4: mAP(0.5) 0.5152
* Model 5: mAP(0.5) 0.4910
| Method | mAP(0.5) Result | Best params | Elapsed time (sec) |
| ------ | --------------- | ----------- | ------------ |
| NMS | **0.5642** | IOU Thr: 0.5 | 47 |
| Soft-NMS | **0.5616** | Sigma: 0.1, Confidence Thr: 0.001 | 88 |
| NMW | **0.5667** | IOU Thr: 0.5 | 171 |
| WBF | **0.5982** | IOU Thr: 0.6 | 249 |
You can download model predictions as well as ground truth labels from here: [test_data.zip](https://github.com/ZFTurbo/Weighted-Boxes-Fusion/releases/download/v1.0/test_data.zip)
Ensemble script for them is available here: [example_oid.py](./example_oid.py)
## Description of WBF method
* https://arxiv.org/abs/1910.13302
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的竞赛项目学习资料,作为参考学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 2020年全国水下机器人(湛江)大赛源码+学习说明.zip
资源推荐
资源详情
资源评论
收起资源包目录
2020年全国水下机器人(湛江)大赛源码+学习说明.zip (53个子文件)
code_20105
information 5KB
logs
Logs.md 19KB
AHF_EXPERIMENT.md 29KB
Readme.md 2KB
code
Weighted-Boxes-Fusion
ensemble_boxes
__init__.py 295B
ensemble_boxes_nms.py 7KB
__pycache__
ensemble_boxes_nms.cpython-37.pyc 5KB
ensemble_boxes_nmw.cpython-37.pyc 4KB
ensemble_boxes_wbf.cpython-37.pyc 4KB
__init__.cpython-37.pyc 470B
ensemble_boxes_wbf.py 5KB
ensemble_boxes_nmw.py 5KB
setup.py 874B
example_oid.py 11KB
example.py 5KB
ensemble.ipynb 2.63MB
.ipynb_checkpoints
ensemble copy-checkpoint.ipynb 2.83MB
ensemble-checkpoint.ipynb 2.63MB
README.md 4KB
data_analysis.ipynb 962KB
draw_bbox.ipynb 26KB
mmdet
datasets
pipelines
transforms.py 44KB
losses
cross_entropy_loss.py 4KB
get_testjson.py 3KB
Retinex.py 9KB
poisson_blending.ipynb 180KB
draw_pred_bbox.ipynb 4KB
Motion_Blurring.ipynb 3.56MB
instance_balanced_augmentation.ipynb 521KB
Readme.md 2KB
poisson-image-editing
target_mask.png 2KB
002389.jpg 10KB
paint_mask.py 2KB
ref_Poisson image editing.pdf 1.77MB
main.py 3KB
target_result.png 129KB
poisson_image_editing.ipynb 482KB
mask.png 2KB
figs
example1
direct_merge1.png 315KB
mask1.png 3KB
source1.jpg 28KB
target1.jpg 64KB
all.png 921KB
possion1.png 316KB
demo
draw_mask.png 827KB
move_mask.png 1.2MB
.gitignore 173B
move_mask.py 3KB
.ipynb_checkpoints
poisson_image_editing-checkpoint.ipynb 482KB
README.md 2KB
002395.jpg 26KB
poisson_image_editing.py 3KB
config.py 10KB
共 53 条
- 1
资源评论
土豆片片
- 粉丝: 1557
- 资源: 5641
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功