データセットの内容を理解する
1 分
このページは、データセットの内容を理解するのに役立ちます。
データセット内でどのシーンにアノテーションがあるかを把握する
どのシーンに対して予測を提供できるかを把握するには、データセット内でどのシーンにアノテーションがあるかを理解する必要があります。これは、データセット内のアノテーションを一覧表示するエンドポイントを使用して行えます。現在、データセットにシーンを追加する方法は、アノテーションをデータセットに追加する間接的な方法のみです。サポートが必要な場合やシーンをデータセットに関連付けたい場合は、お問い合わせください。以下のコードスニペットは、エンドポイントを利用してこれを実行し、CSVファイルに保存します。
from kognic.auth.requests.auth_session import RequestsAuthSession
import csv
base_url = "https://dataset.app.kognic.com"
client = RequestsAuthSession()
dataset_uuid = YOUR_DATASET_UUID
done = False
offset = 0
annotations = []
while not done:
print(f"Fetched {offset} annotations")
res = client.session.get(
f"{base_url}/v1/datasets/{dataset_uuid}/annotations?offset={offset}"
)
res_annotations = res.json()['data']
annotations += res_annotations
offset += len(res_annotations)
if len(res_annotations) == 0:
done = True
print(f"Fetched {len(annotations)} annotations")
# save to csv called dataset_{dataset_uuid}_annotations.csv
with open(f'dataset_{dataset_uuid}_annotations.csv', 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(annotations[0].keys())
for annotation in annotations:
writer.writerow(annotation.values())