Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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) 
like image 244
ParraghG Avatar asked Nov 18 '25 10:11

ParraghG


1 Answers

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

like image 177
Shyam R Avatar answered Nov 20 '25 23:11

Shyam R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!