# pytorchcocotools
[![Build](https://github.com/twsl/pytorchcocotools/actions/workflows/build.yaml/badge.svg)](https://github.com/twsl/pytorchcocotools/actions/workflows/build.yaml)
[![Documentation](https://github.com/twsl/pytorchcocotools/actions/workflows/docs.yaml/badge.svg)](https://github.com/twsl/pytorchcocotools/actions/workflows/docs.yaml)
[![Docs with MkDocs](https://img.shields.io/badge/MkDocs-docs?style=flat&logo=materialformkdocs&logoColor=white&color=%23526CFE)](https://squidfunk.github.io/mkdocs-material/)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![linting: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](.pre-commit-config.yaml)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
[![Semantic Versions](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--versions-e10079.svg)](https://github.com/twsl/pytorchcocotools/releases)
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-border.json)](https://github.com/copier-org/copier)
[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
Unofficial APIs for the MS-COCO dataset using PyTorch.
Uses the official [repository](https://github.com/ppwwyyxx/cocoapi) of the `pycocotools` packages as reference.
The file format is explained in the [official documentation](https://cocodataset.org/#format-data) and nicely summarized [here](https://www.youtube.com/watch?v=h6s61a_pqfM).
## Features
- Strongly typed COCO data format [represetation](./src/pytorchcocotools/internal/structure/)
- Drop-in compatible `COCO` and `COCOeval` classes
- (Almost) drop-in compatible `mask` methods
- Pure `torch` implementation
- `torchvision` data set using the latest transformation API
- fully unit tested and documented
## Installation
With `pip`:
```bash
python -m pip install pytorchcocotools
```
With [`poetry`](https://python-poetry.org/):
```bash
poetry add pytorchcocotools
```
## How to use it
Pretty much all you need to do is to change the import statement from `pycocotools` to `pytorchcocotools`:
```diff
-import pycocotools
+import pytorchcocotools
```
So all imports look like this:
```python
from pytorchcocotools.coco import COCO
from pytorchcocotools.cocoeval import COCOeval
...
```
## API
> [!WARNING]
> While the API is mostly compatible with the original `pycocotools` package, there are some differences.
> For some methods you need to adapt the handling of the return type. See the examples below.
> [!NOTE]
> All methods are documented with detailed type hints.
### `mask`
All methods now have a optional `device` and `requires_grad` parameters that allows to specify the device on which the masks should be created and whether gradients are required. This is useful for acceleration.
`decode`, `encode` and `toBbox` now always return the batch/channel dimension implementation as opposed to a single return element if only a single element was passed. This was done to make the API more consistent, but is open for further discussion.
> [!IMPORTANT]
> Not yet done for `frPyObjects`.
### `COCO`
One major difference is that the `COCO` class now uses a strongly typed data structure to represent the COCO data format. This makes it easier to work with the data and to understand the structure of the data, but also might cause problems with data sources that do not strictly follow the data format.
## Docs
```bash
poetry run mkdocs build -f ./docs/mkdocs.yml -d ./_build/
```
## Update template
```bash
copier update --trust -A --vcs-ref=HEAD
```
## Credits
This project was generated with [![🚀 A generic python project template.](https://img.shields.io/badge/python--project--template-%F0%9F%9A%80-brightgreen)](https://github.com/twsl/python-project-template)
Raw data
{
"_id": null,
"home_page": "https://twsl.github.io/pytorchcocotools/",
"name": "pytorchcocotools",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "pytorch, pycocotools, pytorch-lightning, lightning, coco",
"author": "twsl",
"author_email": "45483159+twsl@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/8f/63/19b5acf303015b9a3124ac12768699c238aaabe255f8a8e6ca81492567d6/pytorchcocotools-0.1.0.tar.gz",
"platform": null,
"description": "# pytorchcocotools\n\n[![Build](https://github.com/twsl/pytorchcocotools/actions/workflows/build.yaml/badge.svg)](https://github.com/twsl/pytorchcocotools/actions/workflows/build.yaml)\n[![Documentation](https://github.com/twsl/pytorchcocotools/actions/workflows/docs.yaml/badge.svg)](https://github.com/twsl/pytorchcocotools/actions/workflows/docs.yaml)\n[![Docs with MkDocs](https://img.shields.io/badge/MkDocs-docs?style=flat&logo=materialformkdocs&logoColor=white&color=%23526CFE)](https://squidfunk.github.io/mkdocs-material/)\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n[![linting: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](.pre-commit-config.yaml)\n[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n[![Semantic Versions](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--versions-e10079.svg)](https://github.com/twsl/pytorchcocotools/releases)\n[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-border.json)](https://github.com/copier-org/copier)\n[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)\n\nUnofficial APIs for the MS-COCO dataset using PyTorch.\nUses the official [repository](https://github.com/ppwwyyxx/cocoapi) of the `pycocotools` packages as reference.\n\nThe file format is explained in the [official documentation](https://cocodataset.org/#format-data) and nicely summarized [here](https://www.youtube.com/watch?v=h6s61a_pqfM).\n\n## Features\n\n- Strongly typed COCO data format [represetation](./src/pytorchcocotools/internal/structure/)\n- Drop-in compatible `COCO` and `COCOeval` classes\n- (Almost) drop-in compatible `mask` methods\n- Pure `torch` implementation\n- `torchvision` data set using the latest transformation API\n- fully unit tested and documented\n\n## Installation\n\nWith `pip`:\n\n```bash\npython -m pip install pytorchcocotools\n```\n\nWith [`poetry`](https://python-poetry.org/):\n\n```bash\npoetry add pytorchcocotools\n```\n\n## How to use it\n\nPretty much all you need to do is to change the import statement from `pycocotools` to `pytorchcocotools`:\n\n```diff\n-import pycocotools\n+import pytorchcocotools\n```\n\nSo all imports look like this:\n\n```python\nfrom pytorchcocotools.coco import COCO\nfrom pytorchcocotools.cocoeval import COCOeval\n\n...\n```\n\n## API\n\n> [!WARNING]\n> While the API is mostly compatible with the original `pycocotools` package, there are some differences.\n> For some methods you need to adapt the handling of the return type. See the examples below.\n\n> [!NOTE]\n> All methods are documented with detailed type hints.\n\n### `mask`\n\nAll methods now have a optional `device` and `requires_grad` parameters that allows to specify the device on which the masks should be created and whether gradients are required. This is useful for acceleration.\n`decode`, `encode` and `toBbox` now always return the batch/channel dimension implementation as opposed to a single return element if only a single element was passed. This was done to make the API more consistent, but is open for further discussion.\n\n> [!IMPORTANT]\n> Not yet done for `frPyObjects`.\n\n### `COCO`\n\nOne major difference is that the `COCO` class now uses a strongly typed data structure to represent the COCO data format. This makes it easier to work with the data and to understand the structure of the data, but also might cause problems with data sources that do not strictly follow the data format.\n\n## Docs\n\n```bash\npoetry run mkdocs build -f ./docs/mkdocs.yml -d ./_build/\n```\n\n## Update template\n\n```bash\ncopier update --trust -A --vcs-ref=HEAD\n```\n\n## Credits\n\nThis project was generated with [![\ud83d\ude80 A generic python project template.](https://img.shields.io/badge/python--project--template-%F0%9F%9A%80-brightgreen)](https://github.com/twsl/python-project-template)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Unofficial APIs for the MS-COCO dataset using PyTorch",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://twsl.github.io/pytorchcocotools/",
"Repository": "https://github.com/twsl/pytorchcocotools"
},
"split_keywords": [
"pytorch",
" pycocotools",
" pytorch-lightning",
" lightning",
" coco"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f6f788ede02273276c6e07f292a3e7d74b0e37cbacddee43baf8d16cb663a45b",
"md5": "dc4ea5fb802e18f00f27eefb452faeea",
"sha256": "26f66253a4f713b3130df63811a0ce9fec2088c8840aa5e8b9b0a4cb216f8b56"
},
"downloads": -1,
"filename": "pytorchcocotools-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dc4ea5fb802e18f00f27eefb452faeea",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 66778,
"upload_time": "2025-01-02T17:30:55",
"upload_time_iso_8601": "2025-01-02T17:30:55.539032Z",
"url": "https://files.pythonhosted.org/packages/f6/f7/88ede02273276c6e07f292a3e7d74b0e37cbacddee43baf8d16cb663a45b/pytorchcocotools-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8f6319b5acf303015b9a3124ac12768699c238aaabe255f8a8e6ca81492567d6",
"md5": "e8a478a9ca385283cd47f3c3bdd670e8",
"sha256": "c32338a5cad3a4662da9043831078828d8526de34bf190417147d524fb70540a"
},
"downloads": -1,
"filename": "pytorchcocotools-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "e8a478a9ca385283cd47f3c3bdd670e8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 52123,
"upload_time": "2025-01-02T17:30:57",
"upload_time_iso_8601": "2025-01-02T17:30:57.923523Z",
"url": "https://files.pythonhosted.org/packages/8f/63/19b5acf303015b9a3124ac12768699c238aaabe255f8a8e6ca81492567d6/pytorchcocotools-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-02 17:30:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "twsl",
"github_project": "pytorchcocotools",
"github_not_found": true,
"lcname": "pytorchcocotools"
}