Unofficial APIs for the MS-COCO dataset using PyTorch
Project description
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 poetry:
poetry 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
poetry run mkdocs build -f ./docs/mkdocs.yml -d ./_build/
Update template
copier update --trust -A --vcs-ref=HEAD
Credits
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytorchcocotools-0.1.3.tar.gz.
File metadata
- Download URL: pytorchcocotools-0.1.3.tar.gz
- Upload date:
- Size: 54.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.13 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f80d53e020cb7f37c45c613d70d67d216338e88d3ee976c79ef2e6ababf8ec48
|
|
| MD5 |
f37025e131db38fcc199bc9908b863f0
|
|
| BLAKE2b-256 |
38473c48244bd305883d49eacf5461d7012f77bddbfbf3a11009a8fa4f9bac1d
|
File details
Details for the file pytorchcocotools-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pytorchcocotools-0.1.3-py3-none-any.whl
- Upload date:
- Size: 71.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.13 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4481a45ddfdae117029bf36ca2a95ee7e299e1444af2f71829a777a0404ecbbf
|
|
| MD5 |
54ef674a5bc33f45eb3be4f68cece558
|
|
| BLAKE2b-256 |
965dff2fc8408a837ee9ba421db3a9395da8f53579705f01469c37529a3d4238
|