https://github.com/nielsrogge/coco-eval
A tiny package supporting distributed computation of COCO metrics for PyTorch models.
https://github.com/nielsrogge/coco-eval
coco metrics object-detection
Last synced: about 1 year ago
JSON representation
A tiny package supporting distributed computation of COCO metrics for PyTorch models.
- Host: GitHub
- URL: https://github.com/nielsrogge/coco-eval
- Owner: NielsRogge
- License: mit
- Created: 2023-02-27T20:24:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T21:21:56.000Z (over 3 years ago)
- Last Synced: 2025-04-06T23:12:37.607Z (about 1 year ago)
- Topics: coco, metrics, object-detection
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# coco-eval (PyTorch)
A tiny package supporting distributed computation of COCO metrics (like mAP) for PyTorch models.
## Installation
I made this package available on PyPi (thanks to [this guide](https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56)): https://pypi.org/project/coco-eval/.
```
pip install coco-eval
```
## Usage
The metric was taken and isolated from the [DETR repository](https://github.com/facebookresearch/detr/tree/main). Credits go to the authors.
High-level usage is as follows (assuming you have a PyTorch model that makes predictions):
```
from coco_eval import CocoEvaluator
from torchvision.datasets import CocoDetection
from torch.utils.data import DataLoader
dataset = CocoDetection(root="path_to_your_images", annFile="path_to_annotation_file")
dataloader = DataLoader(dataset, batch_size=2)
evaluator = CocoEvaluator(coco_gt=dataset.coco, iou_types=["bbox"])
model = ...
for batch in dataloader:
predictions = model(batch)
evaluator.update(predictions)
evaluator.synchronize_between_processes()
evaluator.accumulate()
evaluator.summarize()
```
Refer to my [DETR fine-tuning demo notebook](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/DETR/Fine_tuning_DetrForObjectDetection_on_custom_dataset_(balloon).ipynb) regarding an example of using it.