{"id":13576390,"url":"https://github.com/ZFTurbo/Weighted-Boxes-Fusion","last_synced_at":"2025-04-05T05:31:41.720Z","repository":{"id":37821355,"uuid":"217881799","full_name":"ZFTurbo/Weighted-Boxes-Fusion","owner":"ZFTurbo","description":"Set of methods to ensemble boxes from different object detection models, including implementation of \"Weighted boxes fusion (WBF)\" method.","archived":false,"fork":false,"pushed_at":"2023-01-10T17:36:59.000Z","size":70,"stargazers_count":1758,"open_issues_count":36,"forks_count":238,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-29T23:06:10.008Z","etag":null,"topics":["boxes","ensemble-prediction","object-detection"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZFTurbo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-27T16:17:58.000Z","updated_at":"2025-03-27T19:31:30.000Z","dependencies_parsed_at":"2023-02-08T19:46:16.080Z","dependency_job_id":null,"html_url":"https://github.com/ZFTurbo/Weighted-Boxes-Fusion","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2FWeighted-Boxes-Fusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2FWeighted-Boxes-Fusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2FWeighted-Boxes-Fusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2FWeighted-Boxes-Fusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZFTurbo","download_url":"https://codeload.github.com/ZFTurbo/Weighted-Boxes-Fusion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294470,"owners_count":20915335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boxes","ensemble-prediction","object-detection"],"created_at":"2024-08-01T15:01:09.834Z","updated_at":"2025-04-05T05:31:36.700Z","avatar_url":"https://github.com/ZFTurbo.png","language":"Python","funding_links":[],"categories":["Python","Appendix: Object Detection for Natural Scene"],"sub_categories":["Papers"],"readme":"[![DOI](https://zenodo.org/badge/217881799.svg)](https://zenodo.org/badge/latestdoi/217881799)\n\n## Weighted boxes fusion\n\nRepository contains Python implementation of several methods for ensembling boxes from object detection models: \n\n* Non-maximum Suppression (NMS)\n* Soft-NMS [[1]](https://arxiv.org/abs/1704.04503)\n* Non-maximum weighted (NMW) [[2]](http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w14/Zhou_CAD_Scale_Invariant_ICCV_2017_paper.pdf)\n* **Weighted boxes fusion (WBF)** [[3]](https://arxiv.org/abs/1910.13302) - new method which gives better results comparing to others \n\n## Requirements\n\nPython 3.*, Numpy, Numba\n\n# Installation\n\n`pip install ensemble-boxes`\n\n## Usage examples\n\nCoordinates for boxes expected to be normalized e.g in range [0; 1]. Order: x1, y1, x2, y2. \n\nExample of boxes ensembling for 2 models below. \n* First model predicts 5 boxes, second model predicts 4 boxes.\n* Confidence scores for each box model 1: [0.9, 0.8, 0.2, 0.4, 0.7]\n* Confidence scores for each box model 2: [0.5, 0.8, 0.7, 0.3]\n* Labels (classes) for each box model 1: [0, 1, 0, 1, 1]\n* Labels (classes) for each box model 2: [1, 1, 1, 0]\n* We set weight for 1st model to be 2, and weight for second model to be 1.\n* We set intersection over union for boxes to be match: iou_thr = 0.5\n* We skip boxes with confidence lower than skip_box_thr = 0.0001\n\n```python\nfrom ensemble_boxes import *\n\nboxes_list = [[\n    [0.00, 0.51, 0.81, 0.91],\n    [0.10, 0.31, 0.71, 0.61],\n    [0.01, 0.32, 0.83, 0.93],\n    [0.02, 0.53, 0.11, 0.94],\n    [0.03, 0.24, 0.12, 0.35],\n],[\n    [0.04, 0.56, 0.84, 0.92],\n    [0.12, 0.33, 0.72, 0.64],\n    [0.38, 0.66, 0.79, 0.95],\n    [0.08, 0.49, 0.21, 0.89],\n]]\nscores_list = [[0.9, 0.8, 0.2, 0.4, 0.7], [0.5, 0.8, 0.7, 0.3]]\nlabels_list = [[0, 1, 0, 1, 1], [1, 1, 1, 0]]\nweights = [2, 1]\n\niou_thr = 0.5\nskip_box_thr = 0.0001\nsigma = 0.1\n\nboxes, scores, labels = nms(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr)\nboxes, scores, labels = soft_nms(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr, sigma=sigma, thresh=skip_box_thr)\nboxes, scores, labels = non_maximum_weighted(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr, skip_box_thr=skip_box_thr)\nboxes, scores, labels = weighted_boxes_fusion(boxes_list, scores_list, labels_list, weights=weights, iou_thr=iou_thr, skip_box_thr=skip_box_thr)\n```\n\n#### Single model\n\nIf you need to apply NMS or any other method to single model predictions you can call function like that:\n\n```python\nfrom ensemble_boxes import *\n# Merge boxes for single model predictions\nboxes, scores, labels = weighted_boxes_fusion([boxes_list], [scores_list], [labels_list], weights=None, method=method, iou_thr=iou_thr, thresh=thresh)\n```\n\nMore examples can be found in [example.py](examples/example.py)\n\n#### 3D version\n\nThere is support for 3D boxes in WBF method with `weighted_boxes_fusion_3d` function. Check example of usage in [example_3d.py](examples/example_3d.py)\n\n#### 1D version\n\nThere is support for 1D line segments in WBF method with `weighted_boxes_fusion_1d` function. Check example of usage in [example_1d.py](examples/example_1d.py). It was reported that 1D variant can be useful in Named-entity recognition (NER) type of tasks for Natural Language Processing (NLP) problems. Check discussion [here](https://www.kaggle.com/c/feedback-prize-2021/discussion/313389).\n\n## Benchmarks\n\n* Benchmark for [Open Images Dataset (5 models)](benchmark_oid/README.md)\n* Benchmark for [COCO Dataset (10 models)](benchmark_coco/README.md)\n* Benchmark for [NLP Dataset (10 models)](benchmark_nlp/README.md) - example for one-dimensional WBF variant\n\n## Description of WBF method and citation\n\n* https://arxiv.org/abs/1910.13302 (updated: 2020.08)\n* https://authors.elsevier.com/c/1ca0dxnVK3cWY \n\nIf you find this code useful please cite:\n\n```\n@article{solovyev2021weighted,\n  title={Weighted boxes fusion: Ensembling boxes from different object detection models},\n  author={Solovyev, Roman and Wang, Weimin and Gabruseva, Tatiana},\n  journal={Image and Vision Computing},\n  pages={1-6},\n  year={2021},\n  publisher={Elsevier}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZFTurbo%2FWeighted-Boxes-Fusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZFTurbo%2FWeighted-Boxes-Fusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZFTurbo%2FWeighted-Boxes-Fusion/lists"}