laitimes

JSON format COCO annotation sample generation, format conversion and visualization

author:Intelligent human
JSON format COCO annotation sample generation, format conversion and visualization

Video loading...

GeoLabel has provided perfect support for DOTA, YOLO, VOC and glVOC and other annotation formats, of which DOTA and YOLO are TXT format, VOC and glVOC are XML format, starting from GeoLabel version 2.3.2, new COCO format annotation sample support, which is JSON format.

The operations supported by the COCO format include:

  • SHP to COCO
  • COCO to SHP
  • COCO annotation merger
  • COCO annotation splitting

1. Sample graphic annotation

All graphics editing in GeoLabel is based on the ESRI Shapefile format (SHP format), which can be converted to COCO format after completing the SHP format annotation. The annotation method is GeoLabel's consistent labeling method.

JSON format COCO annotation sample generation, format conversion and visualization

Second, the SHP format is converted to the COCO format

Currently, segmentation, change detection, rotation box object detection, and horizontal box object detection annotations are supported to convert to COCO format.

This function is located in the [Free Function-Format Conversion-Format Conversion] tool, and can be converted to COCO format after completing the SHP format annotation.

JSON format COCO annotation sample generation, format conversion and visualization

The resulting JSON file looks like this:

JSON format COCO annotation sample generation, format conversion and visualization

JSON example (many nodes, simplified):

{
   "annotations" : [
      {
         "area" : 211469.0,
         "bbox" : [ 0.0, 0.0, 500.0, 500.0 ],
         "category_id" : 0,
         "id" : 0,
         "image_id" : 1,
         "iscrowd" : 0,
         "segmentation" : [
            [ 500.0, 500.0, 0.0, 500.0, 0.0, 0.0, 500.0, 0.0 ],
            [
               44.4,
               217.7,
               44.0,
               209.3,
               44.0,
               204.0,
               44.0,
               198.4,
               45.4,
               189.6,
               47.6
            ],
            [   
               320.0,
               224.1,
               288.0,
               220.9,
               268.0,
               219.0,
               265.5,
               220.7
            ],
            [
               221.3,
               315.1,
               218.8,
               314.7,
               212.2,
               314.3,
               208.0,
               314.0
            ]
         ]
      },
      {
         "area" : 14302.4,
         "bbox" : [ 149.4, 44.0, 147.6, 143.4 ],
         "category_id" : 1,
         "id" : 1,
         "image_id" : 1,
         "iscrowd" : 0,
         "segmentation" : [
            [
            
               175.7,
               56.5,
               180.4,
               52.6,
               185.9,
               49.1,
               189.6,
               47.6
            ]
         ]
      }
   ],
   "categories" : [
      {
         "id" : 0,
         "name" : "其他",
         "supercategory" : "其他"
      },
      {
         "id" : 1,
         "name" : "目标",
         "supercategory" : "目标"
      }
   ],
   "images" : [
      {
         "file_name" : "1_image.tif",
         "height" : 500,
         "id" : 1,
         "width" : 500
      }
   ],
   "info" : [ "none" ],
   "licenses" : [ "none" ]
}           

Third, COCO labeling merger

Sometimes the program needs to combine all the JSON annotations of the sample set into a label file (such as the public COCO dataset, which is a JSON file of several hundred megabytes), which can be synthesized automatically.

This feature is located in the Advanced - Batch Processing - COCO Disassembly tool.

JSON format COCO annotation sample generation, format conversion and visualization

The build result is shown in the following figure:

JSON format COCO annotation sample generation, format conversion and visualization

4. COCO label splitting

Often the entire dataset has only one large JSON file, and the annotations of all images are in this file (such as the public COCO dataset), which is too difficult to view and cannot be visualized, and it can be automatically split, and each picture corresponds to a JSON format annotation.

This feature is located in the Advanced - Batch Processing - COCO Disassembly tool.

JSON format COCO annotation sample generation, format conversion and visualization

The build result is shown in the following figure:

JSON format COCO annotation sample generation, format conversion and visualization

5. Convert COCO format to SHP format

COCO format as a text file, can not be visualized with general software, COCO format can be converted to SHP format, this function is located in [Free function - format conversion - format conversion] tool.

JSON format COCO annotation sample generation, format conversion and visualization

The build result is shown in the following figure:

JSON format COCO annotation sample generation, format conversion and visualization

6. SHP format visualization

Import samples in the Project-Import tool to check the labels. It can also be seen that after several conversions, the annotation can also be restored losslessly.

JSON format COCO annotation sample generation, format conversion and visualization
JSON format COCO annotation sample generation, format conversion and visualization
JSON format COCO annotation sample generation, format conversion and visualization