アノテーションの確認

前のステップで作ったアノテーションを確認しましょう。

アノテーションを俯瞰的に確認する

プロジェクト名の下に配置されている「アノテーション」タブを選択すると、アノテーションの一覧が表示されます。この画面では、タスクを横断してアノテーションを見ることができます。

サイドの「ラベル」を選択すると、アノテーションのラベルで絞り込むことができます。さらに、選択したラベルが持つ属性で絞り込むこともできます。

アノテーションZIPを確認する

プロジェクト名の下に配置されている「アノテーション」タブを選択して、「アノテーションZIPをダウンロード」ボタンを押してください。モーダルダイアログの「ダウンロード」ボタンを押すと、すべてのアノテーションが格納されたZIP(アノテーションZIP)をダウンロードできます。

なお、作成したアノテーションは03:00(JST)頃にアノテーションZIPに反映されます。現在のアノテーションをアノテーションZIPに反映させたい場合は、モーダルダイアログ上の「現在のデータで手動更新」ボタンを押してください。アノテーションZIPの更新処理が開始されます。ただし、更新処理はデータ量に応じて数分から数十分かかります。

アノテーションZIPをダウンロードして、前のステップで作成したアノテーションを確認してみましょう。
アノテーションZIPのフォルダ構成は以下の通りです。JSONファイルは、入力データごとに存在します。

アノテーションZIP/
├── {タスクID}/
│   ├── {入力データID}.json              アノテーションのデータ
│   ├── {入力データID}/
│   │   ├── {アノテーションデータID}    塗りつぶしのPNG画像

アノテーションZIP内のJSONファイルには、以下のような内容が記載されてます。detailsキーにアノテーション情報が格納されています。JSONファイルのフォーマットについては、https://annofab.com/docs/api/#section/Simple-Annotation-ZIP を参照してください。

{
    "project_id": "877cdb50-6bed-4c07-8fbf-55c6e27eaa29",
    "annotation_format_version": "1.2.0",
    "task_id": "sample_task_01",
    "task_phase": "acceptance",
    "task_phase_stage": 1,
    "task_status": "not_started",
    "input_data_id": "gas-station_1706_20171111_R-DRV-610_20171111140522156-0-28784.jpg",
    "input_data_name": "gas-station_1706_20171111_R-DRV-610_20171111140522156-0-28784.jpg",
    "details": [
        {
            "label": "car",
            "annotation_id": "a67fa709-c47c-4210-8a21-1468920dc4e6",
            "data": {
                "left_top": {
                    "x": 1544,
                    "y": 755
                },
                "right_bottom": {
                    "x": 1681,
                    "y": 882
                },
                "_type": "BoundingBox"
            },
            "attributes": {
                "car_kind": "general_car",
                "condition": "",
                "tracking": "a67fa709-c47c-4210-8a21-1468920dc4e6",
                "traffic_lane": -1
            }
        },
        {
            "label": "whole",
            "annotation_id": "fcb847a5-5607-4467-a72b-fc11fb5cfbab",
            "data": {
                "_type": "Classification"
            },
            "attributes": {
                "weater": ""
            }
        }
    ],
    "updated_datetime": "2022-05-01T18:27:52.483+09:00"
}

SDKでアノテーションZIPの中身を読み込む

annofab-api-python-clientというAnnofabのPython SDK(Software Development Kit)では、アノテーションZIP内のJSONに対応するデータクラスを用意しています。Pythonのデータクラスを使って、アノテーションZIP内のデータを読み込むコードを、以下に記載します。詳細は https://annofab-api-python-client.readthedocs.io/en/latest/user_guide/advanced_usage.html を参照ください。

import zipfile
from annofabapi.parser import SimpleAnnotationZipParser

with zipfile.ZipFile("annotation.zip", "r") as zip_file:
    parser = SimpleAnnotationZipParser(zip_file, "sample_task_01/gas-station_1706_20171111_R-DRV-610_20171111140522156-0-28784.jpg.json")
    
    print(parser.task_id)
    # 'sample_task_01'

    print(parser.input_data_id)
    # 'gas-station_1706_20171111_R-DRV-610_20171111140522156-0-28784.jpg.json'
        
    simple_annotation = parser.parse()
		print(simple_annotation.details[0])
    # SimpleAnnotationDetail(label='car', annotation_id='a67fa709-c47c-4210-8a21-1468920dc4e6', data={'left_top': {'x': 1544, 'y': 755}, 'right_bottom': {'x': 1681, 'y': 882}, '_type': 'BoundingBox'}, attributes={'car_kind': 'general_car', 'condition': '', 'tracking': 'a67fa709-c47c-4210-8a21-1468920dc4e6', 'traffic_lane': -1})

まとめ

以上で、チュートリアル1は終了です。
チュートリアル1では、「車載カメラ画像」テンプレートを利用してプロジェクトを作り、自動車にアノテーションを付けました。またアノテーションZIPをダウンロードして、アノテーションのフォーマットを確認しました。