-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* format * fix root_validator error * enforce pydantic >2.0.0 in setup.py * fix test errors and warnings * fix issues found by mypy * use model_dump in calibration * remove type ignore comments * split airo-dataset-tools readme * remove .dict() and change tests --------- Co-authored-by: tlips <[email protected]>
- Loading branch information
1 parent
7794633
commit c15625b
Showing
19 changed files
with
282 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,17 @@ | ||
# airo-dataset-tools | ||
Package for working with datasets. | ||
|
||
[COCO](https://cocodataset.org/#format-data) is the preferred format for computer vision datasets. We strictly follow their data format with 2 exceptions: segmentation masks are not required for Instance datasets, bounding boxes nor segmentation masks are required for keypoint datasets. This is to limit labeling effort for real-world datasets where you don't always need all annotation types. | ||
|
||
Other formats will are added if they are needed for dataset creation (think the format of a labeling tool) or for consumption of the dataset (think the YOLO format for training an object detector). Besides datasets, we also provide tools for other persistent data such as camera intrinsics and extrinsics. | ||
|
||
As always, we try to reuse existing tools/code as much as possible, but we have found that keypoints are by far not supported as well as segmentation or detection, so we had to write some custom tooling for working with keypoints. | ||
|
||
## Data Parsers | ||
The functionality is mainly provided in the form of [Pydantic](https://docs.pydantic.dev/) parsers, that can be used to load or create data(sets). The parsers can be found in the `data_parsers` folder. | ||
|
||
Avalaible Data Parsers: | ||
* [COCO Datasets](https://cocodataset.org/#format-data) | ||
* [CVAT 1.1 Images annotations](https://opencv.github.io/cvat/docs/manual/advanced/xml_format/) | ||
* [Pose format](docs/pose.md) | ||
* [Camera instrinsics format](docs/camera_intrinsics.md) | ||
|
||
## COCO dataset creation | ||
We provide a [documented](airo_dataset_tools/cvat_labeling/readme.md) worklow for labeling real-world data with [CVAT]() and to create [COCO]() Keypoints or Instance datasets based on these annotations. | ||
|
||
We also provide a number of tools for working with COCO datasets: | ||
- visualisation using [FiftyOne](https://voxel51.com/) | ||
- applying Albumentation transforms (e.g. resizing, flipping,...) to a COCO Keypoints dataset and its annotations, see [here](airo_dataset_tools/coco_tools/transform_dataset.py) | ||
- converting COCO instances to YOLO format, see [here](airo_dataset_tools/coco_tools/coco_instances_to_yolo.py) | ||
- combining COCO datasets (via datumaro)(TODO) | ||
|
||
Most of the COCO tools are available in the CLI, which you can access by running `airo-dataset-tools --help` from the command line. | ||
|
||
|
||
Tools for working with datasets. | ||
They fall into two categories: | ||
|
||
[**COCO related tools**](airo_dataset_tools/coco_tools/README.md): | ||
* COCO dataset loading (and creation) | ||
* FiftyOne visualisation | ||
* Albumentation transforms | ||
* COCO to YOLO conversion. | ||
* CVAT labeling workflow | ||
|
||
[**Data formats**](airo_dataset_tools/data_parsers/README.md): | ||
* 3D poses | ||
* Camera instrinsics | ||
|
||
> [Pydantic](https://docs.pydantic.dev/latest/) is used heavily throughout this package. | ||
It allows you to easily create Python objects that can be saved and loaded to and from JSON files. |
43 changes: 43 additions & 0 deletions
43
airo-dataset-tools/airo_dataset_tools/coco_tools/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# COCO | ||
|
||
Tools for working with COCO datasets. | ||
Most of the COCO tools are available in the CLI, which you can access by running `airo-dataset-tools --help` from the command line. | ||
|
||
Overview of the functionality: | ||
* [COCO](#dataset-loading) dataset loading | ||
* COCO dataset creation (e.g. with synthetic data or CVAT) | ||
* [CVAT labeling workflow](../../airo_dataset_tools/cvat_labeling/readme.md) | ||
* FiftyOne visualisation (see CLI) | ||
* Applying Albumentation transforms (e.g. resizing, flipping,...) to a COCO Keypoints dataset and its annotations, see [transform_dataset.py](transform_dataset.py) | ||
* Converting COCO instances to YOLO format, see [coco_instances_to_yolo.py](coco_instances_to_yolo.py) | ||
|
||
## Dataset loading | ||
We provide two main dataset [classes](./airo_dataset_tools/data_parsers/coco.py) for working with COCO: | ||
* `CocoInstancesDataset`: for COCO datasets without keypoints | ||
* `CocoKeypointsDataset`: for COCO datasets with keypoints | ||
|
||
You can read more about the COCO dataset format [here](https://cocodataset.org/#format-data). | ||
It is our preferred format for computer vision datasets. | ||
|
||
Loading a COCO dataset can be done as follows: | ||
```python | ||
from airo_dataset_tools.data_parsers.coco import CocoInstancesDataset | ||
|
||
with open("./test/test_data.instances_val2017_small.json", "r") as file: | ||
dataset = CocoInstancesDataset.model_validate_json(file.read()) | ||
|
||
print(len(dataset.images)) | ||
print(len(dataset.annotations)) | ||
``` | ||
|
||
## Notes | ||
|
||
[COCO](https://cocodataset.org/#format-data) is the preferred format for computer vision datasets. We strictly follow their data format with 2 exceptions: | ||
* Segmentation masks are not required for Instance datasets, | ||
* Bounding boxes nor segmentation masks are required for keypoint datasets. | ||
|
||
This is to limit labeling effort for real-world datasets where you don't always need all annotation types. | ||
|
||
Other formats will are added if they are needed for dataset creation (think the format of a labeling tool) or for consumption of the dataset (think the YOLO format for training an object detector). Besides datasets, we also provide tools for other persistent data such as camera intrinsics and extrinsics. | ||
|
||
As always, we try to reuse existing tools/code as much as possible, but we have found that keypoints are by far not supported as well as segmentation or detection, so we had to write some custom tooling for working with keypoints. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
airo-dataset-tools/airo_dataset_tools/data_parsers/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Data parsers | ||
We call our Pydantic Model classes *data parsers* because we use them to define, load and store data in a specific format. | ||
For documentation of the COCO data parsers, see [here](../coco_tools/README.md). | ||
The other data parsers we provide are: | ||
* [Pose](../../docs/pose.md) | ||
* [CameraIntrinsics](../../docs/camera_intrinsics.md) | ||
|
||
|
||
## Example usage | ||
|
||
:floppy_disk: **Creating a Pydantic Model instance and saving it to json:** | ||
```python | ||
from airo_dataset_tools.data_parsers.pose import EulerAngles, Pose, Position | ||
|
||
pose = Pose( | ||
position_in_meters=Position(x=1.0, y=2.0, z=3.0), | ||
rotation_euler_xyz_in_radians=EulerAngles(roll=np.pi / 4, pitch=-np.pi / 2, yaw=np.pi), | ||
) | ||
|
||
with open("pose.json", "w") as file: | ||
json.dump(pose.model_dump(exclude_none=True), file, indent=4) | ||
``` | ||
|
||
:mag_right: **Loading a Pydantic Model instance from json:** | ||
```python | ||
with open("pose.json", "r") as file: | ||
pose2 = Pose.model_validate_json(file.read()) | ||
|
||
x = pose2.position_in_meters.x | ||
print(x) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.