pixano.datasets.exporters.coco_dataset_exporter
COCODatasetExporter(dataset, export_dir, overwrite=False, category_format='coco91', custom_category_dict=None)
Bases: DatasetExporter
Default JSON dataset exporter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
The dataset to be exported. |
required |
export_dir
|
str | Path
|
The directory where the exported files will be saved. |
required |
overwrite
|
bool
|
Whether to overwrite existing directory. |
False
|
category_format
|
str
|
Category format for name to ID conversion ("coco91", "coco80", "voc"). |
'coco91'
|
custom_category_dict
|
dict[str, int] | None
|
Custom category dictionary for name to ID conversion (supersedes category_format). |
None
|
Source code in pixano/datasets/exporters/coco_dataset_exporter.py
export_dataset_item(export_data, dataset_item)
Store the dataset item in the export_data
dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
export_data
|
dict[str, Any]
|
A dictionary containing the data to be exported. |
required |
dataset_item
|
DatasetItem
|
The dataset item to be exported. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary containing the data to be exported. |
Source code in pixano/datasets/exporters/coco_dataset_exporter.py
initialize_export_data(info, sources)
Initialize the dictionary or list of dictionaries to be exported.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info
|
DatasetInfo
|
The dataset information. |
required |
sources
|
list[Source]
|
The list of sources. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary containing the data to be exported. |
Source code in pixano/datasets/exporters/coco_dataset_exporter.py
save_data(export_data, split, file_name, file_num)
Save data to the specified directory.
The saved directory has the following structure
export_dir/{split}{file_name}_0.json /... /{split}{file_name}{file_num}.json /... /{split}{file_name}_n.json
Parameters:
Name | Type | Description | Default |
---|---|---|---|
export_data
|
dict[str, Any]
|
The dictionary containing the data to be saved. |
required |
split
|
str
|
The split of the dataset item being saved. |
required |
file_name
|
str
|
The name of the file to save the data in. |
required |
file_num
|
int
|
The number of the file to save the data in. |
required |
Source code in pixano/datasets/exporters/coco_dataset_exporter.py
coco_annotation(ann, existing_coco_ann=None, category_dict=None)
Return annotation in COCO format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ann
|
BBox | CompressedRLE | Entity
|
Annotation |
required |
existing_coco_ann
|
dict[str, Any] | None
|
Existing annotation in COCO format to complete |
None
|
category_dict
|
dict[str, int] | None
|
Category dictonary for name to ID conversion |
None
|
Returns: Annotation in COCO format
Source code in pixano/datasets/exporters/coco_dataset_exporter.py
coco_image(image, view)
Return image in COCO format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
Image
|
Image |
required |
view
|
str
|
Image view |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Image in COCO format |