Converting custom made coco json to tfrecords using TLT MaskRCNN usecase

I am trying to convert custom-made coco annotations including objects and masks to TFRecords by running create_coco_tf_record.py from “TLT MaskRCNN example usecase”, but it keeps asking for caption_annotation_file.

INFO:tensorflow:Building bounding box index.
I0312 01:04:05.183368 140534908258048 create_coco_tf_record.py:212] Building bounding box index.
INFO:tensorflow:286 images are missing bboxes.
I0312 01:04:05.184590 140534908258048 create_coco_tf_record.py:223] 286 images are missing bboxes.
Traceback (most recent call last):
File “/workspace/server/create_coco_tf_record.py”, line 333, in
app.run(main)
File “/usr/local/lib/python3.6/dist-packages/absl/app.py”, line 299, in run
_run_main(main, args)
File “/usr/local/lib/python3.6/dist-packages/absl/app.py”, line 250, in _run_main
sys.exit(main(argv))
File “/workspace/server/create_coco_tf_record.py”, line 321, in main
num_shards=256)
File “/workspace/server/create_coco_tf_record.py”, line 275, in _create_tf_record_from_coco_annotations
_load_caption_annotations(caption_annotations_file))
File “/workspace/server/create_coco_tf_record.py”, line 230, in _load_caption_annotations
caption_annotations = json.load(fid)
File “/usr/lib/python3.6/json/ **init** .py”, line 296, in load
return loads(fp.read(),
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/lib/io/file_io.py”, line 122, in read
self._preread_check()
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/lib/io/file_io.py”, line 84, in _preread_check
compat.as_bytes(self.__name), 1024 * 512)
tensorflow.python.framework.errors_impl.NotFoundError: ; No such file or directory

Is there any way we convert coco annotations for just masks and not passing any caption using TLT.

I am using "nvcr.io/nvidia/tlt-streamanalytics:v2.0_py3 " docker container and the converter can be found/workspace/examples/maskrcnn/create_coco_tf_record.py

Thank you

Please login docker to check where is the caption_annotation_file.

Make sure you can “ls” the file when run below command
$ tlt mask_rcnn run ls <path to caption_annotation_file>

but I don’t have the caption_annotation_file. My custom dataset is just masks and there is no need for the caption.

@mohsen.zardadi
As we synced in ValueError: Total size of new array must be unchanged for box_head/class-predict/kernel lh_shape: [(1024, 1)], rh_shape: [(1024, 2)] - #4 by Morganh, is your issue(this forum topic) gone?

I found a work around for converting custom made coco json to tfrecords using the usecase code. If your dataset is just instance segmentations, and your dataset doesn’t have or need caption json files, like my dataset, you can make a dummy json file for captions and then use the usecase code (create_coco_tf_record.py). It will convert the coco format json annotations to tfrecords without problem. It is not the best solution but it works fine.

1 Like