COCO 데이터셋은 여러 종류의 task 에 대한 모델을 훈련시킬 수 있음:
다음의 task들로 구분됨.
1. Object Detection (객체 탐지)
- 목적: 이미지 안에 있는 객체의 location 과 class (=category)를 추출 : things만
- annotation
bbox(bounding box)category_id(int)
- 출력 예
- 사람, 자동차, 개 등 80개 클래스
- 대표 사용 모델
- Faster R-CNN, YOLO, RetinaNet 등
관련 디렉토리 및 파일들.
train2017/
val2017/
annotations/instances_*.json
2. Instance Segmentation (인스턴스 분할)
- 목적: 객체를 pixel 단위로 정확히 분리 : things만
- annotation
segmentation(polygon 또는 RLE)bbox(bounding box)category_id(int)
- 특징
- 같은 클래스라도 객체 하나하나(=instance)를 구분
- 대표 사용 모델
- Mask R-CNN
관련 디렉토리 및 파일들.
train2017/
val2017/
annotations/instances_*.json
3. Keypoints / Pose Estimation (사람 자세 추정)
- 목적: 사람의 관절 위치 추정
- 대상 image
- person 단일 클래스 인 images
- 여러 instance 가 있을 수는 있지만 category_id가 person인 image에 주어짐.
- annotation
- 사람에 대한 bounding box
- 17개 keypoints (눈, 코, 어깨, 무릎 등)
(x, y, visibility): visibility에 의해 가려진 관절들이 처리 가능:0: not labeled (보이지도 않고 위치도 모름)1: labeled but not visible (관절의 위치는 추정 가능하나 가려진 상태)2: labeled and visible
- 활용
- (Human) Action Recognition
- Sports (Performance) Analsis
관련 디렉토리 및 파일들.
train2017/
val2017/
annotations/person_keypoints_*.json
4. Panoptic Segmentation (파노픽 분할)
- 목적
- Instance Segmentation + Semantic Segmentation 결합
- 구성
- image 1 장에 대해 panoptic mask 이미지(PNG)가 1장 주어짐.
- panoptic mask 이미지의 pixel의 값은
segment_id임:- Thing: 개별 객체 (사람, 자동차) - 80개 category로 구성.
- Stuff: 배경 영역 (하늘, 도로) - 130여개의 category로 구성.
- json파일 내의
segments_info필드 내id가segment_id이고 대응하는category_id가 주어짐- panoptic_train2017.json, panoptic_val2017.json 에 있음.
- 해당 픽셀이 뭐에 속하는지 표시.
- 특징
- 이미지 내 모든 픽셀에 라벨 부여
- 난이도
- COCO 태스크 중 가장 복합적
컴퓨터 비전에서 panoptic은 다음을 뜻함.
이미지 내 모든 픽셀을 객체(Thing)와 배경(Stuff)을 구분하여
동시에 빠짐없이 인식하는 것
관련 디렉토리 및 파일들.
train2017/
val2017/
annotations/panoptic_*.json
panoptic_train2017/
panoptic_val2017/
5. Image Captioning (이미지 캡셔닝)
- 목적:
- 이미지를 문장으로 설명
- 어노테이션
- 이미지당 여러 개의 자연어 문장
- 활용
- 멀티모달 학습, Vision-Language Model
관련 디렉토리 및 파일들.
train2017
val2017
annotations/captions_*.json
다운로드 및 구성
다운로드 (Windows에서 wget은 잘 동작안함. curl 추천)
mkdir coco
cd coco
curl -L http://images.cocodataset.org/zips/train2017.zip -o train2017.zip
curl -L http://images.cocodataset.org/zips/val2017.zip -o val2017.zip
curl -L http://images.cocodataset.org/annotations/annotations_trainval2017.zip ^
-o annotations_trainval2017.zip
curl -L http://images.cocodataset.org/annotations/panoptic_annotations_trainval2017.zip ^
-o panoptic_annotations_trainval2017.zip
압축 해제 (conda 로 git 설치하고 나면 unzip 존재)
unzip train2017.zip
unzip val2017.zip
unzip annotations_trainval2017.zip
unzip panoptic_annotations_trainval2017.zip
cd annotations
unzip panoptic_train2017.zip -d ../
unzip panoptic_val2017.zip -d ../
위의 scripts 실행 이후 다음의 디렉토리 구조를 가지며, pycocotools.COCO 등의 API를 사용 가능함.
2023.09.29 - [utils] - [Util] curl 간단사용법 정리 : web의 자원 다운로드하기.
[Util] curl 간단사용법 정리 : web의 자원 다운로드하기.
CLI (command line interface)로 URL을 통해,특정 자원(resource. 주로 설치파일이나 image등)을 웹으로부터 가져와 저장하는 tool. 엄밀히 말하면 다운로드만 하는 건 아님.다양한 프로토콜들(http, https, ftp, pop3
ds31x.tistory.com
디렉토리 및 파일 구성
coco/
├─ train2017/
├─ val2017/
├─ test2017/
├─ annotations/
│ ├─ instances_train2017.json
│ ├─ instances_val2017.json
│ ├─ person_keypoints_train2017.json
│ ├─ person_keypoints_val2017.json
│ ├─ captions_train2017.json
│ ├─ captions_val2017.json
│ ├─ panoptic_train2017.json
│ └─ panoptic_val2017.json
├─ panoptic_train2017/
└─ panoptic_val2017/
위에서 panoptic_xxx2017 디렉토리 들은 annotations 밑에 압축해제 시 놓이는 panoptic_xxx2017.zip 을 상단으로 풀어서 처리한다.
API들이 위의 구성을 보통 가정하기 때문임.
unzip panoptic_val2017.zip -d ../
unzip panoptic_train2017.zip -d ../
참고로, train2017, val2017, test2017 을 coco/images 에 놓는 구조가 사실 더 많이 사용된다.
압축을 풀고나서 정리해서 사용하는 경우가 많다보니...
coco/
├─ images/
│ ├─ train2017/
│ ├─ val2017/
│ └─ test2017/
│
├─ annotations/
│ ├─ instances_train2017.json
│ ├─ instances_val2017.json
│ ├─ person_keypoints_train2017.json
│ ├─ person_keypoints_val2017.json
│ ├─ captions_train2017.json
│ ├─ captions_val2017.json
│ ├─ panoptic_train2017.json
│ └─ panoptic_val2017.json
│
└─ panoptic/
├─ train2017/
└─ val2017/
정리 표
| Task | bbox | mask | keypoints | caption | file |
| Object Detection | O | X | X | X | instances_xxx.json |
| Instance Segmentation |
O | O | X | X | instances_xxx.json |
| Keypoints | O | X | O | X | person_keypoints_xxx.json |
| Panoptic Segmentation |
O | O | X | X | panoptic_xxx.json + panoptic PNG masks |
| Image Captioning | X | X | X | O | captions_xxx.json |
정리
- COCO는 단일 목적 데이터셋이 아니라 멀티태스크 데이터셋
- detection 튜토리얼에서 쓰는 COCO는 보통 Object Detection subset
annotations/*.json파일이 태스크별로 다름- 하나의 이미지가 여러 태스크에 동시에 사용될 수 있음
'ML' 카테고리의 다른 글
| Object Detection 태스크에 대한 모델 평가를 COCO API로 하기 (0) | 2025.12.16 |
|---|---|
| pycocotools COCO API 기초 (0) | 2025.12.16 |
| Detection Task에서 collate_fn의 입·출력 구조와 default_collate의 한계 (0) | 2025.12.15 |
| [PyTorch] tensor의 vectorized operation (0) | 2025.12.04 |
| Decision Tree - CART (Classification and Regression Trees) (0) | 2025.11.13 |
