---
title: kognic-openlabel
slug: api-guide/ja/kognic-openlabel
docTags: 
createdAt: 2024-12-17T13:03:57.108Z
---

このOpenLABEL JSONスキーマを使用して、アノテーションの操作を容易にするPythonパッケージ[`kognic-openlabel`](https://pypi.org/project/kognic-openlabel)を作成しました。このパッケージはOpenLABEL形式を`pydantic`モデルとしてモデル化しており、以下の方法でインストールできます。

```bash
pip install --upgrade kognic-openlabel
```

`pydantic`を使用しているため、モデルにはバリデーションとシリアライズ・デシリアライズのためのメソッドが含まれています。以下は、異なる形式間で簡単に変換する方法の例です。

```python
openlabel_dict = {
    "openlabel": {
        "metadata": {
            "schema_version": "1.0.0"
        }
    }
}

from kognic.openlabel.models import OpenLabelAnnotation

# Deserialize dict
openlabel_annotation = OpenLabelAnnotation.model_validate(openlabel_dict)

# Serialize to json
openlabel_json = openlabel_annotation.model_dump_json(exclude_none=True)

# Deserialize json
openlabel_annotation = OpenLabelAnnotation.model_validate_json(openlabel_json)

# Serialize to dict
openlabel_dict = openlabel_annotation.model_dump(exclude_none=True)
```

