|
|
@ -55,7 +55,7 @@ def convert_coco(labels_dir='../coco/annotations/', use_segments=False, use_keyp
|
|
|
|
data = json.load(f)
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
# Create image dict
|
|
|
|
# Create image dict
|
|
|
|
images = {'%g' % x['id']: x for x in data['images']}
|
|
|
|
images = {f'{x["id"]:d}': x for x in data['images']}
|
|
|
|
# Create image-annotations dict
|
|
|
|
# Create image-annotations dict
|
|
|
|
imgToAnns = defaultdict(list)
|
|
|
|
imgToAnns = defaultdict(list)
|
|
|
|
for ann in data['annotations']:
|
|
|
|
for ann in data['annotations']:
|
|
|
@ -63,7 +63,7 @@ def convert_coco(labels_dir='../coco/annotations/', use_segments=False, use_keyp
|
|
|
|
|
|
|
|
|
|
|
|
# Write labels file
|
|
|
|
# Write labels file
|
|
|
|
for img_id, anns in tqdm(imgToAnns.items(), desc=f'Annotations {json_file}'):
|
|
|
|
for img_id, anns in tqdm(imgToAnns.items(), desc=f'Annotations {json_file}'):
|
|
|
|
img = images['%g' % img_id]
|
|
|
|
img = images[f'{img_id:d}']
|
|
|
|
h, w, f = img['height'], img['width'], img['file_name']
|
|
|
|
h, w, f = img['height'], img['width'], img['file_name']
|
|
|
|
|
|
|
|
|
|
|
|
bboxes = []
|
|
|
|
bboxes = []
|
|
|
|