"# Convert label me annotations to COCO JSON format"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "jlmasaZNtJ6C"
},
"source": [
"Given the images and their corresponding annotated JSON files exported from the \"labelme\" tool. Our goal is to generate COCO format JSON files."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "M-LDdP-NtT3F"
},
"source": [
"We will use an open source library called labelme2coco to convert all the JSON files from \"labelme\" tool to COCO JSON format."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "RojnXi7lfLSA"
},
"source": [
"Put the annotated JSON files and their corresponding images in the same folder and create another folder for storing the output COCO JSON file and then use the labelme2coco tool to export the output."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Ud4OzlNMtHv7"
},
"outputs": [],
"source": [
"# install the library and RESTART runtime\n",
"!pip install labelme2coco"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "nWgcQzpHt4hq"
},
"outputs": [],
"source": [
"# import the library\n",
"import labelme2coco\n",
"import json"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"executionInfo": {
"elapsed": 56,
"status": "ok",
"timestamp": 1660342052001,
"user": {
"displayName": "",
"userId": ""
},
"user_tz": 420
},
"id": "3Wt3WELFXO5o"
},
"outputs": [],
"source": [
"# Import a sample annotation file exported from \"labelme\" tool and its corresponding image\n",