kognic-openlabel
1 分
このOpenLABEL JSONスキーマを使用して、アノテーションの操作を容易にするPythonパッケージkognic-openlabelを作成しました。このパッケージはOpenLABEL形式をpydanticモデルとしてモデル化しており、以下の方法でインストールできます。
pip install --upgrade kognic-openlabelpydanticを使用しているため、モデルにはバリデーションとシリアライズ・デシリアライズのためのメソッドが含まれています。以下は、異なる形式間で簡単に変換する方法の例です。
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)