Pycocotools

머선러닝·2023년 9월 24일
0

https://cocodataset.org/#detection-eval

기본적인 사용법

# Import 방법
from pycocotools.coco import COCO

# COCO 오브젝트 생성 방법
coco = COCO('path_to_annotation_file.json')

# 전체 카테고리를 각각의 개수와 함께 추출하는 방법
category_counts = {}
for cat_id in category_ids:
    category_info = coco.loadCats(cat_id)[0]
    category_name = category_info['name']
    category_count = len(coco.getAnnIds(catIds=cat_id))
    category_counts[category_name] = category_count
print(category_counts)
from pycocotools.coco import COCO


target_cat = 'unknown'

coco = COCO('test.json')

category_id = coco.getCatIds(catNms=[target_cat])[0]

small = 0
large = 0
medium = 0
ann_ids = coco.getAnnIds(catIds=category_id)
for ann_id in ann_ids:
    annotation = coco.loadAnns(ann_id)[0]
    area = annotation['area']
    
    if area <= 32**2:
        small += 1
    elif area >= 96**2:
        large += 1
    else:
        medium += 1

print(f'target_cat: {target_cat}, [s]{small} + [m]{medium} + [l]{large} = {small + medium + large}')

탐지 성능 평가하기

cocoEval
profile
머선러닝, 인공능지를 연구합니다.

0개의 댓글

Powered by GraphCDN, the GraphQL CDN