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 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] Building bounding box index.
INFO:tensorflow:286 images are missing bboxes.
I0312 01:04:05.184590 140534908258048] 286 images are missing bboxes.
Traceback (most recent call last):
File “/workspace/server/”, line 333, in
File “/usr/local/lib/python3.6/dist-packages/absl/”, line 299, in run
_run_main(main, args)
File “/usr/local/lib/python3.6/dist-packages/absl/”, line 250, in _run_main
File “/workspace/server/”, line 321, in main
File “/workspace/server/”, line 275, in _create_tf_record_from_coco_annotations
File “/workspace/server/”, 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(,
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/lib/io/”, line 122, in read
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/lib/io/”, 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 " " docker container and the converter can be found/workspace/examples/maskrcnn/

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.

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 ( It will convert the coco format json annotations to tfrecords without problem. It is not the best solution but it works fine.

1 Like