COCO 데이터셋 Annotation에 대한 설명을 해 주신 글이 있어, 스크랩해 보았다.
Reference
- 본 게시물은 원본 게시물을 스크랩한 게시물입니다.
- 원본 게시물: (https://ukayzm.github.io/cocodataset/)
Annotation 파일 분석
Annotation 파일은 한 줄짜리 json 형식으로 되어 있습니다. 혹시라도, 이 파일을 그냥 vi로 열면 안됩니다. 수백메가 크기의 한 줄 짜리 파일이라, vi가 감당을 못합니다. 그래서, json beautifier를 이용하여 줄바꿈을 해 주어야 분석이 쉽습니다.
https://stedolan.github.io/jq/에서 jq binary를 다운로드 받습니다. 저는 64-bit Ubuntu용으로 다운로드 받아서, 파일 이름이 jq-linux64 네요. 그 다음,
$ jq-linux64 . instances_val2017.json > instances_val2017.beautified.json
이와 같이 하면 줄바꿈이 적용된 JSON 파일인 instances_val2017.beautified.json 파일이 생성됩니다.
이 중에서 instances에 대해 좀 더 자세히 알아보겠습니다.
Instances json file
Instances json file의 첫 부분은 아래와 같이 information과 license의 종류에 대한 내용입니다.
{
"info": {
"description": "COCO 2017 Dataset",
"url": "http://cocodataset.org",
"version": "1.0",
"year": 2017,
"contributor": "COCO Consortium",
"date_created": "2017/09/01"
},
"licenses": [
{
"url": "http://creativecommons.org/licenses/by-nc-sa/2.0/",
"id": 1,
"name": "Attribution-NonCommercial-ShareAlike License"
},
...
],
그 다음엔, 그림 파일에 대한 내용이 나옵니다.
"images": [
...
{
"license": 1,
"file_name": "000000324158.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000324158.jpg",
"height": 334,
"width": 500,
"date_captured": "2013-11-19 23:54:06",
"flickr_url": "http://farm1.staticflickr.com/169/417836491_5bf8762150_z.jpg",
"id": 324158
},
...
],
그 다음엔, 각 그림에 대한 annotation 정보가 나옵니다. Annotation이란, 그림에 있는 사물/사람의 segmentation mask와 box 영역, 카테고리 등의 정보를 말합니다. 아래 예는 COCO API Demo에서 사용된 image인 324159 그림의 annotation 중 일부 입니다.
"annotations": [
...
{
"segmentation": [
[
216.7,
211.89,
216.16,
217.81,
215.89,
220.77,
...
212.16
]
],
"area": 759.3375500000002,
"iscrowd": 0,
"image_id": 324158,
"bbox": [
196.51,
183.36,
23.95,
53.02
],
"category_id": 18,
"id": 10673
},
...
{
"segmentation": [
[
44.2,
167.74,
48.39,
162.71,
...
167.58
]
],
"area": 331.9790999999998,
"iscrowd": 0,
"image_id": 324158,
"bbox": [
44.2,
161.19,
36.78,
13.78
],
"category_id": 3,
"id": 345846
},
...
],
마지막으로, category 리스트가 나옵니다.
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person"
},
...
]
}