Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coco Format data parsing for EDA #4

Open
SangJunni opened this issue Nov 17, 2022 · 2 comments
Open

Coco Format data parsing for EDA #4

SangJunni opened this issue Nov 17, 2022 · 2 comments
Labels
good first issue Good for newcomers

Comments

@SangJunni
Copy link
Member

Coco Format parsing for EDA (just paste and use this!)

#import libraries
import json
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
import os
from pycocotools.coco import COCO

#image loader
src_root = 'root folder of dataset in your environment'
src_subset = 'subset root of your environment'
src_file = src_root + 'train.json'
src_desc = 'a name (identifier) for the dataset'

coco_obj = COCO(src_file)

#data load
with open(src_file, 'r') as f:
    root = json.load(f)
    
root.keys() #dict_keys(['info', 'licenses', 'images', 'categories', 'annotations'])

#Basic High level infromation
n_images = len(root['images'])
n_boxes = len(root['annotations'])
n_categ = len(root['categories'])

# height, width
heights = [x['height'] for x in root['images']]
widths = [x['width'] for x in root['images']]

print('Dataset Name: ',src_desc)
print('Number of images: ',n_images)
print('Number of bounding boxes: ', n_boxes)
print('Number of classes: ', n_categ)
print('Max min avg height: ', max(heights), min(heights), int(sum(heights)/len(heights)))
print('Max min avg width: ', max(widths), min(widths), int(sum(widths)/len(widths)))
@SangJunni SangJunni added the good first issue Good for newcomers label Nov 17, 2022
@SangJunni SangJunni pinned this issue Nov 17, 2022
@SangJunni
Copy link
Member Author

Another method over there Coco dataset open for eda #5

@0seob
Copy link
Contributor

0seob commented Nov 17, 2022

sry...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants