pytorchcocotools
Unofficial APIs for the MS-COCO dataset using PyTorch.
Uses the official repository of the pycocotools packages as reference.
The file format is explained in the official documentation and nicely summarized here.
[!WARNING] This is work in progress, feel free to contribute!
Features
- Strongly typed COCO data format represetation
- Drop-in compatible
COCOandCOCOevalclasses - (Almost) drop-in compatible
maskmethods - Pure
torchimplementation torchvisiondata set using the latest transformation API- fully unit tested and documented
Installation
With pip:
python -m pip install pytorchcocotools
With uv:
uv add pytorchcocotools
How to use it
Pretty much all you need to do is to change the import statement from pycocotools to pytorchcocotools:
-import pycocotools
+import pytorchcocotools
So all imports look like this:
from pytorchcocotools.coco import COCO
from pytorchcocotools.cocoeval import COCOeval
...
API
[!WARNING] While the API is mostly compatible with the original
pycocotoolspackage, 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.
[!IMPORTANT] >
decode,encode,toBboxandfrPyObjectsnow 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 by providing single, defined return types, but is open for further discussion.
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.
COCOeval
Strongly typed as well. Includes also minor fixes, e.g. the __str__ now also returns the stats.
Other additions
pytorchcocotools.utils.coco.download.CocoDownloader: Whilegsutils rsyncis the officially recommended way to download the data, this allows you to trigger the download from Python.- The
loggerproperty in both all classes from theloggingmodule replaces theprintcommand, so you can fully customize it. pytorchcocotools.torch.dataset.CocoDetection: A drop-in replacement for the dataset fromtorchvision, now strongly typed using the newtransforms.v2api.
Docs
uv run mkdocs build -f ./mkdocs.yml -d ./_build/
Update template
copier update --trust -A --vcs-ref=HEAD
Credits
Metadata
Release files for pytorchcocotools 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pytorchcocotools-0.2.0.tar.gz | 53.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytorchcocotools-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 124.5 kB
Release files / pytorchcocotools-0.2.0.tar.gz
| Download URL | pytorchcocotools-0.2.0.tar.gz |
|---|---|
| Size | 53.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1aca29735e4a49ce6c4b3af4d2fb79e3dbe03ac8410068214257bd78babad2fe
|
|
BLAKE2b-256 checksum How to use checksums |
cd5bd57e19eba985bed9950712e041034f9910a87d98f18905548214ad745ed0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pytorchcocotools-0.2.0-py3-none-any.whl
| Download URL | pytorchcocotools-0.2.0-py3-none-any.whl |
|---|---|
| Size | 71.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
646444e83f59797a96c454c7e17235d521ce7857a898f6e9c88efb3d9925ca96
|
|
BLAKE2b-256 checksum How to use checksums |
b45765af831c644b290acbc6bf48ee792723eb7667fd056482cf3b88f0a2f69b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pytorchcocotools 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.