ParraghG
ParraghG

Reputation: 33

create tfrecord from labelme json file

I want to create an object detection neural network, from some special item with special shape with limited relativly small image datasets.For this i used labelme I think polygonal labeling would perform better then normal boxing labeling because of the shape of the object. I want to use of one the pretrained model from coco Tensorflow detection models, but im struggling to create tfrecord file from json files.As you can see below it countain both polygon and circle shape_type. Thank for your help in advance. If you know how to convert it to tfrecord or some alternative labeling program that would work better for my problem pls let me know i will just relabel my imageses if its solve my problem. json file For example:

    {
  "version": "3.5.0",
  "flags": {},
  "shapes": [
    {
      "label": "polygon",
      "line_color": null,
      "fill_color": null,
      "points": [
        [
          447,
          110
        ],
        [
          491,
          63
        ],
        [
          531,
          47
        ],
        [
          559,
          79
        ],
        [
          544,
          121
        ],
        [
          532,
          128
        ],
        [
          536,
          139
        ],
        [
          516,
          148
        ],
        [
          497,
          174
        ]
      ],
      "shape_type": "polygon"
    },
    {
      "label": "circle",
      "line_color": null,
      "fill_color": null,
      "points": [
        [
          403,
          317
        ],
        [
          377,
          262
        ]
      ],
      "shape_type": "circle"
    }
  ],
  "lineColor": [
    0,
    255,
    0,
    128
  ],
  "fillColor": [
    255,
    0,
    0,
    128
  ],
  "imagePath": "teszt.jpg",
  imageData ...(long data) 

Upvotes: 3

Views: 4017

Answers (1)

Shyam R
Shyam R

Reputation: 126

From the looks of JSON file i believe you are doing instance segmentation. You could use scripts provided in the labelme examples directory.

Instance Segmentation folder has two scripts labelme2coco.py and labelme2voc.py

So you can convert labelme JSONs to COCO format or VOC format and use them to build TFRecords

tensorflow models repo has a bunch of scripts to help you do this

Upvotes: 3

Related Questions