Introduction
echo1-coco-builder provides a faster, safer way to build coco formatted data.
See: https://cocodataset.org/#format-data for more information
Installation
# If using pip
pip install echo1-coco-builder
# If using poetry
poetry add echo1-coco-builder
Example use (building coco annotations)
import pandas as pd
from echo1_coco_builder.annotations_builder import CocoAnnotationsBuilder
# Open a CSV using pandas
df = pd.read_csv("./tests/data/test.csv")
# Initialize the coco builder
coco_builder = CocoAnnotationsBuilder()
# For each row in the csv
for annotation_id, row in df.iterrows():
# image_id must be an integer
image_id = row["image_name"]
# image_name must be a string
file_name = row["image_name"]
# image_width and image_height must be an integer
image_width = row["image_width"]
image_height = row["image_height"]
# category_id must be an integer
category_id = row["category_id"]
# category_name must be a string
category_name = row["category_name"]
# bbox format: [x,y,width,height]
bbox = row["bbox"].split(",")
# add a new image
coco_builder.add_image(
{
"id": image_id,
"file_name": file_name,
"width": image_width,
"height": image_height,
}
)
# add a new category
coco_builder.add_category({"id": category_id, "name": category_name})
# add a new annotation
coco_builder.add_annotation(
{
"id": annotation_id,
"image_id": image_id,
"category_id": category_id,
"bbox": bbox,
"segmentation": segmentation,
"iscrowd": 0,
"area": area,
}
)
# add info
coco_builder.add_info(
{
"year": 2022,
"version": "v1.0",
"contributor": "Echo1",
"description": "Contact for more info.",
"url": "https://echo1.io",
}
)
# print the data in the coco format as a python object
print(coco_builder)
# print the data in the coco format as json
print(coco_builder.get())
# save the data in the coco format as json
python_file = open("example-data.json", "w")
python_file.write(coco_builder.get())
python_file.close()
Example use (building coco results)
from echo1_coco_builder.results_builder import CocoResultsBuilder
# Initialize the coco generator
results_builder = CocoResultsBuilder()
results_builder.add_result(
{
"image_id": 1,
"bbox": [490, 365, 14, 26],
"score": 0.8559583425521851,
"category_id": 1,
"category_name": "My Category",
"segmentation": [],
"iscrowd": 0,
"area": 364,
}
)
# print the data in the coco results format as a python object
print(results_builder)
# print the data in the coco results format as json
print(results_builder.get())
Metadata
Release files for echo1-coco-builder 0.1.8
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 | Actions |
|---|---|---|---|---|
| echo1-coco-builder-0.1.8.tar.gz | 5.7 kB | Without provenance | Details for echo1-coco-builder-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| echo1_coco_builder-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for echo1_coco_builder-0.1.8-py3-none-any.whl |
Total release size: 13.5 kB
Release files / echo1-coco-builder-0.1.8.tar.gz
| Download URL | echo1-coco-builder-0.1.8.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5365ff0e96ad1096a5abb1073409c0729b760866533c18b6e129b7b15dc6ebcb
|
|
BLAKE2b-256 checksum How to use checksums |
081b021d7912a88e540b9d4b723c7a20838b3e48c2eb2fe84175a3dc77bd9568
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.2 Darwin/21.4.0
|
Release files / echo1_coco_builder-0.1.8-py3-none-any.whl
| Download URL | echo1_coco_builder-0.1.8-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39dd07564afecfaa8d3ec71ff1982f14c4abe062d727395749e472af59e0a17e
|
|
BLAKE2b-256 checksum How to use checksums |
27a464f9769768ff837d03665075beb13bfd3ba08a2065cf85ab69df202b6cd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.2 Darwin/21.4.0
|
Security for echo1-coco-builder 0.1.8
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.