jsonl-to-coco.py
import json
from typing import List
import srsly
import typer
app = typer.Typer()
def convert_to_coco(input_file: str, output_file: str):
# Load the JSONL file using srsly
This file has been truncated. show original
prodigy-boundingbox-input.jsonl
{"image":"https://images.unsplash.com/photo-1434993568367-36f24aa04d2f?w=400","width":400,"height":267,"spans":[{"label":"SKATEBOARD","color":"yellow","x":47.5,"y":171.4,"width":109.1,"height":67.4,"points":[[47.5,171.4],[47.5,238.8],[156.6,238.8],[156.6,171.4]],"center":[102.05,205.1],"type":"rect"},{"label":"PERSON","color":"cyan","points":[[256,39.5],[237,78.5],[269,116.5],[286,67.5]],"type":"polygon"}]}
{"image":"https://images.unsplash.com/photo-1434993568367-36f24aa04d2f?w=500","width":500,"height":267,"spans":[{"label":"SKATEBOARD","color":"yellow","x":47.5,"y":171.4,"width":109.1,"height":67.4,"points":[[47.5,171.4],[47.5,238.8],[156.6,238.8],[156.6,171.4]],"center":[102.05,205.1],"type":"rect"},{"label":"PERSON","color":"cyan","points":[[256,39.5],[237,78.5],[269,116.5],[286,67.5]],"type":"polygon"}]}
prodigy-coco.json
{"info": {}, "licenses": [], "categories": [{"id": 1, "name": "SKATEBOARD", "supercategory": ""}, {"id": 2, "name": "PERSON", "supercategory": ""}], "images": [{"id": 1, "width": 400, "height": 267, "file_name": "https://images.unsplash.com/photo-1434993568367-36f24aa04d2f?w=400"}, {"id": 2, "width": 500, "height": 267, "file_name": "https://images.unsplash.com/photo-1434993568367-36f24aa04d2f?w=500"}], "annotations": [{"id": 1, "image_id": 1, "category_id": 1, "iscrowd": 0, "bbox": [47.5, 171.4, 109.1, 67.4], "area": 7353.34, "segmentation": [[47.5, 171.4, 47.5, 238.8, 156.6, 238.8, 156.6, 171.4]]}, {"id": 2, "image_id": 1, "category_id": 2, "iscrowd": 0, "segmentation": [[[256, 39.5], [237, 78.5], [269, 116.5], [286, 67.5]]]}, {"id": 3, "image_id": 2, "category_id": 1, "iscrowd": 0, "bbox": [47.5, 171.4, 109.1, 67.4], "area": 7353.34, "segmentation": [[47.5, 171.4, 47.5, 238.8, 156.6, 238.8, 156.6, 171.4]]}, {"id": 4, "image_id": 2, "category_id": 2, "iscrowd": 0, "segmentation": [[[256, 39.5], [237, 78.5], [269, 116.5], [286, 67.5]]]}]}